Visualize Crippen Atom Contribution

Yesterday, I wrote that I was interested in “calcAtomGaussians”.
So, I wrote simple script to visualize molecular image with atomic contribution about logP.
In this script, query “name” is converted to smiles strings using chemspipy module, at first.
Then the smiles are converted to mol-object of RDKit.
****
The chemspipy require a security token; to obtain a token. So, if interested in chemspipy, you need complete the registration process.

URLs are here.
http://www.chemspider.com/
https://github.com/mcs07/ChemSpiPy
****

The code is ….

# chemspi_view_crippen.py
import sys, chemspipy
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem import Crippen
import matplotlib
from matplotlib import cm

query = sys.argv[ 1 ]
c = chemspipy.find_one( query )
smi = c.smiles

mol = Chem.MolFromSmiles( smi )
fig=Draw.MolToMPL(mol)
contribs = Crippen.rdMolDescriptors._CalcCrippenContribs( mol )
logps, mrs = zip( *contribs )
x,y,z=Draw.calcAtomGaussians(mol,0.03,step=0.01,weights=logps)
fig.axes[0].imshow(z,cmap=cm.jet,interpolation='bilinear',origin='lower',extent=(0,1,0,1))
fig.axes[0].contour(x,y,z,20,colors='k',alpha=0.5)
fig.savefig('%s.png'%query,bbox_inches='tight')

_CalcCrippenContribs returns logps and MRs each atoms in molecule.
x,y mean atom map and z means logps.
Using these data, matplotlib module makes contour.
Let’s run scirpt.

lion$ python chemspi_view_crippen.py tofacitinib

Now I got following image.
tofacitinib

I think RDKit is masterpiece of chemoinformatics . 😉

More details are …
http://www.rdkit.org/docs/api/index.html

Advertisements

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 )

Google+ photo

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

Connecting to %s