rdkit: Error drawing molecule with MolDraw2DSVG
Hi all,
I’ve been following along on this blog post in a IPython notebook. However, when I get to step 4 in the blog post (using identical code), I get the following error:
---------------------------------------------------------------------------
ArgumentError Traceback (most recent call last)
<ipython-input-13-0f637ca1e274> in <module>()
----> 1 SVG(moltosvg(m))
<ipython-input-12-f15ebd7dae1f> in moltosvg(mol, molSize, kekulize)
9 mc = Chem.Mol(mol.ToBinary())
10 if not mc.GetNumConformers():
---> 11 rdDepictor.Compute2DCoords(mc)
12 drawer = rdMolDraw2D.MolDraw2DSVG(molSize[0],molSize[1])
13 drawer.DrawMolecule(mc)
ArgumentError: Python argument types in
rdkit.Chem.rdDepictor.Compute2DCoords(Mol)
did not match C++ signature:
Compute2DCoords(RDKit::ROMol {lvalue} mol, bool canonOrient=True, bool clearConfs=True, boost::python::dict {lvalue} coordMap={}, unsigned int nFlipsPerSample=0, unsigned int nSample=0, int sampleSeed=0, bool permuteDeg4Nodes=False, double bondLength=-1.0)
If I try to use a non-SMILES pathway, using a molecule from the ZINC database like this one (you can download the mol2 file from there), I get the following error:
---------------------------------------------------------------------------
ArgumentError Traceback (most recent call last)
<ipython-input-16-0f637ca1e274> in <module>()
----> 1 SVG(moltosvg(m))
<ipython-input-15-ba161ab9d915> in moltosvg(mol, molSize, kekulize)
12 rdDepictor.Compute2DCoords(mc)
13 drawer = rdMolDraw2D.MolDraw2DSVG(molSize[0],molSize[1])
---> 14 drawer.DrawMolecule(mc)
15 drawer.FinishDrawing()
16 svg = drawer.GetDrawingText()
ArgumentError: Python argument types in
MolDraw2D.DrawMolecule(MolDraw2DSVG, Mol)
did not match C++ signature:
DrawMolecule(RDKit::MolDraw2D {lvalue} self, RDKit::ROMol mol, boost::python::api::object highlightAtoms, boost::python::api::object highlightBonds, boost::python::api::object highlightAtomColors=None, boost::python::api::object highlightBondColors=None, boost::python::api::object highlightAtomRadii=None, int confId=-1)
DrawMolecule(RDKit::MolDraw2D {lvalue} self, RDKit::ROMol mol, boost::python::api::object highlightAtoms=None, boost::python::api::object highlightAtomColors=None, boost::python::api::object highlightAtomRadii=None, int confId=-1)
I am lost because I don’t know C/C++ or python bindings very well. Any hints as to what’s going wrong or what I’m doing wrong?
(Side note: I don’t know what this means, but I was looking through the source code I noticed that it appears (to my naive eyes) that there is a duplicated piece of code here.)
Other helpful info:
Platform: OS X 10.10.5
IPython Version: 4.0.1
Python version: 3.4.3
RDkit version: rdkit 2015.09.1 py34_1 (downloaded from conda)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 16 (9 by maintainers)
just fyi, i’ve been running into this issue on Windows (64bit) python 3.6 you can install both cairo and cairocffi via a combination of
condaandpipand it’s back to pretty pictures.
interestingly the
IPythonConsole.ipython_useSVG=Trueflag was causing an error, i’ll raise a separate issue for it.I can confirm this now works with the 2016.03.1 release (
conda install -c rdkit rdkit) and anaconda python 3.5 and 2.7.