Skip to course content
Learn CADD

Module 5: Cheminformatics & Molecular Representations

Understand how computers represent, process, and analyze chemical molecules. Master connection tables, line notations (SMILES/SMARTS), molecular descriptors, and structural fingerprint similarity.


1. Computers vs. Chemists: The Structural Challenge

Molecules are dynamic quantum-mechanical objects. Representing them computationally requires approximations across different dimensional spaces. Modern chemical AI models organize these representations into three primary families:

Discrete Representations

Express structures as distinct symbolic units. Includes molecular graphs (atoms and bonds), 1D text strings (SMILES, SELFIES), and binary bit vectors. They are human-interpretable and highly traceable.

Continuous Representations

Express chemical features as real-valued vectors or spatial functions (like Cartesian coordinate arrays or learned neural embeddings from GNNs). Essential for gradient-based deep learning.

Hybrid Architectures (LLMs)

Large Language Models that tokenize discrete chemical notations into continuous embeddings, perform reasoning in latent spaces, and decode them back to discrete structures.

2. Standard Representations: SMILES, SELFIES, SMARTS, & SDF

Several formats serve as standard representations for transferring structural files between databases (like ChEMBL or PubChem) and computational docking algorithms:

SMILES Notation

A line notation language storing structural topology in ASCII strings. Atoms are elements, branching is enclosed in parentheses (), and ring closure coordinates are designated by digits.

SELFIES Notation

A self-referencing line notation built for machine learning. Unlike SMILES, where random mutations yield invalid chemistry, SELFIES grammar guarantees that 100% of generated strings translate to syntactically valid molecules.

SMARTS Substructures

An extension of SMILES for specifying patterns to filter molecules. It permits expressions like wildcards, aromatic checks, and coordinate counts to identify toxicophores or functional cores.

SMIRKS Reactions

A line notation for chemical transformations. Whereas SMILES represents molecules and SMARTS represents queries, SMIRKS represents *reactions* (e.g. [C:1](=[O:2])[O:3] >> [C:1](=[O:2])[Cl:4]), mapping reactant atoms to products via indexes.

SDF/MOL Tables

Files that record explicit 3D spatial coordinate blocks (x, y, z) and connection arrays matching each atom index to specify atomic types, charges, and formal bond topologies.

InChI & InChIKey: The Universal Chemical Identifier

InChI (International Chemical Identifier)

A machine-readable canonical string developed by IUPAC and NIST. Unlike SMILES, which can have multiple valid representations for the same molecule, InChI provides a single unique canonical representation. It uses a layered format encoding: formula, connectivity, hydrogen, charge, and stereochemistry.

Caffeine InChIInChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3

InChIKey

A fixed-length 27-character hash derived from an InChI string. Its format follows the pattern XXXXXXXXXXXXXX-YYYYYYYYYY-Z (14 characters encoding connectivity, 10 characters for other layers, and 1 version character). InChIKey enables exact-match database searching across ChEMBL, PubChem, and other chemical databases.

Caffeine InChIKeyRYYVLZVUVIJVGH-UHFFFAOYSA-N

Why InChIKey Matters for QSAR

During data curation, InChIKey serves as the unique compound identifier for deduplication. Two molecules with different SMILES strings but identical InChIKeys are the same compound; this is critical for removing duplicates before training machine learning models.

How it works:
  • Chem.MolFromSmiles: Parses a 1D SMILES string to reconstruct a molecular graph database entry.
  • Chem.MolToInchi: IUPAC NIST converter that generates a canonical, layered string representation of structural layers.
  • inchi.InchiToInchiKey: Generates a fixed-length 27-character hash, ideal for rapid database indexing and deduplication.
InChI & InChIKey Generation Script

The Isomerism Landscape

Isomers share a molecular formula but differ in some other way — and almost every kind changes biological activity. R/S chirality is only one branch of the tree. The split that matters most for a cheminformatician is whether the connectivity changes (a different graph) or only the spatial arrangement does (the same graph).

Constitutional (Structural) Isomers — different connectivity

The atoms are bonded together in a different order, so the molecular graph itself differs. These are trivially distinguished by any 2D representation — different SMILES, different fingerprints, different everything.

  • Chain / skeletal: butane CCCC vs isobutane CC(C)C.
  • Positional (regioisomers): where a substituent sits on a ring. Ibuprofen is the para isomer CC(C)Cc1ccc(...)cc1; the meta isomer is a different, inactive compound.
  • Functional group: ethanol CCO vs dimethyl ether COC — same C₂H₆O, entirely different chemistry.
  • Tautomers: a special case that interconverts rapidly (keto ⇌ enol). See tautomer canonicalization in the curation section below.
Stereoisomers — same connectivity, different 3D arrangement

The graph is identical; only the spatial arrangement differs. These are the dangerous ones computationally — a naive 2D pipeline cannot see them at all.

  • Enantiomers (R/S): non-superimposable mirror images. One eutomer fits the pocket; the distomer may be inactive or toxic (thalidomide).
  • Diastereomers: stereoisomers that are not mirror images (≥2 stereocentres, differing at some but not all). Ephedrine vs pseudoephedrine — different compounds, different pharmacology.
  • Geometric (cis/trans, E/Z): restricted rotation about a C=C or ring. Only (Z)-tamoxifen is the active antiestrogen; (E)-diethylstilbestrol (Module 5) is the active estrogen.
  • Atropisomers: axial chirality from hindered rotation about a single bond (biaryls) — now a formal regulatory concern in kinase-inhibitor programmes.
  • Conformers (rotamers): interconvert by free rotation, so not separable compounds — but the bioactive conformation is what the receptor sees (Module 5).
Isomer typeHow SMILES encodes itExample
ConstitutionalDifferent atom/bond ordering — a different string entirelyCCO vs COC
Enantiomer / diastereomerTetrahedral tags @ / @@C[C@H](N)C(=O)O
Geometric (E/Z)Directional bonds / and \F/C=C/F (E) vs F/C=C\F (Z)
AtropisomerNot captured by default — needs explicit axial stereo or 3D coordinates(3D required)
ConformerNever encoded — SMILES is a 2D topology, not a geometry(conformer search)
Critical: standard fingerprints are stereo-blind

ECFP4/Morgan fingerprints encode topology only. By default, two enantiomers hash to the identical bit vector — a Tanimoto of 1.00 — so a QSAR model literally cannot tell the eutomer from the distomer. Passing useChirality=True drops that pair to ≈0.71and lets the model separate them. Constitutional isomers, by contrast, are always distinguishable because the graph differs. If your endpoint depends on stereochemistry, a default 2D fingerprint will silently cap your model's accuracy.

Detecting Every Isomer Type in RDKit

Chirality & Stereoisomer Curation

Zooming in on the branch that causes the most trouble in practice: molecules with identical atomic connectivity can exhibit different three-dimensional arrangements called stereoisomers. Chirality is a key driver of biological activity; often, only one enantiomer fits the receptor pocket (the active "eutomer"), while the other is inactive or toxic (the "distomer").

Handling Undefined Stereochemistry

When curating chemical libraries from databases, compounds are sometimes represented with undefined chiral centers (lacking wedge/dash bonds). Computational workflows must identify these centers and enumerate all possible physical stereoisomers to avoid screening incomplete chemical spaces.

Programmatic Enumeration in RDKit

RDKit provides the EnumerateStereoisomers module. It analyzes the tetrahedral carbon centers in a molecular graph and builds a collection of distinct conformers representing every possible combination of R and S configurations.

Programmatic Enumeration Example:
  • EnumerateStereoisomers: Finds all stereocenters and generates a generator yielding all combinations of stereochemical configurations.
  • StereoEnumerationOptions: Allows constraints on the maximum number of generated stereoisomers (e.g. maxIsomers=32) to prevent exponential explosion for complex compounds.
Stereoisomer Enumeration Script

Interactive Playground: Chemical Graph & Tanimoto Similarity

Select structural templates to project their graphs and generated fingerprints. Click any atom in Molecule A to explore how circular ECFP neighborhoods are hashed at increasing radii.

Molecule A: Graph Explorer
SMILES: NCCc1ccc(O)c(O)c1
CCCCCCOOCCN
Circular Neighborhood (ECFP)Click any atom above to explore
Molecule B: Similarity Compare
Tanimoto Coefficient (Tc)
0.773

High fingerprint similarity: many encoded features are shared, but target activity still requires experimental evidence.

Bit intersection17 bits
Bit union22 bits
Fingerprint Bits Grid (32-bit illustration)Union overlaps highlighted
Dopamine FP:
1
0
1
1
0
1
0
0
1
1
0
1
1
0
0
1
0
1
0
1
1
0
0
1
0
1
1
0
1
0
0
1
Adrenaline FP:
1
0
1
1
1
1
0
1
1
1
0
1
1
0
1
1
0
1
0
1
1
1
0
1
0
1
1
0
1
0
1
1

*Tanimoto Coefficient formula: Tc(A, B) = |A ∩ B| / |A ∪ B| = N_ab / (N_a + N_b - N_ab), where N_ab is the number of bits set in both fingerprints, and N_a and N_b are the numbers of bits set in molecules A and B individually. There is no universal similarity cutoff: a value is meaningful only with the fingerprint definition, dataset, molecular sizes, and retrieval objective used to derive it.

3. Predefined vs. Topological Fingerprints

While basic 1D descriptors capture simple properties (like logP or molecular weight), advanced machine learning relies on molecular fingerprints to encode spatial networks:

A

Predefined Fragments (MACCS Keys)

MACCS (Molecular ACCess System) uses a dictionary of 166 pre-calculated structural fragments (e.g. "Is there an aromatic oxygen?" and "Is there a ring of size 5?"). Each bit index corresponds to a specific question, resulting in a 166-bit binary fingerprint. Highly interpretable but limited to predefined structures.

B

Extended Connectivity Fingerprints (ECFPs)

Topological or circular fingerprints. ECFP doesn't use a dictionary. Instead, it systematically identifies every atom in a molecule and lists its neighbors at increasing radii (e.g. radius 2, matching a diameter of 4 for ECFP4). The resulting substructures are hashed into integers, which are mapped onto a fixed-size bit array (typically 1024 or 2048 bits).

C

Atom-Pair & Topological-Torsion Fingerprints

Older but still useful path-based descriptors. An atom pair encodes (atom type — topological distance — atom type) for every pair of atoms in the molecule; a topological torsion encodes a 4-atom chain (type–type–type–type). Each atom type is itself a small tuple: element, number of heavy-atom neighbors, and number of π electrons. Being global (whole-molecule) rather than local (per-atom neighborhood) like ECFP, they capture long-range shape that circular fingerprints can miss.

D

2D Pharmacophore Fingerprints

Bridges cheminformatics and Module 7's pharmacophore modeling directly: each atom is first tagged with a pharmacophoric role (Donor, Acceptor, Aromatic, Hydrophobe, PosIonizable, NegIonizable), then every pair of features is encoded as (feature — topological distance bin — feature), e.g. binning distances into (2–3), (3–4), (4–5) bonds. Two molecules with completely different scaffolds but the same pharmacophore-pair pattern will score highly similar — the fingerprint-level analogue of scaffold hopping.

A Third Axis: Feature-Class (FCFP-style) Morgan Fingerprints

ECFP hashes each atom by its raw connectivity (element, degree, charge, ring membership). A feature-class variant (FCFP) instead hashes atoms by their pharmacophoric class — the same six roles used above — so that, for example, any halogen counts as interchangeable with any other halogen. This makes FCFP-style fingerprints better at finding functionally similar but chemically distinct scaffolds, at the cost of losing exact-structure resolution.

Why Fingerprints Also Power Fast Substructure Search

Beyond similarity, fingerprints act as a cheap pre-filter for exact substructure matching in million-compound databases: if molecule B is a substructure of molecule A, then every bit set in FP(B) must also be set in FP(A). A database engine can discard any candidate that fails this bit-containment test in microseconds, calling the slow, NP-complete subgraph-isomorphism algorithm only on the small surviving set — turning an intractable full-database scan into a practical query.

4. The Tanimoto Coefficient: Defining Chemical Similarity

In virtual database screening, we compare candidate molecules to a known active reference molecule to identify biological hits. The standard metric to quantify structural similarity is the Tanimoto Coefficient (Tc):

Tanimoto Coefficient Equation:
Tc = N_c / (N_a + N_b - N_c)
Where N_c is the number of common active bits (intersection) shared between both, and N_a and N_b are the total active bits in molecules A and B respectively. The coefficient ranges from 0.0 (no overlap) to 1.0 (identical bit vectors).

Tanimoto is actually one special case of a more general family, the Tversky Index, which weights the two molecules asymmetrically:

Tversky Index (general form):
Tversky(A, B, α, β) = N_c / (α·N_a + β·N_b + (1 − α − β)·N_c)
Setting α = β = 1 recovers the Tanimoto coefficient above. Setting α = β = 0.5 recovers the Dice coefficient, 2·N_c / (N_a + N_b), which weights the intersection more heavily and is common in target-fishing pipelines. Because it can be tuned asymmetrically, Tversky is especially useful when comparing a small query fragment against large full molecules, where a symmetric metric like Tanimoto unfairly penalizes the size difference.

5. Matched Molecular Pairs, Activity Cliffs & Bioisosteres

Whole-molecule similarity is useful for retrieval, but medicinal chemistry often asks a more local question: what changed when one defined structural transformation was made within an otherwise comparable series?

Matched molecular pair (MMP)

An MMP differs by one localized transformation, such as H → F or ester → amide. Repeated examples can reveal context-dependent effects on potency, solubility, clearance, or permeability.

Activity cliff

Two highly similar compounds can have a large activity difference. Confirm assay, stereochemistry, protonation, and measurement quality before treating the cliff as a binding-site insight or model failure.

Bioisosteric replacement

Replace a group with another that can preserve key geometry or interactions while changing pKa, logD, metabolic stability, or permeability. Bioisosteres are design hypotheses, not guaranteed equivalents.

6. Chemical Data Curation & Standardisation Pipeline

In public bioactivity databases (e.g. ChEMBL, PubChem), molecules are uploaded as raw SMILES representing diverse experimental settings. They often contain counterions (salts), solvent molecules, incorrect formal charges, and mismatching tautomeric forms. If used directly in machine learning, these artifacts degrade prediction accuracy.

To prepare a clean chemical library, computational chemists apply a multi-step RDKit standardization pipeline:

The 5-Step Curation Protocol

  1. Exclusion & Filtering:Remove invalid structures, strip molecules lacking carbon atoms, exclude heavy compounds (MW ≥ 1500 Da), and reject mixtures (mixtures containing more than 4-5 carbon fragments).
  2. Salt and Solvent Stripping: Isolate the active parent compound by removing counterions (like Na+, Cl-) and solvent adducts. In RDKit, this is performed using rdMolStandardize.FragmentParent.
  3. Charge Neutralization: Convert charge states to neutral equivalents (e.g. carboxylates to carboxylic acids, protonated amines to neutral amines) using rdMolStandardize.Uncharger.
  4. Isotope & Stereo Standardization: Remove isotopic labels (converting Carbon-13 to Carbon-12) to group chemical duplicates, and standardize stereochemical representations.
  5. Tautomer Canonicalization: Resolve different tautomers (e.g., keto-enol tautomerism) by enumerating and selecting a single, consistent canonical representation using rdMolStandardize.TautomerEnumerator().Canonicalize.

Here is a standard Python script block using RDKit to implement this pipeline on a raw SMILES string:

RDKit Standardization Pipeline

Advanced: Practical Cheminformatics with RDKit

RDKit is the industry-standard library for cheminformatics in Python. Beyond chemical standardization, it provides robust APIs for multi-format file operations, 3D conformer generation, and chemical reaction processing.

1. Reading & Writing Molecules

RDKit reads and writes structures across SMILES, SDF, MOL, and InChI formats. Use SDWriter to export libraries with their computed properties preserved.

2. 3D Conformer Generation

Molecules are 3D entities. RDKit uses the ETKDG method (Experimental-Torsion Knowledge Distance Geometry) to generate physically realistic 3D conformer ensembles.

3. Reaction Handling

Virtual libraries are built using chemical reactions. By applying SMARTS-based reaction transformations (e.g. amide coupling), RDKit automatically generates products from reactants.

Here is a comprehensive script demonstrating these four core operations in RDKit:

Deep Dive into the Script Operations:
  • Chem.SDWriter: Creates an SDF (Structure Data File) output stream to store coordinates alongside custom chemical annotations.
  • Chem.AddHs & EmbedMultipleConfs: Hydrogens must be added to build correct 3D geometries. The ETKDG algorithm places atoms based on experimental torsion databases.
  • AllChem.MMFFOptimizeMolecule: Uses the Merck Molecular Force Field (MMFF94) to optimize bond angles, lengths, and steric clashes.
  • AllChem.ReactionFromSmarts: Applies organic reaction maps where reactants match substructure queries to generate valid product graphs.
  • Recap & BRICS: Cleaves molecules along common synthetic bonds (like esters or amides) to generate fragment building blocks for retrosynthetic design.
Advanced RDKit Cheminformatics Script

Self-Assessment ChallengeQuestion 1 of 3

Why is tautomer canonicalization critical before generating ECFP4 fingerprints for machine learning models?