Molecular graph scaffold split
Skill rangsimanketkaew/mlff/skills/molecular_graph_scaffold_split
Molecular graph representations and Bemis-Murcko scaffold splitting to assess OOD generalization.From its SKILL.md
npx -y skills add rangsimanketkaew/mlff --skill molecular_graph_scaffold_splitAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
2.0 KB, as published. Nobody here has run it
Molecular Graph & Scaffold Splitting
Use this skill when processing raw molecular data (SMILES or 3D coordinates) and preparing dataset partitions for machine learning training. This ensures realistic validation by avoiding chemical data leakage between splits.
Conceptual Framework
Molecular Graph Representation
Molecules are represented as graphs $G = (V, E)$, where:
- Nodes $v \in V$ represent atoms featurized by atomic properties (atomic number, valence, hybridization, formal charge, etc.).
- Edges $e_{uv} \in E$ represent bonds featurized by bond properties (bond type, aromaticity, ring membership).
Bemis-Murcko Scaffold Splitting
Instead of random splitting, which can lead to over-optimistic performance estimates due to highly similar molecules appearing in both train and test splits, scaffold splitting partitions molecules by their core Bemis-Murcko scaffold (the ring structures and their linkers). This ensures:
- Out-of-distribution (OOD) generalization is evaluated.
- The model's capacity to generalize to novel chemotypes is measured accurately.
Recommended Workflow
- Preprocess and Clean SMILES: Use RDKit to standardize structures (desalt, neutralize charges, find canonical SMILES).
- Compute Bemis-Murcko Scaffolds: For each molecule, extract its scaffold.
- Group by Scaffold: Identify all unique scaffolds and group corresponding molecular indices.
- Sort and Split: Sort scaffold groups by size, and assign them to train, validation, and test splits (typically 80/10/10 or 80/20) to ensure that the largest groups are distributed appropriately.
- Verify Split: Check similarity/overlap of chemical space between splits.
Code Example
Run the helper script scaffold_split.py to automatically calculate scaffold splits for a list of SMILES:
python scripts/scaffold_split.py --input dataset.csv --smiles_col "smiles" --ratios 0.8,0.1,0.1