So I have a list of molecules. They all have a common substructure, but different substitution patterns.

For example, in the figure below, the leftmost molecule is the base, and the center and rightmost molecules are both a (1,4)-substituted variants of the base.

base molecule (left) and substituted variants (center/right)

Because the different substitution patterns result in a different numbering of the atoms, identifying the substitution locations is very difficult. Using the method mol.HasSubstructureMatch(some_substituition), I can find the location of the substitution, but since the base pattern keeps changing, this location is meaningless for my purposes (e.g. center molecule is (4,16)-substituted, and the rightmost molecule is (4,13)-substituted)

Is it possible to modify the substituted molecules such that the base substructure always has a consistent numbering pattern (e.g. make it so both molecules above are (4,12)-substituted)? Any ideas on how to systematically identify the substitution pattern would be greatly appreciated.


1 Answer 1


You can get the corresponding indices of the two structures with GenerateDepictionMatching2DStructure.

The code was made in a Jupyter notebook.

from rdkit import Chem
from rdkit.Chem import rdDepictor
from rdkit.Chem.Draw import IPythonConsole
IPythonConsole.molSize = (350, 350)
IPythonConsole.drawOptions.addAtomIndices = True

Compute the coordinates of the reference mol.

ref_mol = Chem.MolFromSmiles('O=C1c2ccccc2C(=O)c2ccccc12')

enter image description here

Now match the the target mol with the reference mol.

tar_mol = Chem.MolFromSmiles('CC(C)(C)c1cccc2C(=O)c3c(cccc3C(C)(C)C)C(=O)c12')
idx_pair = rdDepictor.GenerateDepictionMatching2DStructure(tar_mol, ref_mol)

enter image description here

After matching, you will get the pairs of corresponding indices. First value is from the reference.


((0, 10),
 (1, 9),
 (2, 8),
 (3, 7),
 (4, 6),
 (5, 5),
 (6, 4),
 (7, 23),
 (8, 21),
 (9, 22),
 (10, 12),
 (11, 13),
 (12, 14),
 (13, 15),
 (14, 16),
 (15, 11))

Lets find the substitutions.

patt = Chem.MolFromSmarts('cC(C)(C)C')
idx_tar = tar_mol.GetSubstructMatches(patt)

((4, 1, 0, 2, 3), (16, 17, 18, 19, 20))

enter image description here

And now you can get the corresponding indices for 4 and 16

for t in idx_tar:
    for p in idx_pair:
        if t[0] == p[1]:
            print('Substitute on:', p[0])

Substitute on: 6
Substitute on: 14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .