In [1]:
from rdkit import Chem
from rdkit.Chem import Draw
from rdkit.Chem.Draw import IPythonConsole
IPythonConsole.ipython_useSVG = True
mol = Chem.MolFromSmiles("C1NCCC1")
atoms = mol.GetNumAtoms()
for idx in range( atoms ):
    mol.GetAtomWithIdx( idx ).SetProp( 'molAtomMapNumber', str(mol.GetAtomWithIdx( idx ).GetAtomicNum())  )
In [2]:
mol
Out[2]:
C:6 NH:7 C:6 C:6 C:6
In [5]:
mol = Chem.MolFromSmiles("C1NCCC1")
atoms = mol.GetNumAtoms()
for idx in range( atoms ):
    mol.GetAtomWithIdx( idx ).SetProp( 'molAtomMapNumber', str(mol.GetAtomWithIdx( idx ).GetIdx())  )
a = mol.GetAtomWithIdx(0)
In [6]:
mol
Out[6]:
C:0 NH:1 C:2 C:3 C:4
In [11]:
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
In [12]:
mol = Chem.MolFromSmiles( "C1CC2=C3C(=CC=C2)C(=CN3C1)[[email protected]]4[[email protected]@H](C(=O)NC4=O)C5=CNC6=CC=CC=C65" )
In [13]:
mol
Out[13]:
N O NH O NH
In [14]:
mol_with_atom_index(mol)
Out[14]:
C:0 C:1 C:2 C:3 C:4 C:5 C:6 C:7 C:8 C:9 N:10 C:11 C:12 C:13 C:14 O:15 NH:16 C:17 O:18 C:19 C:20 NH:21 C:22 C:23 C:24 C:25 C:26 C:27
In [ ]: