liveBook · Manning

RDKit

As explained in Build AI Drug Discovery Pipelines

RDKit is an open-source cheminformatics toolkit for representing, manipulating, visualizing, and analyzing chemical structures.

RDKit is an open-source cheminformatics toolkit for representing, manipulating, visualizing, and analyzing chemical structures. Its molecule objects store atoms, bonds, connectivity, and attributes such as atom type and formal charge, while its Python modules support chemical workflows and machine-learning integration. section 1.2.3

A practical RDKit workflow can include:

  • Reading and writing molecules with rdkit.Chem. section 1.2.3
  • Using AllChem for advanced chemical operations, Draw for visualization, and PandasTools for molecule columns in Pandas dataframes. section 1.2.3
  • Converting molecules into numerical fingerprints for biological-activity prediction, toxicity assessment, compound prioritization, or optimization. section 1.2.3

Inspecting and visualizing caffeine

Chem.MolFromSmiles converts a caffeine SMILES string into a molecule object. The example counts 14 atoms and 15 bonds, then renders the molecule with Draw.MolsToGridImage. A larger workflow adds RDKit molecule columns to FDA-approved-drug data, generates ECFP6 fingerprints, reduces them with PCA, and applies logistic regression to classify USAN stems such as -cillin and -olol. section 1.2.3 section 1.2.3

Listing 1.1 Basic RDKit Functionality
from rdkit import Chem
from rdkit.Chem import (
    AllChem, Descriptors, Draw, PandasTools,
)
 
smiles_string = "CN1C=NC2=C1C(=O)N(C(=O)N2C)C"    #A
mol = Chem.MolFromSmiles(smiles_string)    #B
 
print("Number of atoms:", mol.GetNumAtoms())    #C
# Output -> Number of atoms: 14
print("Number of bonds:", mol.GetNumBonds())
# Output -> Number of bonds: 15
 
mol    #D
 
img = Draw.MolsToGridImage(    #E
    mols=[mol], molsPerRow=1, useSVG=True, drawOptions=dopts,
)
with open("figures/ch01/caffeine.svg", "w") as f:
  f.write(img.data)
 

Use the runnable listing to inspect imports, parse a SMILES string, count molecular components, and generate a grid image. section 1.2.3

How Build AI Drug Discovery Pipelines covers it

How deep it goes
Explains molecule objects, core modules, and an end-to-end preview, while deferring detailed treatment of each tool.
Examples
Uses caffeine parsing, molecular visualization, FDA-approved-drug fingerprints, PCA chemical-space exploration, and USAN-stem classification.
What you can do after
Apply it via Python to convert chemical structures into analyzable objects, visualizations, and machine-learning features.
How it connects
Connects cheminformatics with molecular representation, fingerprints, Pandas, PCA, logistic regression, and Scikit-Learn.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build AI Drug Discovery Pipelines. The section links point to the parts of the book it draws on.