Skip to content

Scaffold

molfp.scaffold

Scaffold extraction, fingerprinting, and scaffold-aware data splitting.

Murcko scaffolds identify the core ring system of a molecule after stripping side chains — critical for scaffold hopping, series analysis, diversity assessment, and preventing scaffold leakage in QSAR train/test splits.

scaffold(input_data, *, column=None)

Extract Murcko and generic scaffolds from molecule(s).

Parameters:

Name Type Description Default
input_data

SMILES string, list, Series, or DataFrame.

required
column

column name for DataFrame input.

None

Returns:

Type Description

Single molecule: dict with murcko, generic, smiles.

Multiple molecules: list of dicts.

scaffold_fingerprint(input_data, *, column=None, scaffold_type='murcko')

Create a binary scaffold membership fingerprint.

Each column represents a unique scaffold found in the dataset. A molecule gets a 1 in the column matching its scaffold.

Parameters:

Name Type Description Default
input_data

list of SMILES, Series, or DataFrame.

required
column

column name for DataFrame input.

None
scaffold_type

"murcko" or "generic".

'murcko'

Returns:

Type Description

dict with: X: numpy array (n_samples, n_scaffolds) — binary membership scaffolds: list of scaffold SMILES (column order) assignments: list of scaffold SMILES per molecule

scaffold_split(input_data, *, column=None, test_size=0.2, scaffold_type='murcko')

Scaffold-aware train/test split — prevents scaffold leakage.

Groups molecules by scaffold, then assigns entire groups to train or test. Ensures no scaffold appears in both sets — critical for fair QSAR evaluation.

Parameters:

Name Type Description Default
input_data

list of SMILES, Series, or DataFrame.

required
column

column name for DataFrame input.

None
test_size

fraction of molecules for test set (approximate).

0.2
scaffold_type

"murcko" or "generic".

'murcko'

Returns:

Type Description

dict with: train_idx: numpy array of training indices test_idx: numpy array of test indices n_train: number of training molecules n_test: number of test molecules n_scaffolds_train: number of scaffolds in train n_scaffolds_test: number of scaffolds in test scaffold_groups: dict mapping scaffold SMILES → list of molecule indices