$npx -y skills add GPTomics/bioSkills --skill molecular-standardizationStandardizes molecular structures using the ChEMBL structure pipeline for normalization and parent selection plus RDKit rdMolStandardize for explicit custom steps such as tautomer canonicalization, salt/solvent stripping, charge handling, stereochemistry handling, mixture selecti
| 1 | ## Version Compatibility |
| 2 | |
| 3 | Reference examples tested with: RDKit 2024.09+ and chembl_structure_pipeline 1.2+. MolVS 0.1.1 is a legacy package; use RDKit's maintained `rdMolStandardize` module for custom pipelines. |
| 4 | |
| 5 | Before using code patterns, verify installed versions match. If versions differ: |
| 6 | - Python: `pip show <package>` then `help(module.function)` to check signatures |
| 7 | |
| 8 | If code throws ImportError, AttributeError, or TypeError, introspect the installed |
| 9 | package and adapt the example to match the actual API rather than retrying. |
| 10 | |
| 11 | # Molecular Standardization |
| 12 | |
| 13 | Convert raw molecular structures into a consistent form for ML training data, deduplication, registry, and cross-database joining. Skipping standardization can create data leakage when alternate representations of one compound enter different splits, distort QSAR inputs, and cause database join misses. The ChEMBL structure pipeline (Bento et al. 2020) is built on RDKit and applies ChEMBL-specific normalization and parent-selection rules. canSARchem (Dolciami et al. 2022) adds canonical-tautomer selection before parent extraction. RDKit's maintained `rdMolStandardize` module provides primitives for building an explicit custom pipeline. |
| 14 | |
| 15 | For format-level I/O and aromaticity perception, see `chemoinformatics/molecular-io`. For descriptor calculation after standardization, see `chemoinformatics/molecular-descriptors`. |
| 16 | |
| 17 | ## Standardization Pipeline Stages |
| 18 | |
| 19 | | Stage | RDKit Tool | Operation | Common errors caught | |
| 20 | |-------|-----------|-----------|----------------------| |
| 21 | | 1. Sanitization | `Chem.SanitizeMol` | Kekulize, assign aromaticity, fix valences | Wrong valence on N/O | |
| 22 | | 2. Salt stripping | `rdMolStandardize.FragmentRemover` or `LargestFragmentChooser` | Remove counterions | Cl-, Na+, K+, OH- | |
| 23 | | 3. Mixture choice | `LargestFragmentChooser` | Pick parent fragment | Co-crystals, hydrates | |
| 24 | | 4. Charge neutralization | `Uncharger` | Neutralize while preserving net charge | Permanent charges preserved (quaternary N+) | |
| 25 | | 5. Tautomer canonicalization | `TautomerEnumerator.Canonicalize` | Pick canonical tautomer | Keto/enol; amide/imidate | |
| 26 | | 6. Stereo standardization | `Chem.AssignStereochemistry` | Consistent stereo descriptors | Lost wedges, ambiguous R/S | |
| 27 | | 7. Isotope normalization | Explicitly set selected atom isotope labels to 0 | Remove 13C, 2H labels | Tracer studies; preserve labels when scientifically meaningful | |
| 28 | | 8. Output canonicalization | `Chem.MolToSmiles(canonical=True)` | Canonical SMILES + InChIKey | Round-trip stability | |
| 29 | |
| 30 | ## Pipeline Reconciliation |
| 31 | |
| 32 | | Pipeline | Origin | Tautomer canonicalization | Salt definition | Use case | |
| 33 | |----------|--------|---------------------------|-----------------|----------| |
| 34 | | ChEMBL pipeline | EBI ChEMBL | Not performed by `standardize_mol` or `get_parent_mol` | ChEMBL salt list (extensive) | ChEMBL-compatible registration | |
| 35 | | canSARchem | ICR Cancer Research UK | Canonical tautomer BEFORE parent extraction | Extended salt list | Cancer drug discovery | |
| 36 | | PubChem (OpenEye) | NIH NCBI | OpenEye QUACPAC tautomer | PubChem salt list | Bioassay data, large-scale | |
| 37 | | RDKit rdMolStandardize default | Greg Landrum | RDKit TautomerEnumerator | RDKit default | General purpose, open source | |
| 38 | |
| 39 | **Key difference (canSARchem vs ChEMBL):** |
| 40 | - ChEMBL standardizes the representation and extracts a parent, but does not canonicalize tautomers. |
| 41 | - canSARchem canonicalizes the tautomer before parent extraction. |
| 42 | |
| 43 | This difference matters when alternate tautomeric inputs must be registered as one parent. Do not describe ChEMBL output as tautomer-canonical unless an explicit tautomer step is added and documented. |
| 44 | |
| 45 | ## ChEMBL Structure Pipeline (Reference Implementation) |
| 46 | |
| 47 | ChEMBL's standardization is the most widely-used reference. The Python package `chembl_structure_pipeline` exposes the validated pipeline. |
| 48 | |
| 49 | **Goal:** Apply the industry-reference ChEMBL standardization pipeline to a SMILES. |
| 50 | |
| 51 | **Approach:** Parse SMILES with RDKit, run `standardize_mol` (sanitize, normalize, and standardize charges), then `get_parent_mol` (strip salts/counter-ions), and emit canonical SMILES. Add `rdMolStandardize.TautomerEnumerator` separately only when the project requires tautomer canonicalization. |
| 52 | |
| 53 | ```python |
| 54 | from chembl_structure_pipeline import standardize_mol, get_parent_mol |
| 55 | from rdkit import Chem |
| 56 | |
| 57 | def ch |