RDKit GenerateDepictionMatching2DStructure(m, s) - Substructure Orientation

This section provides a tutorial example on how to draw multiple molecules with the same orientation as a common substructure.

If a substructure is found in multiple molecules, you may want them to be display in the same orientation as the substructure.

This can be done using the AllChem.GenerateDepictionMatching2DStructure(m, s) method as shown below: in a Jupyter Notebook:

from rdkit import Chem
l = ['O=C(O)c2cc1ccc(Cl)n1cn2', 'c1ccc2c(c1)ncn3cccc23',
    'c1ccc3c(c1)cc2ccncn23']
ms = []
for i in l:
    m = Chem.MolFromSmiles(i)
    ms.append(m)

from rdkit.Chem import Draw
Draw.MolsToGridImage(ms)

from rdkit.Chem import AllChem
s = Chem.MolFromSmiles('c1nccc2n1ccc2')
AllChem.Compute2DCoords(s)
for m in ms:
    AllChem.GenerateDepictionMatching2DStructure(m, s)
Draw.MolsToGridImage(ms)
RDKit GenerateDepictionMatching2DStructure(m, s) - Substructure Orientation
RDKit GenerateDepictionMatching2DStructure(m, s) - Substructure Orientation

As you can see from the output, molecules in the bottom images all have the same orientation as the substructure.

By the way, rdkit.Chem.Draw.MolsToGridImage(ms) allows you to draw multiple molecules in a single image.

Table of Contents

 About This Book

 SMILES (Simplified Molecular-Input Line-Entry System)

 Open Babel: The Open Source Chemistry Toolbox

 Using Open Babel Command: "obabel"

 Generating SVG Pictures with Open Babel

 Substructure Search with Open Babel

 Similarity Search with Open Babel

 Fingerprint Index for Fastsearch with Open Babel

 Stereochemistry with Open Babel

 Command Line Tools Provided by Open Babel

 RDKit: Open-Source Cheminformatics Software

 rdkit.Chem.rdchem - The Core Module

 rdkit.Chem.rdmolfiles - Molecular File Module

 rdkit.Chem.rdDepictor - Compute 2D Coordinates

 rdkit.Chem.Draw - Handle Molecule Images

Molecule Substructure Search with RDKit

 RDKit m.HasSubstructMatch(s) - Substructure Match

RDKit GenerateDepictionMatching2DStructure(m, s) - Substructure Orientation

 RDKit rdMolDraw2D.PrepareAndDrawMolecule - Substructure Highlight

 RDKit Substructure Search with SMARTS

 rdkit.Chem.rdFMCS - Maximum Common Substructure

 rdkit.Chem.rdSubstructLibrary - Substructure Library

 Substructure Library in Binary and SMILES Formats

 rdkit.Chem.rdmolops - Molecule Operations

 Daylight Fingerprint Generator in RDKit

 Morgan Fingerprint Generator in RDKit

 RDKit Performance on Substructure Search

 Introduction to Molecular Fingerprints

 OCSR (Optical Chemical Structure Recognition)

 AlphaFold - Protein Structure Prediction

 Resources and Tools

 Cheminformatics Related Terminologies

 References

 Full Version in PDF/EPUB