Draw molecule in RDKit

I really enjoyed OETK training.

Thanks a lot y_sama and organiser of the training.
And I told about rdkit with the TK specialist in break time.
TK specialist asked me that can RDKit draw molecule with highlight substructure.
I answered to him ‘yes… maybe…but I can’t show you example now…’.

Now I searched Web and found answer.
New version of RDKit can draw molecule as SVG.
Example is following.
I couldn’t view SVG image from web browser so, I uploaded picture.
And Snap shot is following picture.
Screen Shot 2015-08-05 at 11.20.31 PM

If following code run from IPython notebook, it will get SVG image of molecule.
rdDepictor function is cool ;-).

from __future__ import print_function
from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole
from IPython.display import SVG
from rdkit import rdBase
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import rdMolDraw2D
mol = Chem.MolFromSmiles( "CN1CCN(S(=O)(C2=CC=C(OCC)C(C3=NC4=C(N(C)N=C4CCC)C(N3)=O)=C2)=O)CC1" )
drawer = rdMolDraw2D.MolDraw2DSVG(400,200)
svg = drawer.GetDrawingText().replace('svg:','')

Now I’ll try to evaluate TK.

If reader interested in rdDepictor, I recommend check the blog!
His post is very cool and useful.


Published by iwatobipen

I'm medicinal chemist in mid size of pharmaceutical company. I love chemoinfo, cording, organic synthesis, my family.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: