Skip to content

How to change (or remap) atom index (ordering) of a molecule after canonicalization? #5091

Answered by ptosco
qcxia20 asked this question in Q&A
Discussion options

You must be logged in to vote

@qcxia20 MolFromSmiles adds two private properties to the molecule it is called on, _smilesAtomOutputOrder and _smilesBondOutputOrder, which contain the original atom index before canonicalization. See below:

from rdkit import Chem
from rdkit.Chem.Draw import IPythonConsole

IPythonConsole.drawOptions.addAtomIndices = True

mol = Chem.MolFromSmiles("OC(COC1=C2C=CC=CC2=CC=C1)CNC(C)C")
mol

canonical_mol = Chem.MolFromSmiles(Chem.MolToSmiles(mol))
canonical_mol

list(mol.GetPropNames(includePrivate=True, includeComputed=True))
['__computedProps',
 'numArom',
 '_StereochemDone',
 '_smilesAtomOutputOrder',
 '_smilesBondOutputOrder']
list(map(int, mol.GetProp("_smilesAtomOutputOrder")[1:-2].…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@qcxia20
Comment options

@tsn2027
Comment options

@greglandrum
Comment options

Answer selected by qcxia20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants