Greg Landrum schrieb: > Dear Thomas, > > On Thu, Apr 29, 2010 at 4:05 PM, Thomas Heller <thel...@ctypes.org> wrote: >> >> I get errors when trying to depict this smiles string: OC(=O)[C@@H]1CCCN1 >> >> It is from the wikipedia entry for Proline: >> http://en.wikipedia.org/wiki/Proline >> >> As it turns out rdkit is passing 'nan' as coordinates to all the drawing >> functions ;-( > > Can you please provide a bit of code that demonstrates the problem? > > The following works fine for me: > [16]>>> from rdkit import Chem > [17]>>> from rdkit.Chem import Draw > [18]>>> m = Chem.MolFromSmiles('OC(=O)[C@@H]1CCCN1') > [19]>>> Draw.MolToImageFile(m,'proline.png')
Greg, does 'proline.png' contain a valid image in your case? Attached is a script that demonstrates the problem. It uses a custom Canvas class that prints the calls to stdout - my real code uses a canvas that directly draws into a windows device context. Running the script with Python2.6 (on Windows) and RDKit_Q12010_1 I get this output: c:\code>\python26\python test.py drawline (nan, nan, nan, nan) {'color': Color(1.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} stringBox ('HO', Font(10,0,0,0,'helvetica')) {} drawRect (nan, nan, nan, nan) {'edgeColor': Color(-1.00,-1.00,-1.00), 'edgeWidth': 0, 'fillColor': Color(1.00,1.00,1.00)} drawString HO (nan, nan) Font(10,0,0,0,'helvetica') Color(1.00,0.00,0.00) drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(1.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(1.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1} stringBox ('O', Font(10,0,0,0,'helvetica')) {} drawRect (nan, nan, nan, nan) {'edgeColor': Color(-1.00,-1.00,-1.00), 'edgeWidth': 0, 'fillColor': Color(1.00,1.00,1.00)} drawString O (nan, nan) Font(10,0,0,0,'helvetica') Color(1.00,0.00,0.00) drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,1.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (nan, nan, nan, nan) {'color': Color(0.00,0.00,1.00), 'width': 1, 'dash': None} stringBox ('HN', Font(10,0,0,0,'helvetica')) {} drawRect (nan, nan, nan, nan) {'edgeColor': Color(-1.00,-1.00,-1.00), 'edgeWidth': 0, 'fillColor': Color(1.00,1.00,1.00)} drawString HN (nan, nan) Font(10,0,0,0,'helvetica') Color(0.00,0.00,1.00) c:\code> Other examples work fine: c:\code>\python26\python test.py CN drawline (77.5, 100.0, 100.0, 100.0) {'color': Color(0.00,0.00,0.00), 'width': 1, 'dash': None} drawline (100.0, 100.0, 122.5, 100.0) {'color': Color(0.00,0.00,1.00), 'width': 1, 'dash': None} stringBox ('NH2', Font(12,0,0,0,'helvetica')) {} drawRect (120.5, 102.0, 124.5, 98.0) {'edgeColor': Color(-1.00,-1.00,-1.00), 'edgeWidth': 0, 'fillColor': Color(1.00,1.00,1.00)} drawString NH2 (120.5, 102.0) Font(12,0,0,0,'helvetica') Color(0.00,0.00,1.00) c:\code> Here is the test script: <snip> import sys from rdkit.Chem import AllChem def draw(canvas, mol, size=(300,300), kekulize=True, wedgeBonds=True, highlightAtoms=["N"]): if not mol: raise ValueError,'Null molecule provided' from rdkit.Chem.Draw import MolDrawing drawer = MolDrawing.MolDrawing(canvas) if kekulize: from rdkit import Chem mol = Chem.Mol(mol.ToBinary()) Chem.Kekulize(mol) if not mol.GetNumConformers(): from rdkit.Chem import AllChem AllChem.Compute2DCoords(mol) drawer.wedgeDashedBonds=wedgeBonds drawer.AddMol(mol,highlightAtoms=highlightAtoms) class Canvas(object): size = (200, 200) def drawLine(self, *args, **kw): print "drawline", args, kw def stringBox(self, *args, **kw): print "stringBox", args, kw return (5, 5) def drawRect(self, *args, **kw): print "drawRect", args, kw def drawString(self, text, x, y, font, color): print "drawString", text, (x, y), font, color if len(sys.argv) > 1: smiles = sys.argv[1] else: smiles = "OC(=O)[C@@H]1CCCN1" mol = AllChem.MolFromSmiles(smiles) draw(Canvas(), mol, size=(200, 200)) </snip> -- Thanks, Thomas ------------------------------------------------------------------------------ _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss