You are exactly right.
New question is about aggdraw.
I successfully compiled it, yet I get the following:
> In [1]: from rdkit.Chem import AllChem
>
> In [2]: from rdkit.Chem import Draw
>
> In [3]: import aggdraw
>
> In [4]: mol = AllChem.MolFromSmiles('[H]n1c2ccccc2c2n([H])c3ccccc3c12')
>
> In [5]: Draw.MolToImageFile(mol,"a.jpg")
> ---------------------------------------------------------------------------
> IOError Traceback (most recent call last)
>
> /home/aryeh/<ipython console> in <module>()
>
> /usr/lib/python2.6/dist-packages/rdkit/Chem/Draw/__init__.py in
> MolToImageFile(mol, filename, size, kekulize, wedgeBonds)
> 46
> 47 def MolToImageFile(mol,filename,size=(300,300),kekulize=True,
> wedgeBonds=True):
> ---> 48 img =
> MolToImage(mol,size=size,kekulize=kekulize,wedgeBonds=wedgeBonds)
> 49 img.save(filename)
> 50
>
> /usr/lib/python2.6/dist-packages/rdkit/Chem/Draw/__init__.py in
> MolToImage(mol, size, kekulize, wedgeBonds)
> 40
> 41 drawer.wedgeDashedBonds=wedgeBonds
> ---> 42 drawer.AddMol(mol)
> 43 canvas.flush()
> 44
>
> /usr/lib/python2.6/dist-packages/rdkit/Chem/Draw/MolDrawing.py in
> AddMol(self, mol, canvas, centerIt, molTrans, drawingTrans, highlightAtoms,
> confId)
> 381 color = elemDict.get(atom.GetAtomicNum(),(0,0,0))
> 382 self._drawLabel(canvas,symbol,pos,font,color=color,
> --> 383 highlightIt=(highlightAtoms and idx in
> highlightAtoms))
> 384
> 385 def registerCanvas(canvasNm):
>
> /usr/lib/python2.6/dist-packages/rdkit/Chem/Draw/MolDrawing.py in
> _drawLabel(self, canvas, label, pos, font, color, highlightIt)
> 267 y1 = pos[1]
> 268 labelP = x1,y1
> --> 269 addCanvasText(canvas,label,(x1,y1),font,color)
> 270
> 271 def
> AddMol(self,mol,canvas=None,centerIt=True,molTrans=(0,0),drawingTrans=(0,0),
>
> /usr/lib/python2.6/dist-packages/rdkit/Chem/Draw/aggCanvas.py in
> addCanvasText(canvas, text, pos, font, color, **kwargs)
> 72 def addCanvasText(canvas,text,pos,font,color=(0,0,0),**kwargs):
> 73 color = convertColor(color)
> ---> 74 font = Font(color,faceMap[font.face],size=font.size)
> 75 w,h=canvas.textsize(text,font)
> 76 bw,bh=w*1.1,h*1.1
>
> IOError: cannot load font
>
Aggdraw was compiled with freetype support (at least it should have been). I
have the libraries installed, and pointed aggdraw's setup.py to /usr.
Why would I be getting this problem?
-Ari
On Thu, Jul 9, 2009 at 3:43 PM, Greg Landrum <[email protected]> wrote:
> On Thu, Jul 9, 2009 at 9:34 PM, Aryeh
> Gold-Parker<[email protected]> wrote:
> > I'll be honest, I made it using cinfony and then converted it to an rdkit
> > molecule.
> >
> >> >>> rdkitmol = rdkit.Molecule(pybelmol)
> >
> > It worked great when I constructed the molecule using
> > rdkit.Chem.MolFromSmiles(smi).
>
> I suspect that cinfony isn't actually giving you an RDKit molecule. Try
> this:
> [4] >>> m = Chem.MolFromSmiles('CCOC')
>
> [6] >>> type(m)
> Out[6]: <class 'rdkit.Chem.rdchem.Mol'>
>
> I think in cinfony to get the underlying RDKit molecule, you need to
> do something like:
>
> >>> mol = rdkit.Molecule(pybelmol)
> >>> rdkitmol = mol.Mol
> >>> Draw.MolToImageFile(rdkitmol, 'a.png')
>
> -greg
>