bio-molecular-descriptors

SkillAI & models

Calculates 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 selection. Use when featurizing molecules for similarity, QSAR, virtual screening, or ML, or selecting the correct fingerprint for a chemotype-aware task.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the bio-molecular-descriptors skill

What this skill tells your AI

The instructions your AI receives, as published by pku-yuangroup/openai4s in skills/bioskills/bio-chemoinformatics-molecular-descriptors/SKILL.md and read by ahel’s review.

Version Compatibility

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.

Before using code patterns, verify installed versions match. If versions differ:

  • Python: pip show <package> then help(module.function) to check signatures

If code throws ImportError, AttributeError, or TypeError, introspect the installed package and adapt the example to match the actual API rather than retrying.

Molecular Descriptors

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.

For canonicalization before featurization, see chemoinformatics/molecular-standardization. For 3D-only descriptors, see chemoinformatics/conformer-generation.

Fingerprint Taxonomy

FingerprintTypeRadius/PathBitsUse caseFails when
Morgan (ECFP)Circularr=2 (ECFP4), r=3 (ECFP6)2048 typicalDrug-like similarity, ML defaultLoses long-range topology; bit collisions at low nBits
FCFPFunctional Morganr=2 default2048Pharmacophore-aware similaritySame caveats as ECFP; less specific
MACCSSubstructure key166 fixed bits167Quick fingerprint, drug-likenessToo sparse for large diverse libraries
RDKit FPPath/subgraph-basedpaths and branched subgraphs up to 7 bonds by default2048RDKit-native ECFP alternativeDrug-like only; not optimal for scaffold hopping
AtomPairPair + topological distanceAll atom pairs2048Long-range topological similaritySlower than ECFP; harder to interpret
TopologicalTorsion4-atom torsionAll TT2048Path-pattern similarityLike AP, slower than ECFP
AvalonSubstructure + atom pairsMixed512/1024Fast similarityLess standard; older
MAP4 (MinHashed atom-pair)MinHash atom-pairr=1,21024/2048Biological + metabolite diversitymap4 library required; slower hash
MHFP6 (MinHash)MinHash ECFP-liker=3 (diam 6)2048Large-library nearest-neighbor with a compatible MinHash/LSH indexDifferent distance semantics from folded-bit Tanimoto
Pharm2D2D pharmacophorefeature pairs/tripletssparsePharmacophore searchSparse, slower

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).

Bit vs Count Vectors

FormUseLibrary impact
Bit (0/1)Tanimoto similarity, BulkTanimotoSimilarity, RDKit fingerprint foldingStandard for similarity
Count (integer)Some ML methods, RF on counts, neural fingerprintsLoses bit-level fast operations; richer signal
Sparse (dict)Direct chemical interpretation (which fragments at which atoms)Use for SHAP / atomic attribution
from rdkit import Chem
from rdkit.Chem import rdFingerprintGenerator

mol = Chem.MolFromSmiles('CCO')

morgan = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)
ecfp4_bit = morgan.GetFingerprint(mol)
ecfp4_count = morgan.GetCountFingerprint(mol)
ecfp4_sparse = morgan.GetSparseCountFingerprint(mol)

Morgan / ECFP Radius Math

ECFP-X notation: X is the diameter in bonds. RDKit's radius parameter is half of X.

NotationRDKit radiusDiameterCaptures
ECFP000Atom identity only
ECFP212Atom + immediate neighbors
ECFP424Atom + 2-bond environment
ECFP636Atom + 3-bond environment

Trade-off: Larger radius captures more specific local environments but increases collisions at fixed nBits. ECFP4 2048 is a common baseline (Rogers & Hahn 2010; Wu et al. 2018). O'Boyle and Sayle (2016) showed that increasing folded-fingerprint length can improve virtual-screening performance, but they did not establish a universal 4096-bit setting or a 1-5% collision rate. Measure collision occupancy and model performance for the dataset; increase nBits or use an unhashed sparse representation when needed.

FCFP vs ECFP

FCFP (Functional-Class) uses RDKit's Morgan feature invariants (donor, acceptor, aromatic, halogen, basic, and acidic) instead of atom identity. Hydrophobe is a family in BaseFeatures.fdef, but it is not one of the default Morgan feature-invariant classes. FCFP trades atom-specificity for functional-equivalence.

ecfp_generator = rdFingerprintGenerator.GetMorganGenerator(radius=2, fpSize=2048)
feature_invariants = rdFingerprintGenerator.GetMorganFeatureAtomInvGen()
fcfp_generator = rdFingerprintGenerator.GetMorganGenerator(
    radius=2, fpSize=2048, atomInvariantsGenerator=feature_invariants)
ecfp4 = ecfp_generator.GetFingerprint(mol)
fcfp4 = fcfp_generator.GetFingerprint(mol)

When to use FCFP4: Scaffold-hopping campaigns, pharmacophore-driven similarity, cross-target activity prediction.

When to use ECFP4: Within-series QSAR, lead optimization, when chemotype identity matters.

3D Descriptors and Conformer Dependence

Conformer-dependent descriptors (asphericity, eccentricity, principal moments of inertia, RDF) require a generated 3D structure. A single conformer may be unrepresentative when the molecule is flexible; measure descriptor variation across a conformer ensemble when the downstream conclusion depends on 3D shape.

Goal: Compute 3D shape descriptors over a conformer ensemble rather than from a single (possibly unrepresentative) conformer.

Approach: Add explicit hydrogens, embed N conformers with ETKDGv3, MMFF-optimize them all, then evaluate the descriptor across each conformer for downstream averaging.

from rdkit.Chem import AllChem, Descriptors3D

mol = Chem.MolFromSmiles('CCCCO')
mol = Chem.AddHs(mol)

params = AllChem.ETKDGv3()
params.randomSeed = 42
conf_ids = AllChem.EmbedMultipleConfs(mol, numConfs=20, params=params)
if not conf_ids:
    raise RuntimeError('ETKDGv3 failed to generate any conformers')
if not AllChem.MMFFHasAllMoleculeParams(mol):
    raise ValueError('MMFF94 parameters are unavailable for this molecule')
optimization_results = AllChem.MMFFOptimizeMoleculeConfs(mol)
if any(status != 0 for status, _ in optimization_results):
    raise RuntimeError('MMFF94 optimization did not converge for every conformer')

asphericities = [Descriptors3D.Asphericity(mol, confId=c) for c in conf_ids]

Decision: For QSAR / ML, choose and document the conformer count using a convergence check on representative molecules. Report the aggregation rule, such as a simple mean or a Boltzmann-weighted average, and the energy model used for any weights.

Partial Charge Methods

MethodSoftwareCostAccuracyUse for
Gasteiger-MarsiliRDKit, Open BabelFastEmpirical, roughCharge-aware preparation or models that explicitly require Gasteiger charges; Vina/Vinardo scoring itself does not require assigned atom charges
MMFF94RDKit0.1s/molForce-field consistentMMFF energy, conformer ranking
AM1-BCCantechamber (AmberTools)~10s/molSemi-empiricalMD setup, FEP, GAFF
RESPpsi4, Gaussianminutes/molRestrained fit to a quantum-mechanical ESP; protocol-specificForce-field workflows parameterized for that RESP protocol
OpenFF Rechargeopenff-rechargeWorkflow-dependentFramework for generating/retrieving QC ESP data and fitting library charges, BCCs, RESP charges, or virtual sitesDeveloping or evaluating charge models; it is not one charge-assignment method
from rdkit.Chem import AllChem

AllChem.ComputeGasteigerCharges(mol)
for atom in mol.GetAtoms():
    print(atom.GetIdx(), atom.GetPropsAsDict().get('_GasteigerCharge', None))

Critical: Charge method must match downstream. Gasteiger charges in an AMBER MD run violate the assumptions of the protein force field.

MAP4 and MHFP6 for Diverse Libraries

For libraries spanning drug-like molecules, natural products, peptides, and metabolites, compare ECFP4 with MAP4 or MHFP6 on task-relevant retrieval benchmarks. MAP4 and MHFP6 use MinHash with atom-pair or circular-substructure shingles, but no universal pairwise-similarity range establishes that ECFP4 is saturated for every mixed library.

from mhfp.encoder import MHFPEncoder

encoder = MHFPEncoder(2048)
mhfp6 = encoder.encode_mol(mol, radius=3)

MHFP6 distance is Jaccard on MinHash, not standard Tanimoto. Use MHFPEncoder.distance(fp1, fp2).

Physicochemical Descriptors

DescriptorSourceRangeDrug-like cutoff
MolWtRDKit Descriptors.MolWt~50-2000 Da<=500 (Lipinski)
MolLogP (Crippen)RDKit Descriptors.MolLogP-5 to 8<=5 (Lipinski)
HBDLipinski.NumHDonors0-10<=5 (Lipinski)
HBALipinski.NumHAcceptors0-15<=10 (Lipinski)
TPSADescriptors.TPSA (Ertl)0-200 A^2<=140 (Veber oral); <=90 (BBB+)
RotBondsLipinski.NumRotatableBonds0-15<=10 (Veber)
AromaticRingsLipinski.NumAromaticRings0-6<=3-4 (Ritchie-Macdonald aromatic ring count)
HeavyAtomsDescriptors.HeavyAtomCount<=50 (lead-like)
FractionCSP3Descriptors.FractionCSP30-1Descriptive; higher sp3 character was associated with clinical progression by Lovering et al. (2009), without a universal cutoff
QEDQED.qed0-1Higher is more similar to the reference property distributions; a project may use >=0.5 as a triage heuristic
SAscoresascorer.calculateScore (external)1-10Lower is easier by the model; project cutoffs such as <=4 or >6 require dataset calibration

Goal: Compute a standard physicochemical descriptor panel for drug-likeness filtering and QSAR features.

Approach: Combine RDKit Descriptors, Lipinski, and QED calls into a single dict so the caller gets MW, LogP, HBD/HBA, TPSA, rotatable bonds, aromatic rings, fraction sp3, and QED in one pass.

from rdkit.Chem import Descriptors, Lipinski, QED

def physchem(mol):
    return {
        'MolWt': Descriptors.MolWt(mol),
        'MolLogP': Descriptors.MolLogP(mol),
        'HBD': Lipinski.NumHDonors(mol),
        'HBA': Lipinski.NumHAcceptors(mol),
        'TPSA': Descriptors.TPSA(mol),
        'RotBonds': Lipinski.NumRotatableBonds(mol),
        'AromRings': Lipinski.NumAromaticRings(mol),
        'FractionCSP3': Descriptors.FractionCSP3(mol),
        'QED': QED.qed(mol),
    }

Drug-Likeness Rule Sets

RuleConstraintsSource
Lipinski Ro5MW<=500, LogP<=5, HBD<=5, HBA<=10Lipinski 1997
VeberRotBonds<=10, TPSA<=140Veber 2002 (oral)
Ghose160<=MW<=480, -0.4<=LogP<=5.6, 40<=MR<=130, 20<=atoms<=70Ghose 1999
EganLogP<=5.88, TPSA<=131.6Egan 2000
Muegge200<=MW<=600, -2<=LogP<=5, TPSA<=150, rings<=7, C>4, heteroatoms>1, RotBonds<=15, HBD<=5, HBA<=10Muegge 2001
Lead-likeMW<=350, LogP<=3Teague 1999
Fragment Ro3MW<=300, LogP<=3, HBD<=3, HBA<=3, RotBonds<=3, TPSA<=60 A^2Congreve 2003
Pfizer CNS MPOSix desirability functions: ClogP, ClogD, MW, TPSA, HBD, and pKaWager 2010

Use case: Treat Ro5 and Veber criteria as risk indicators rather than universal hard cutoffs. Doak et al. (2014) analyze orally bioavailable drugs and candidates beyond the Rule of 5, but do not support the claim that approximately 30% of marketed oral drugs violate at least one rule. For CNS prioritization, implement the six-property Wager MPO desirability score rather than replacing it with three hard thresholds.

QED (Weighted Drug-Likeness)

QED (Bickerton 2012) is a single-number drug-likeness measure (0-1) combining 8 properties (MW, LogP, HBD, HBA, PSA, RotBonds, AromaticRings, structural alerts) via desirability functions.

Caveat: QED summarizes desirability functions derived from property distributions of marketed oral drugs; it is not a supervised predictor trained specifically on FDA-approved drugs. It can under-rank fragment-like or natural-product-like molecules, so do not use it as the sole filter for those libraries.

Common Errors

SymptomCauseFix
Fingerprint changes between runsRandom seed not set for canonicalizationRDKit Morgan is deterministic; check if input differs (stereo, charges)
MACCS bit count != 166RDKit MACCS returns 167 bits (bit 0 unused)Slice [1:] if comparing to literature 166-bit
Crippen LogP differs from XLogPDifferent modelUse Descriptors.MolLogP for Crippen; XLogP3 requires external lib
3D descriptor differs between callsDifferent conformerSet confId=0 explicitly; or average over ensemble
QED returns nanCharged species or non-standard atomStandardize (uncharge) before QED
Count-vector similarity differs from bit-vector similarityCount multiplicities change the generalized Tanimoto calculationRDKit supports Tanimoto on sparse count vectors; record the vector type and do not compare its threshold directly with a folded-bit threshold
MolWt off by ~1 from PubChemImplicit H counted differentlyUse Descriptors.ExactMolWt for monoisotopic; PubChem reports average

References

Related Skills

  • chemoinformatics/molecular-io - Parse molecules before featurization
  • chemoinformatics/molecular-standardization - Canonicalize before fingerprinting
  • chemoinformatics/conformer-generation - Generate 3D for conformer-dependent descriptors
  • chemoinformatics/similarity-searching - Use fingerprints for similarity ranking
  • chemoinformatics/qsar-modeling - ML using these descriptors as features
  • chemoinformatics/admet-prediction - Filter by drug-likeness criteria
  • machine-learning/biomarker-discovery - ML on molecular features

Signals

GitHub stars
409
Forks
48
Last commit
Sep 2026
Advanced
Catalog kind
skill
Gateway key
bio-molecular-descriptors
Source
github.com/pku-yuangroup/openai4s