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
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import SimilarityMaps
import rdkit
print(rdkit.__version__)
atorvastatin = Chem.MolFromSmiles('O=C(O)C[C@H](O)C[C@H](O)CCn2c(c(c(c2c1ccc(F)cc1)c3ccccc3)C(=O)Nc4ccccc4)C(C)C')
from rdkit.Chem import rdMolDescriptors
ator_contribs = rdMolDescriptors._CalcCrippenContribs(atorvastatin)
d = Draw.MolDraw2DCairo(400, 400)
# d.DrawMolecule(atorvastatin)
SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin,[x[0] for x in ator_contribs],draw2d=d)
d.FinishDrawing()
png = d.GetDrawingText()
and here's what happens when you run it:
$ python foo.py
[16:05:41]
****
Pre-condition Violation
no draw context
Violation occurred on line 203 in file D:\bld\rdkit_1654409205274\work\Code\GraphMol\MolDraw2D\MolDraw2DCairo.cpp
Failed Expression: dp_cr
****
2022.03.3
Traceback (most recent call last):
File "C:\Users\glandrum\foo.py", line 13, in <module>
SimilarityMaps.GetSimilarityMapFromWeights(atorvastatin,[x[0] for x in ator_contribs],draw2d=d)
File "C:\Users\glandrum\mambaforge\envs\my-rdkit-env\lib\site-packages\rdkit\Chem\Draw\SimilarityMaps.py", line 172, in GetSimilarityMapFromWeights
draw2d.ClearDrawing()
RuntimeError: Pre-condition Violation
no draw context
Violation occurred on line 203 in file Code\GraphMol\MolDraw2D\MolDraw2DCairo.cpp
Failed Expression: dp_cr
RDKIT: 2022.03.3
BOOST: 1_74
Uncommenting the d.DrawMolecule(atorvastatin) line clears up the error.
Configuration (please complete the following information):
RDKit version: 2022.03.x (and master)
OS: all (tested on windows and linux)
Python version (if relevant): all
The text was updated successfully, but these errors were encountered:
To Reproduce
Here's the contents of foo.py
and here's what happens when you run it:
Uncommenting the
d.DrawMolecule(atorvastatin)
line clears up the error.Configuration (please complete the following information):
The text was updated successfully, but these errors were encountered: