Draw molecule with atom index in RDKit

I found interesting topics in rdkit discuss. How to draw molecule with atom index.
Greg developer of RDKit answered tips to do it. It can use molAtomMapNumber.
https://sourceforge.net/p/rdkit/mailman/message/31663468/
I didn’t know that!
I tried that in my PC. RDKit can draw molecule easily using IPythonConsole.

from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
IPythonConsole.ipython_useSVG = True

def mol_with_atom_index( mol ):
    atoms = mol.GetNumAtoms()
    for idx in range( atoms ):
        mol.GetAtomWithIdx( idx ).SetProp( 'molAtomMapNumber', str( mol.GetAtomWithIdx( idx ).GetIdx() ) )
    return mol

Test in a kinase inhibitor

mol = Chem.MolFromSmiles( "C1CC2=C3C(=CC=C2)C(=CN3C1)[C@H]4[C@@H](C(=O)NC4=O)C5=CNC6=CC=CC=C65" )

Draw molecule.

#Default
mol
#With index
mol_with_atom_index(mol)

https://github.com/iwatobipen/chemo_info/blob/master/rdkit_notebook/drawmol_with%2Bidx.ipynb

screenshot
screenshot
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