Cheminformatics Tutorials - Herong's Tutorial Examples - v2.01, by Herong Yang
Drawing Diagrams with MolDraw2DCairo and MolDraw2DSVG
This section provides a tutorial example on how to use MolDraw2DCairo and MolDraw2DSVG classes to add custom diagram elements to molecule 2-D images.
Both rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DCairo and rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DSVG classes can be used to draw custom diagrams using drawing methods like DrawLine(), DrawRect(), DrawString(), etc.. Molecule 2-D structures can also be added.
Here is an example of drawing diagram with rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DCairo class in a Jupyter Notebook:
from rdkit.Chem.Draw import rdMolDraw2D from rdkit import Chem from rdkit.Geometry.rdGeometry import Point2D mol = Chem.MolFromSmiles('Cc1ccccc1') d = rdMolDraw2D.MolDraw2DCairo(300, 300) d.drawOptions().clearBackground = False; d.SetColour((0.8, 0.8, 0.8)) d.DrawRect(Point2D(120, 100), Point2D(220, 200)) d.SetColour((1, 0, 0)) d.DrawLine(Point2D(200, 160), Point2D(220, 240)) d.DrawMolecule(mol) d.FinishDrawing() p = d.GetDrawingText() import IPython.display IPython.display.Image(p)
Note that:
Table of Contents
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
What Is rdkit.Chem.Draw Module
MolToImage/MolToFile - Molecule PNG Image
rdkit.Chem.Draw.MolDrawing.DrawingOptions Class
rdkirdkit.Chem.Draw.rdMolDraw2D.MolDraw2DCairo - 2D Molecule Drawing
rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DCairo - Molecule PNG Image
rdkit.Chem.Draw.rdMolDraw2D.MolDraw2DSVG - Molecule SVG Image
rdkit.Chem.Draw.rdMolDraw2D.MolDrawOptions - Drawing Options
►Drawing Diagrams with MolDraw2DCairo and MolDraw2DSVG
Molecule Substructure Search with RDKit
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