You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you are using conda, which channel did you install the rdkit from? rdkit
If you are not using conda: how did you install the RDKit?
Description:
I would like to generate pictures for some SMARTS definitions using rdMolDraw2D. I found that for some SMARTS it is not possible to generate pictures using Cairo, as it ends up with kekulization error. The same procedure using SVG as is succesful. Setting parameters like prepareMolsBeforeDrawing = False, or PrepareMolForDrawing(mol, kekulize=False), does not help and ends up with the same error. Example code below
Working code for SVG engine
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import rdMolDraw2D
from rdkit.Chem import rdDepictor
rdDepictor.SetPreferCoordGen(True)
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import SVG
import rdkit
print(rdkit.__version__)
mol = Chem.MolFromSmarts('c[N+]#[N]')
d2d = rdMolDraw2D.MolDraw2DSVG(300, 300)
d2d.DrawMolecule(mol)
d2d.FinishDrawing()
SVG(d2d.GetDrawingText())
The same for Cairo
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import rdMolDraw2D
from rdkit.Chem import rdDepictor
rdDepictor.SetPreferCoordGen(True)
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import SVG
import rdkit
print(rdkit.__version__)
mol = Chem.MolFromSmarts('c[N+]#[N]')
d2d = rdMolDraw2D.MolDraw2DCairo(300, 300)
d2d.DrawMolecule(mol)
d2d.FinishDrawing()
end up with error:
RDKit ERROR: [17:49:00] non-ring atom 0 marked aromatic
It does not work even if I try to switch preparation of molecule before drawing
from rdkit import Chem
from rdkit.Chem import AllChem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import rdMolDraw2D
from rdkit.Chem import rdDepictor
rdDepictor.SetPreferCoordGen(True)
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import SVG
import rdkit
print(rdkit.__version__)
mol = Chem.MolFromSmarts('c[N+]#[N]')
d2d = rdMolDraw2D.MolDraw2DCairo(300, 300)
d2d.prepareMolsBeforeDrawing = False
Options = d2d.drawOptions()
Options.prepareMolsBeforeDrawing = False
d2d.SetDrawOptions(Options)
mol1 = rdMolDraw2D.PrepareMolForDrawing(mol, kekulize=False)
mol1.UpdatePropertyCache(False)
d2d.DrawMolecule(mol1)
d2d.FinishDrawing()
RDKit ERROR: [17:52:50] non-ring atom 0 marked aromatic
The text was updated successfully, but these errors were encountered:
@wopozka , the comment from @DavidACosgrove is correct.
Until we fix the problem (which is a bug), you can work around it by disabling the code which writes metadata to the PNG Options.includeMetadata = False
@greglandrum, thanks for the valuable advice. As I can use svg that is not a problem for me. I just noticed strange behaviour during png generation and then switched to svg.
Configuration:
import rdkit
rdkit.version
-->
Description:
I would like to generate pictures for some SMARTS definitions using rdMolDraw2D. I found that for some SMARTS it is not possible to generate pictures using Cairo, as it ends up with kekulization error. The same procedure using SVG as is succesful. Setting parameters like prepareMolsBeforeDrawing = False, or PrepareMolForDrawing(mol, kekulize=False), does not help and ends up with the same error. Example code below
end up with error:
RDKit ERROR: [17:49:00] non-ring atom 0 marked aromatic
It does not work even if I try to switch preparation of molecule before drawing
RDKit ERROR: [17:52:50] non-ring atom 0 marked aromatic
The text was updated successfully, but these errors were encountered: