Chemical Identity, Search and Molecular Features
RDKit Cheminformatics
Identify molecules, search by substructure and similarity, and transform atomic and molecular information into tabular features for data analysis.
- Role
- Chemical information processing
- Typical input
- SMILES, SDF, MOL, CSV
- Typical output
- InChIKey, fingerprints, descriptors, SVG
1. Workflow
A typical cheminformatics workflow is read -> sanitize -> standardize -> identify -> featurize -> search/model. Decide first whether salts, isotopes, stereoisomers, tautomers, and protonation states count as the same compound.
Salt handling, stereochemistry, isotopes, tautomers, protonation states, and mixtures determine duplicate detection and must be fixed before modeling.
2. SMILES, InChI, and InChIKey
| Representation | Role |
|---|---|
| Canonical SMILES | Toolkit-canonicalized graph string |
| Isomeric SMILES | SMILES retaining specified isotope and stereochemical information |
| Standard InChI | Layered standardized identifier |
| InChIKey | Fixed-length, irreversible hash for lookup |
from rdkit import Chem
from rdkit.Chem import inchi
mol = Chem.MolFromSmiles("C[C@H](O)C(=O)O")
smiles = Chem.MolToSmiles(mol, isomericSmiles=True)
inchi_text = inchi.MolToInchi(mol)
inchi_key = inchi.InchiToInchiKey(inchi_text)Canonical SMILES may depend on toolkit and version. InChIKey is convenient for indexing but is irreversible; retain the standardized structure and full InChI alongside it.
3. Structure standardization
Standardization applies project-specific rules; it does not discover a uniquely correct structure. Cleanup, fragment selection, uncharging, and tautomer canonicalization can remove information relevant to measured salt forms or pH conditions.
from rdkit.Chem.MolStandardize import rdMolStandardize
clean = rdMolStandardize.Cleanup(raw_mol)
parent = rdMolStandardize.FragmentParent(clean)
neutral = rdMolStandardize.Uncharger().uncharge(parent)Fragment removal or uncharging can disconnect the representation from a measurement performed on a salt or at a specified pH. Preserve the source structure and every transformation.
4. Descriptors and Gasteiger charges
Molecular weight, LogP, TPSA, hydrogen-bond counts, rotatable bonds, and rings compress graph information into scalar descriptors. Gasteiger charges are fast empirical partial charges and are not interchangeable with Mulliken, NPA, or Hirshfeld populations.
from rdkit.Chem import AllChem, Descriptors
AllChem.ComputeGasteigerCharges(mol)
charges = [a.GetDoubleProp("_GasteigerCharge") for a in mol.GetAtoms()]
features = {"MolWt": Descriptors.MolWt(mol),
"LogP": Descriptors.MolLogP(mol),
"TPSA": Descriptors.TPSA(mol)}Check for failed charge calculation, nonfinite values, and method-specific parameter limits. Store atom indices when atom-level values will later be mapped onto a drawing or a three-dimensional structure.
5. Fingerprints and similarity
Morgan, RDKit topological, and MACCS fingerprints encode different structural features. For bit vectors, Tanimoto similarity is
from rdkit import DataStructs
from rdkit.Chem import rdFingerprintGenerator
gen = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)
fps = [gen.GetFingerprint(m) for m in mols]
sim = DataStructs.TanimotoSimilarity(fps[0], fps[1])Similarity values are meaningful only together with fingerprint type, radius, size, and feature settings.
6. SMARTS substructure searching
SMARTS represents a query rather than one molecule. Specify aromaticity, formal charge, valence, hydrogen, ring, and stereochemical constraints needed by the chemical question.
amide = Chem.MolFromSmarts("[NX3][CX3](=[OX1])")
matches = target.GetSubstructMatches(amide, useChirality=True)Validate each SMARTS query against positive and negative test structures. Short functional-group patterns often match more chemical environments than their informal name suggests.
7. Depiction and highlighting
Highlight matched atoms and bonds, align a common core across a molecular series, and include the color scale and sign when visualizing atomic contributions such as Gasteiger charges.
from rdkit.Chem.Draw import rdMolDraw2D
hit_atoms = list(target.GetSubstructMatch(amide))
drawer = rdMolDraw2D.MolDraw2DSVG(420, 280)
rdMolDraw2D.PrepareAndDrawMolecule(
drawer, target, highlightAtoms=hit_atoms
)
drawer.FinishDrawing()8. Dataset construction
- Retain source structures and identifiers.
- Record parse failures and mixtures.
- Generate standardized SMILES and InChIKeys.
- Fix descriptor definitions and RDKit version.
- Check missing, infinite, and near-constant features.
- Match structures to target units and measurement conditions.
- Consider scaffold or series splits in addition to random splits.
Continue to numerical and statistical analysis.
9. References
Last reviewed: August 4, 2026. Check the linked official documentation for syntax specific to the installed software version.