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

cairo error when using similarity maps #5383

Closed
greglandrum opened this issue Jun 22, 2022 · 0 comments
Closed

cairo error when using similarity maps #5383

greglandrum opened this issue Jun 22, 2022 · 0 comments
Assignees
Labels
Milestone

Comments

@greglandrum
Copy link
Member

To Reproduce
Here's the contents of foo.py

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
@greglandrum greglandrum self-assigned this Jun 22, 2022
@greglandrum greglandrum added this to the 2022_03_4 milestone Jun 22, 2022
greglandrum added a commit to greglandrum/rdkit that referenced this issue Jun 27, 2022
greglandrum added a commit that referenced this issue Jul 5, 2022
* Fixes #5383

* response to review
this is a better fix
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

1 participant