molfp¶
Interpretable molecular fingerprints with SHAP-driven chemical explanations.
A native Python/RDKit library that computes 35 molecular fingerprint types (18 2D + 9 3D + 8 graph-based) and provides built-in tools for interpretation, visualization, collision detection, activity cliff analysis, bioactivity profiling, and SHAP-based feature explanation.
Install¶
Requires Python 3.9+. RDKit is installed automatically. See Getting Started for optional dependencies and troubleshooting.
Quick Example¶
import molfp
# Compute fingerprints
fp = molfp.maccs("CC(=O)Oc1ccccc1C(=O)O")
fps = molfp.ecfp4(["CCO", "c1ccccc1"], collision_free=True)
# Explain which atoms set which bits
molfp.explain("CCO", "ecfp4")
# SHAP interpretation with chemical meaning
result = molfp.interpret(smiles, activities, fp_type="ecfp4", collision_aware=True)
# Scaffold-aware train/test split
result = molfp.scaffold_split(smiles, test_size=0.2)
Features¶
- 35 fingerprint types — 18 2D, 9 3D, 8 graph-based
- Bit-level explainability — atom attribution for every ON bit
- Chemical annotation — human-readable names for fingerprint bits
- SHAP interpretation — collision-aware feature importance with chemical meaning
- Collision handling — detect, remove, or avoid hash collisions entirely
- Scaffold analysis — Murcko scaffolds with ~130 named ring systems, scaffold-aware splitting
- Activity cliffs — detect structurally similar molecules with different activities
- Bioactivity profiling — enriched/depleted bit analysis
- Isomer discrimination — test whether fingerprints distinguish structural isomers
- Graph representations — 4 graph types with PyG/DGL converters
- sklearn compatible — 27 transformers + GraphTransformer
For molecule visualization (2D drawing, 3D viewing, attribution maps), see molviewer: pip install molviewer
35 Fingerprint Types¶
2D Fingerprints (18 types)¶
| Type | Bits | Function |
|---|---|---|
| MACCS Keys | 166 | maccs() |
| ECFP4 (Morgan) | 1024 | ecfp4() |
| PubChem/CACTVS | 881 | pubchem() |
| Substructure FP | 307 | substructure() |
| Substructure Count | 307 | substructure_count() |
| Klekota-Roth | 4860 | klekota_roth() |
| Klekota-Roth Count | 4860 | klekota_roth_count() |
| E-State | 79 | estate() |
| AtomPairs2D | 780 | atompairs2d() |
| AtomPairs2D Count | 780 | atompairs2d_count() |
| RDK | 1024 | rdk() |
| RDK Extended | 1024 | rdk_ext() |
| RDK GraphOnly | 1024 | rdk_graphonly() |
| FCFP4 (Feature Morgan) | 1024 | fcfp4() |
| Lingo | 1024 | lingo() |
| Shortest Path | 1024 | shortest_path() |
| Hybridization | 1024 | hybridization() |
| Signature | 1024 | signature() |
3D Fingerprints (9 types)¶
| Type | Dims | Function |
|---|---|---|
| AtomPairs3D | 780 | atompairs3d() |
| AtomPairs3D Count | 780 | atompairs3d_count() |
| USR | 12 | usr() |
| USRCAT | 60 | usrcat() |
| Autocorr3D | 80 | autocorr3d() |
| RDF | 210 | rdf() |
| MORSE | 224 | morse() |
| WHIM | 114 | whim() |
| GETAWAY | 273 | getaway() |
Graph Fingerprints (8 types)¶
| Type | Function |
|---|---|
| Standard | mol_graph(type="standard") |
| Standard Enriched | mol_graph(type="standard", enriched=True) |
| Distance | mol_graph(type="distance") |
| Distance Enriched | mol_graph(type="distance", enriched=True) |
| Line | mol_graph(type="line") |
| Line Enriched | mol_graph(type="line", enriched=True) |
| Fragment | mol_graph(type="fragment") |
| Fragment Enriched | mol_graph(type="fragment", enriched=True) |