$npx -y skills add GPTomics/bioSkills --skill molecular-descriptorsCalculates molecular fingerprints (ECFP/Morgan, FCFP, MACCS, RDKit, AtomPair, TopologicalTorsion, Avalon, MAP4, MHFP6) and physicochemical descriptors (Lipinski, QED, TPSA, Crippen LogP, 3D shape) with explicit choice tables, bit vs count semantics, and partial-charge model selec
| 1 | ## Version Compatibility |
| 2 | |
| 3 | Reference examples tested with: RDKit 2024.09+, numpy 1.26+, pandas 2.2+, map4 1.1+ (MAP4), mhfp 1.9+. Use `mapchiral` separately when the stereochemistry-aware MAP4C fingerprint is intended. |
| 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 Descriptors |
| 12 | |
| 13 | Featurize molecules for similarity search, QSAR, virtual screening, or ML. Fingerprint performance is **dataset- and objective-dependent**: ECFP4 is a strong drug-like baseline, atom-pair and topological-torsion fingerprints expose longer-range topology, MAP4/MHFP6 target broader chemical-space searches, and 3D conformer-based descriptors are needed when shape and stereochemistry matter. |
| 14 | |
| 15 | For canonicalization before featurization, see `chemoinformatics/molecular-standardization`. For 3D-only descriptors, see `chemoinformatics/conformer-generation`. |
| 16 | |
| 17 | ## Fingerprint Taxonomy |
| 18 | |
| 19 | | Fingerprint | Type | Radius/Path | Bits | Use case | Fails when | |
| 20 | |-------------|------|-------------|------|----------|------------| |
| 21 | | Morgan (ECFP) | Circular | r=2 (ECFP4), r=3 (ECFP6) | 2048 typical | Drug-like similarity, ML default | Loses long-range topology; bit collisions at low nBits | |
| 22 | | FCFP | Functional Morgan | r=2 default | 2048 | Pharmacophore-aware similarity | Same caveats as ECFP; less specific | |
| 23 | | MACCS | Substructure key | 166 fixed bits | 167 | Quick fingerprint, drug-likeness | Too sparse for large diverse libraries | |
| 24 | | RDKit FP | Path/subgraph-based | paths and branched subgraphs up to 7 bonds by default | 2048 | RDKit-native ECFP alternative | Drug-like only; not optimal for scaffold hopping | |
| 25 | | AtomPair | Pair + topological distance | All atom pairs | 2048 | Long-range topological similarity | Slower than ECFP; harder to interpret | |
| 26 | | TopologicalTorsion | 4-atom torsion | All TT | 2048 | Path-pattern similarity | Like AP, slower than ECFP | |
| 27 | | Avalon | Substructure + atom pairs | Mixed | 512/1024 | Fast similarity | Less standard; older | |
| 28 | | MAP4 (MinHashed atom-pair) | MinHash atom-pair | r=1,2 | 1024/2048 | Biological + metabolite diversity | `map4` library required; slower hash | |
| 29 | | MHFP6 (MinHash) | MinHash ECFP-like | r=3 (diam 6) | 2048 | Large-library nearest-neighbor with a compatible MinHash/LSH index | Different distance semantics from folded-bit Tanimoto | |
| 30 | | Pharm2D | 2D pharmacophore | feature pairs/triplets | sparse | Pharmacophore search | Sparse, slower | |
| 31 | |
| 32 | **Decision:** For drug-like similarity ranking, start with **ECFP4 2048 bit** because it is fast and well characterized. MHFP6 outperformed ECFP4 for analog recovery in the benchmark reported by Probst and Reymond (2018), making it a candidate for large, diverse libraries. For scaffold hopping, benchmark ECFP4, AtomPair, TopologicalTorsion, and pharmacophore fingerprints on target-relevant actives and decoys; published comparisons do not support a universal AtomPair advantage (Gardiner et al. 2011; Riniker & Landrum 2013). |
| 33 | |
| 34 | ## Bit vs Count Vectors |
| 35 | |
| 36 | | Form | Use | Library impact | |
| 37 | |------|-----|----------------| |
| 38 | | Bit (0/1) | Tanimoto similarity, BulkTanimotoSimilarity, RDKit fingerprint folding | Standard for similarity | |
| 39 | | Count (integer) | Some ML methods, RF on counts, neural fingerprints | Loses bit-level fast operations; richer signal | |
| 40 | | Sparse (dict) | Direct chemical interpretation (which fragments at which atoms) | Use for SHAP / atomic attribution | |
| 41 | |
| 42 | ```python |
| 43 | from rdkit import Chem |
| 44 | from rdkit.Chem import rdFingerprintGenerator |
| 45 | |
| 46 | mol = Chem.MolFromSmiles('CCO') |
| 47 | |
| 48 | morgan = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048) |
| 49 | ecfp4_bit = morgan.GetFingerprint(mol) |
| 50 | ecfp4_count = morgan.GetCountFingerprint(mol) |
| 51 | ecfp4_sparse = morgan.GetSparseCountFingerprint(mol) |
| 52 | ``` |
| 53 | |
| 54 | ## Morgan / ECFP Radius Math |
| 55 | |
| 56 | ECFP-X notation: X is the **diameter** in bonds. RDKit's `radius` parameter is half of X. |
| 57 | |
| 58 | | Notation | RDKit radius | Diameter | Captures | |
| 59 | |----------|--------------|----------|----------| |
| 60 | | ECFP0 | 0 | 0 | Atom identity only | |
| 61 | | ECFP2 | 1 | 2 | Atom + immediate neighbors | |
| 62 | | ECFP4 | 2 | 4 | Atom + 2-bond environment | |
| 63 | | ECFP6 | 3 | 6 | Atom + 3-bond environment | |
| 64 | |
| 65 | **Trade-off:** Larger radius captures more specific local environments but increases collisions at fixed ` |