Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot draw molecule which includes an atom with a [!#X] query (for any X) #6033

Closed
ShangChien opened this issue Jan 31, 2023 · 6 comments
Closed
Assignees
Labels
Milestone

Comments

@ShangChien
Copy link

Describe the bug
m = Chem.MolFromSmiles('CO*.C1=CC=NC=C1 |c:2,4,6,m:2:3.5.4|') can work well, but execute m with error:
image
full error :

[12:36:57] 

****
Pre-condition Violation
bad query type
Violation occurred on line 1169 in file C:\rdkit\build\temp.win-amd64-cpython-38\Release\rdkit\Code\GraphMol\MolDraw2D\DrawMol.cpp
Failed Expression: atom.getQuery()->getDescription() == "AtomOr"
****

Output exceeds the [size limit](command:workbench.action.openSettings?[). Open the full output data [in a text editor](command:workbench.action.openLargeOutput?64f7c3ce-2006-40ac-a17b-79e30aced92d)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
File d:\conda\lib\site-packages\IPython\core\formatters.py:343, in BaseFormatter.__call__(self, obj)
    341     method = get_real_method(obj, self.print_method)
    342     if method is not None:
--> 343         return method()
    344     return None
    345 else:

File d:\conda\lib\site-packages\rdkit\Chem\Draw\IPythonConsole.py:155, in _toPNG(mol)
    153   highlightAtoms = []
    154 kekulize = kekulizeStructures
--> 155 return Draw._moltoimg(mol, molSize, highlightAtoms, "", returnPNG=True, kekulize=kekulize,
    156                       drawOptions=drawOptions)

File d:\conda\lib\site-packages\rdkit\Chem\Draw\__init__.py:489, in _moltoimg(mol, sz, highlights, legend, returnPNG, drawOptions, **kwargs)
    486   d2d.DrawMolecule(mc, legend=legend or "", highlightAtoms=highlights or [],
    487                    highlightBonds=bondHighlights)
    488 else:
--> 489   d2d.DrawMolecule(mc, legend=legend or "", highlightAtoms=highlights or [])
    490 d2d.FinishDrawing()
    491 if returnPNG:
RuntimeError: Pre-condition Violation
	bad query type
...
	Violation occurred on line 1169 in file Code\GraphMol\MolDraw2D\DrawMol.cpp
	Failed Expression: atom.getQuery()->getDescription() == "AtomOr"
	RDKIT: 2022.09.4
	BOOST: 1_78
<rdkit.Chem.rdchem.Mol at 0x27c4e1fe7b0>

Expected behavior
image

Version:rdkit-2022.9.4

@ShangChien ShangChien added the bug label Jan 31, 2023
@ShangChien
Copy link
Author

#5980 related issue

@greglandrum
Copy link
Member

#5980 related issue

That issue is not related to this one

@greglandrum
Copy link
Member

Confirmed. we will look into this

@ShangChien
Copy link
Author

ShangChien commented Jan 31, 2023

For poor my code review skill, i can only provide user's info: For above whole enumrate mols process, rdkit-2022.3.* work very well. 2022.9.* may not stable for it.
but still thanks for rdkit team !

@greglandrum greglandrum self-assigned this Jan 31, 2023
@greglandrum
Copy link
Member

greglandrum commented Jan 31, 2023

Here's a shorter reproducible, the problem isn't actually in the drawing code. I think it's in the changes made as part of the fix for #5930

In [23]: qm = Chem.MolFromSmarts('[!#1]')

In [24]: d2d = Draw.MolDraw2DSVG(-1,-1)

In [25]: d2d.DrawMolecule(qm)
[06:35:19]

****
Pre-condition Violation
bad query type
Violation occurred on line 1169 in file D:\bld\rdkit_1674051513102\work\Code\GraphMol\MolDraw2D\DrawMol.cpp
Failed Expression: atom.getQuery()->getDescription() == "AtomOr"
****

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In [25], line 1
----> 1 d2d.DrawMolecule(qm)

RuntimeError: Pre-condition Violation
        bad query type
        Violation occurred on line 1169 in file Code\GraphMol\MolDraw2D\DrawMol.cpp
        Failed Expression: atom.getQuery()->getDescription() == "AtomOr"
        RDKIT: 2022.09.4
        BOOST: 1_78

@greglandrum greglandrum changed the title rdkit-2022.9.4 has a problem to display 2d-structure, which mol from Chem.MolFromSmiles(CXSMILES) Cannot draw molecule which includes an atom with a [!#X] query (for any X) Jan 31, 2023
@greglandrum greglandrum added this to the 2022_09_5 milestone Jan 31, 2023
@greglandrum
Copy link
Member

This was fixed by #6055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants