Dear Greg,
Thank you! kekulize=False works as advertised! :)
I found UGM2012 IPython notebooks and one is on sanitization, so no need to
explain it..
Regards,
Samo
On Tue, Aug 20, 2013 at 5:25 AM, Greg Landrum <[email protected]>wrote:
> Dear Samo,
>
> On Mon, Aug 19, 2013 at 4:04 PM, Samo Turk <[email protected]> wrote:
>
>>
>> I was playing with ipython notebook and I get interesting error:
>>
>> from rdkit import Chem
>> from rdkit.Chem import Draw
>> from rdkit.Chem.Draw import IPythonConsole
>>
>> mol = Chem.MolFromSmarts('c1ccccc1')
>> mol
>>
>> <draws benzene>
>>
>> Draw.MolsToGridImage([mol])
>>
>> ---------------------------------------------------------------------------ValueError
>> Traceback (most recent call
>> last)<ipython-input-71-4f0b315d518e> in <module>()----> 1
>> Draw.MolsToGridImage([mol])
>> /usr/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.py in
>> MolsToGridImage(mols, molsPerRow, subImgSize, legends, **kwargs) 263
>> row = i//molsPerRow 264 col = i%molsPerRow--> 265
>> res.paste(MolToImage(mol,subImgSize,legend=legends[i],**kwargs),(col*subImgSize[0],row*subImgSize[1]))
>> 266 return res 267
>> /usr/lib/python2.7/site-packages/rdkit/Chem/Draw/__init__.py in
>> MolToImage(mol, size, kekulize, wedgeBonds, **kwargs) 70 from rdkit
>> import Chem 71 mol = Chem.Mol(mol.ToBinary())---> 72
>> Chem.Kekulize(mol) 73 74 if not mol.GetNumConformers():
>> ValueError: Sanitization error: Can't kekulize mol
>>
>>
>> It works normally on aliphatic structures or if I use MolFromSmiles instead
>> of MolFromSmarts. Is kekulization of mols obtained from SMARTS wanted
>> behaviour? Is it possible to turn it off?
>>
>> Very short answer: use Draw.MolsToGridImage([mol],kekulize=False)
>
> A bit of explanation:
>
> The drawing code, by default, tries to kekulize the molecule so that
> drawings of aromatic systems look better. This fails for molecules
> constructed from SMARTS unless you do partial sanitization of those
> molecules (I can explain this if you're interested, but it would be a
> distraction here).
>
> The ipython notebook integration code tries to kekulize the molecule; if
> that fails, it renders the non-kekulized structure.
>
> I hope this helps,
> -greg
>
>
>
>
------------------------------------------------------------------------------
Introducing Performance Central, a new site from SourceForge and
AppDynamics. Performance Central is your source for news, insights,
analysis and resources for efficient Application Performance Management.
Visit us today!
http://pubads.g.doubleclick.net/gampad/clk?id=48897511&iu=/4140/ostg.clktrk
_______________________________________________
Rdkit-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/rdkit-discuss