QM9 Molecular Data Preprocessing and ML Pipeline
This repository contains a series of scripts for processing the QM9 dataset, computing molecular descriptors (e.g., ECFP4), cleaning and organizing molecular data, and preparing it for machine learning (ML) tasks.
This pipeline transforms raw .xyz molecular files into a structured ML-ready format by: 1. Extracting properties 2. Calculating ECFP4 fingerprints 3. Cleaning and filtering problematic entries 4. Organizing columns and unpacking features 5. Finalizing the dataset for ML 6. Splitting it into training, validation, and test sets
Scripts
| File | Description |
|---|---|
00_download_data.sh |
Downloads, unzips, and moves the files into a directory called input_data. |
01_batch_data.py |
Creates many batch files, each containing a portion of the data as file paths. Batching helps parallelize the next step. |
02_process_batch.py |
Reads and parses .xyz files, saving processed molecular data (e.g., atoms, coordinates, properties) in .parquet format. |
03_run_batches.sh |
A shell script to process batches of .xyz files using SLURM or local runs. Calls 02_process_batch.py over all batch files. |
04_merge_data.py |
Merges all batch-level .parquet outputs into a single unified dataset. |
05_sanitize_data.py |
Standardizes SMILES strings and removes molecules that fail sanitization. |
06_calculate_ecfp.py |
Computes ECFP4 molecular fingerprints using RDKit. |
07_calculate_properties.py |
Calculates and appends molecular properties to the dataset. |
08_organize_columns.py |
Reorganizes column order, drops unnecessary columns, and prepares a clean structure. |
09_unpack_ecfp4.py |
Unpacks the ECFP4 bit vectors into individual binary columns for ML input. |
10_finalize_ml_data.py |
Final checks and formatting to ensure the data is ready for ML training. |
11_split_ml_data.py |
Splits the final dataset into train/val/test sets using fixed proportions (e.g., 80/10/10). |
Output
- Clean .parquet file containing ECFP4 + molecular properties, Split files for ML training: train.parquet, val.parquet, test.parquet
output format
| Property Group (Column Range) | Columns |
|---|---|
| Identifier (1–1) | ID |
| Chemical descriptors (2–9) | MolWt, ClogP, TPSA, HBD, HBA, NumRotatableBonds, RingCount, FractionCSP3 |
| Quantum-chemical & thermodynamic properties (10–24) | Rotational_Constant_A, Rotational_Constant_B, Rotational_Constant_C, Dipole_Moment, Isotropic_polarizability, Energy_of_HOMO, Energy_of_LUMO, LUMO_HOMO_GAP, Electronic_spatial_extent, Zero_point_vibrational_energy, Internal_energy_at_0_K, Internal_energy_at_298.15_K, Enthalpy_at_298.15_K, Free_energy_at_298.15_K, Heat_capacity_at_298.15_K |
| Structural fingerprint (25–25) | Ecfp_4 (2,048-bit Morgan fingerprint, radius 2) |
Sources:
L. Ruddigkeit, R. van Deursen, L. C. Blum, J.-L. Reymond, Enumeration of 166 billion organic small molecules in the chemical universe database GDB-17, J. Chem. Inf. Model. 52, 2864–2875, 2012.
R. Ramakrishnan, P. O. Dral, M. Rupp, O. A. von Lilienfeld, Quantum chemistry structures and properties of 134 kilo molecules, Scientific Data 1, 140022, 2014.
License
This project is licensed under CC0 (for use with QM9 which is public domain). Attribution is appreciated but not required.