Explain & Annotate¶
molfp.explain
¶
Bit-level explainability: map each ON bit to the atoms/bonds that triggered it.
For any molecule + fingerprint type, returns a dict mapping bit indices to the structural features responsible for setting that bit. This is the core novel feature of molfp — no other fingerprint library provides unified bit-level explanations across all fingerprint types.
explain(smiles_or_mol, fp_type)
¶
Explain which atoms/bonds set each ON bit in a fingerprint.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
smiles_or_mol
|
Union[str, Mol]
|
SMILES string or RDKit Mol |
required |
fp_type
|
str
|
fingerprint name (e.g. "ecfp4", "maccs", "substructure") |
required |
Returns:
| Type | Description |
|---|---|
dict[int, Any]
|
dict mapping bit_index → list of atom/bond explanations. |
dict[int, Any]
|
Format varies by FP type: - ecfp4/atompairs2d: {bit: [(center_atom_idx, radius), ...]} - rdk/rdk_ext/rdk_graphonly: {bit: [[bond_indices], ...]} - substructure/klekota_roth: {bit: [atom_indices_tuple, ...]} - pubchem: {bit: {"section": str, "detail": str, "atoms": [...]}} - maccs: {bit: [atom_indices_tuple, ...]} - estate: {bit: [atom_idx, ...]} |
molfp.annotate
¶
Chemical annotation: human-readable names and descriptions for fingerprint bits.
annotate(fp_type, bit_idx)
¶
Get human-readable annotation for a specific fingerprint bit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fp_type
|
str
|
fingerprint name (e.g. "substructure", "pubchem", "maccs") |
required |
bit_idx
|
int
|
bit index (0-based) |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
dict with keys: name, smarts (if applicable), description, category |
get_annotations(fp_type)
¶
Get all annotations for a fingerprint type. Returns {bit_idx: annotation_dict}.