Sovereign 8s.is mirror of standardgalactic/active-drug-discovery
  • Python 98.5%
  • Jupyter Notebook 0.9%
  • Shell 0.6%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-06-21 12:02:35 +02:00
data Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
src Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
.gitignore Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
__init__.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
active_learning.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
CITATION.cff Add Zenodo DOI (badge, CITATION.cff, citing section) 2026-06-21 12:02:35 +02:00
LICENSE Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
predict_binary_gnn.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
predict_binary_xgb.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
predict_minisci_gnn.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
predict_regio.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
README.md Add Zenodo DOI (badge, CITATION.cff, citing section) 2026-06-21 12:02:35 +02:00
setup_env.sh Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
train_binary_xgb.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
train_gnn_ensemble.sh Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00
train_gnn_workflow.py Initial public release of active-drug-discovery 2026-06-21 11:40:46 +02:00

Advancing chemical reaction prediction in data-scarce drug discovery with active and geometric deep learning

DOI

This repository contains a reference implementation detailing the workflows for inference and training as well active learning and the experiments on toy datasets introduced in the paper by Mason Minot, Yannick Stenzhorn, Jens Wolfard, Sebastian Strobel, Philippe Jablonski, Daniel Zimmerli, Martin Binder, Uwe Grether, Rainer E. Martin, Alex T. Müller, David F. Nippa, Kenneth Atz, & Gisbert Schneider.

Dataset preprocessing is embedded into each of the respective workflows.

Table of contents

  1. Prepare working environment
  2. Activate working environment
  3. Downloading weights and data
  4. Binary prediction XGBoost
  5. Binary prediction GNN
  6. Regioselectivity prediction
  7. Minisci prediction
  8. Binary training XGBoost
  9. Binary training GNN
  10. Regioselectivity training
  11. Minisci training
  12. Active learning
  13. Toy experiments
  14. Citing This Work

Prepare working environment

To setup the Conda environment, run ./setup_env.sh in the cmd line

Activate working environment

After the initial environment setup and to use any of the scripts below, ensure the environment is activate via

cd active-drug-discovery
conda activate active_disc

Downloading weights and data

Pretrained model weights are distributed via the GitHub Releases page (they are not stored in the git repository). Download the assets from the latest release and place them in src/model_weights/:

mkdir -p src/model_weights/binary_xgb

# Regioselectivity GNN (EquiformerV2) and binary reactivity GNN (PONITA)
curl -L -o src/model_weights/equiformer_regio.pth \
  https://github.com/minotm/active-drug-discovery/releases/download/v1.0.0/equiformer_regio.pth
curl -L -o src/model_weights/ponita_binary.pth \
  https://github.com/minotm/active-drug-discovery/releases/download/v1.0.0/ponita_binary.pth

# Binary reactivity XGBoost ensemble (+ preprocessing) -> unpack into binary_xgb/
curl -L -o /tmp/binary_xgb.zip \
  https://github.com/minotm/active-drug-discovery/releases/download/v1.0.0/binary_xgb.zip
unzip -o /tmp/binary_xgb.zip -d src/model_weights/binary_xgb

No Minisci weights are shipped; train your own (see Minisci training).

Training data

The training data used in the paper ships with this repository under data/training_data/:

File Task Delimiter Description
regioselectivity.csv Regioselectivity tab Substrate SMILES and borylation product_smiles pairs used to train the regioselectivity model.
pre_AL_binary_and_yield.csv Binary + yield semicolon Initial (pre active learning) C–H borylation reactions with reaction conditions, the binary reactivity label, and sum_mono_bo_conv yield/conversion.
AL_1_binary_and_yield.csv Binary + yield tab Reactions acquired in the first active learning round (conditions, binary label, sum_mono_bo_conv yield).
AL_2_binary_and_yield.csv Binary + yield tab Reactions acquired in the second active learning round.
AL_3_binary_and_yield.csv Binary + yield tab Reactions acquired in the third active learning round.
minisci_data.tsv Minisci alkylation tab Full Minisci-type C–H alkylation dataset (13,490 reactions, 37 columns) with reaction conditions, mono_alkylation/di_alkylation/non_alkylation yields, and a binary reactivity label.

The borylation binary/yield files contain full reaction context (substrate, reagent, catalyst, ligand, solvent SMILES plus equivalents and conditions). The binary column is the reactivity label and sum_mono_bo_conv is the measured yield/conversion target.

Minisci dataset source

The Minisci-type C–H alkylation dataset (minisci_data.tsv) is reproduced from the dataset published with Nippa et al., "Expediting hit-to-lead progression in drug discovery through reaction prediction and multi-dimensional optimization", Nature Communications (2025), doi:10.1038/s41467-025-66324-4. The raw data is available on figshare: Minisci-type C–H alkylation dataset.

Inference example data

Small example inputs for the inference / scoring workflows live under data/inference_examples/:

File Used by Description
example_regio.csv predict_regio.py Example substrates (SMILES, PRODUCT_SMILES, ID) for regioselectivity prediction.
example_borylation_candidates.csv active_learning.py Example candidate substrates (startingmat_1_smiles) to score for active learning.
example_minisci.csv minisci workflows Example Minisci-type reactions (conditions + SMILES) matching the minisci_data.tsv schema.

Binary prediction XGBoost

Model: XGBoost ensemble

Input: csv SURF file containing the column startingmat_1_smiles

Example:

To run python script with example data

conda activate active_disc
python predict_binary_xgb.py data/binary_substrates.csv binary_prediction_output.csv 

This will store binary_prediction_output.csv in the output/ folder, adding the output prediction columns binary_prediction, logits, and uncertainty to the input csv file.

Note: uncertainty is calculated as the standard deviation of ensemble member predictions (logits).

Help options for binary prediction script

predict_binary_xgb.py options:

positional arguments:
  input_file            Path to the input file with substrates to predict
  output_file           Name of the output file to save predictions

optional arguments:
  --train_data_path PATH  Path to training data (default: data/training_data/pre_AL_binary_and_yield.csv)
  --ensemble_size N       Number of XGBoost classifiers in ensemble
  --enumerate_conditions  Enumerate conditions (True/False)
  --encoding_strategy S   Features to include (fp, fp_oh_num, fp_oh)
  --balance_strategy S    Class balancing strategy (class_weights, none, scale_pos_weight)
  --acquisition_function F Acquisition function for scoring
  --num_output_mols N     Number of molecules to score and output in csv file
  --hyperopt_evals N      Number of hyperparameter optimization iterations
  --run_metrics           Run metrics on held-out test set
  --num_bins N            Number of bins for model calibration error assessment

Binary prediction GNN

Model: GNN

Input: csv SURF file containing the column startingmat_1_smiles

Example:

To run python script with example data

conda activate active_disc
python predict_binary_gnn.py data/binary_substrates.csv binary_prediction_output.csv 

This will store binary_prediction_output.csv in the output/ folder, adding the output prediction columns binary_prediction and logits to the input csv file.

Help options for binary prediction script

predict_binary_gnn.py options:

positional arguments:
  input_file            Path to the input file with substrates to predict
  output_file           Name of the output file to save predictions

optional arguments:
  --train_data_path PATH  Path to training data (default: data/training_data/pre_AL_binary_and_yield.csv)
  --enumerate_conditions  Enumerate conditions (True/False)
  --model                 Model for prediction (default: ponita)
  --checkpoint_folder     Location of pretrained model checkpoints (default: None)

Predicting with a model you've trained yourself

To run predictions using a model that you've trained yourself, the --checkpoint_folder argument must be specified as in the example below:

conda activate active_disc
python predict_binary_gnn.py data/binary_substrates.csv binary_prediction_output.csv  --checkpoint_folder src/model_weights/your_binary_run

Prediction ensembles

Binary prediction occurs via ensembling. If only a single checkpoint is in the folder, only one model will be used.

Passing this flag will cause the ensemble all checkpoints in the folder with 'final' in their name to make predictions. This restricts running predictions to only models that have been trained to completion.

All models in the ensemble make predictions on 5 conformers per molecule. The predictions are then averaged across conformers and across all available models in the ensemble.

Regioselectivity prediction

Model: GNN

Input: csv file containing the column SMILES and the column ID. Note: if borylation product smiles are avialable, include them in a column titled PRODUCT_SMILES

Example data is provided in data/inference_examples/example_regio.csv

Example

To run the python script with example data:

conda activate active_disc
python predict_regio.py data/inference_examples/example_regio.csv output/preds_regio.xlsx --smiles_col "SMILES" --id_col "ID"

This will store a predictions.xlsx in the output/ folder containing the SMILES, ID, and images of the input molecules annotated with predicted sites of borylation.

Mean and standard deviation of predicted borylation sites are overlayed on the atoms predicted > 10% likely to be borylated. Mean and standard deviation result from model predictions on 5 different conformers of the input molecule.

Predicting with a model you've trained yourself

To run predictions using a model that you've trained yourself, the --checkpoint_folder argument must be specified as in the example below:

conda activate active_disc
python predict_regio.py data/inference_examples/example_regio.csv output/preds_regio.xlsx --smiles_col "SMILES" --id_col "ID" --checkpoint_folder src/model_weights/your_regio_run

Prediction ensembles

Regio prediction occurs via ensembling. If only a single checkpoint is in the folder, only one model will be used.

Passing this flag will cause the ensemble all checkpoints in the folder with 'final' in their name to make predictions. This restricts running predictions to only models that have been trained to completion.

All models in the ensemble make predictions on 5 conformers per molecule. The predictions are then averaged across conformers and across all available models in the ensemble.

Regio prediction model description:

Regioselectivity prediciton uses the Equiformer v2 model.

Training was performed via multi-task learning including

  1. The main regioselectivity prediction task
  2. Coordinate denoising auxiliary task.

Coordinate denoising is deactivated during inference.

Help options for regioselectivity prediction script

positional arguments:
  input_file            Path to the input file.
  output_filename       Name of the output file.

options:
  -h, --help            show this help message and exit
  -d DELIMITER, --delimiter DELIMITER
                        Column delimiter of input file.
  -c SMILES_COL, --smiles_col SMILES_COL
                        Name of column that contains SMILES. Defaults to "SMILES"
  -i ID_COL, --id_col ID_COL
                        Name of column that contains compound IDs. Defaults to "ID"

Minisci prediction

Model: GNN (PONITA)

Predicts Minisci-type C–H alkylation outcomes for a reaction. Each reaction has two substrates (startingmat_1_smiles + startingmat_2_smiles) which are concatenated into a single graph; the model outputs one value per reaction.

Two targets are available via --minisci_target:

  • binary (default): reactivity classification. Output columns logits (sigmoid probability) and binary_prediction (thresholded at 0.5).
  • total_yield (also mono_yield / di_yield): yield regression. Output column yield_prediction (raw value).

Input: csv (comma) or tsv (tab) file containing rxn_id, startingmat_1_smiles, startingmat_2_smiles, reagent_1_smiles, catalyst_1_smiles, additive_1_smiles, solvent_1_smiles, and solvent_2_smiles. Example data is provided in data/inference_examples/example_minisci.csv.

No pretrained Minisci weights are shipped with this repository. --checkpoint_folder is required and must point to a directory of checkpoint(s) you trained yourself (see Minisci training). If the folder contains multiple checkpoints, their predictions are averaged. --use_rxn_conditions must match how the checkpoint was trained, since it changes the model architecture.

Example

To run binary reactivity prediction with a self-trained checkpoint folder:

conda activate active_disc
python predict_minisci_gnn.py data/inference_examples/example_minisci.csv minisci_predictions.csv --minisci_target binary --checkpoint_folder src/model_weights/your_minisci_run --use_rxn_conditions

For yield regression, set --minisci_target total_yield:

python predict_minisci_gnn.py data/inference_examples/example_minisci.csv minisci_predictions.csv --minisci_target total_yield --checkpoint_folder src/model_weights/your_minisci_run --use_rxn_conditions

This stores minisci_predictions.csv in the output/ folder, joining the prediction column(s) back onto the input rows by rxn_id. Reactions whose substrates fail to parse are skipped during graph mapping and receive an empty prediction.

Binary training XGBoost

Model: XGBoost ensemble

Input: path to csv containing training data with reaction conditions.

Example:

To run python script directly with example data:

conda activate active_disc
python train_binary_xgb.py --train_data_path=data/training_data/pre_AL_binary_and_yield.csv

This will train an ensemble of XGBoost classifiers and preprocessing functions StandardScalar, and OneHotEncoder. The model weights will be saved to model_weights/binary_xgb as .pkl files.

Help options for binary training script

train_binary_xgb.py options:

optional arguments:
  --train_data_path PATH   Path to training data (default: data/training_data/pre_AL_binary_and_yield.csv)
  --model_output_dir PATH  Path to save model weights (default: src/model_weights/binary_xgb)
  --ensemble_size N        Number of XGBoost classifiers in ensemble
  --enumerate_conditions   Enumerate conditions (True/False)
  --encoding_strategy S    Features to include (fp, fp_oh_num, fp_oh)
  --balance_strategy S     Class balancing strategy (class_weights, none, scale_pos_weight)
  --acquisition_function F Acquisition function for scoring
  --num_output_mols N      Number of molecules to score and output in csv file
  --hyperopt_evals N       Number of hyperparameter optimization iterations
  --run_metrics            Run metrics on held-out test set
  --num_bins N             Number of bins for model calibration error assessment

Binary training GNN

Model: GNN

To train a single GNN for binary prediction via python:

conda activate active_disc
python train_gnn_workflow.py --input_csv data/training_data/pre_AL_binary_and_yield.csv --prediction_type binary --epochs 1000

Training arguments

required arguments:
  --input_csv PATH       Path to the input CSV file with training data

optional arguments:
  --prediction_type      Type of prediction model to train: binary or regio (default: regio)
  --model               Model architecture to use (default: ponita)
  --output_data_dir     Directory to save outputs (default: output)
  --checkpoint_path     Directory to save model weights (default: src/model_weights/)
  --epochs              Number of training epochs (default: 100)
  --batch_size         Training batch size (default: 16)
  --learn_rate         Learning rate (default: 0.0004)
  --patience           Patience for early stopping (default: 20)
  --wandb_logging      Enable Weights & Biases logging (flag)
  --seed               Random seed for reproducibility (default: 42)
  --run_id             Run ID for ensemble training (default: 0)

Regioselectivity training

Model: GNN

To train a single GNN for regioselectivity prediction via python:

conda activate active_disc
python train_gnn_workflow.py --input_csv data/training_data/regioselectivity.csv --epochs 1000

To train an ensemble of GNNs for regioselectivity prediction via LSF:

conda activate active_disc
./train_gnn_ensemble.sh --input_csv data/training_data/regioselectivity.csv

Training arguments

required arguments:
  --input_csv PATH       Path to the input CSV file with training data

optional arguments:
  --prediction_type      Type of prediction model to train: binary or regio (default: regio)
  --model               Model architecture to use (default: ponita)
  --output_data_dir     Directory to save outputs (default: output)
  --checkpoint_path     Directory to save model weights (default: src/model_weights/)
  --epochs              Number of training epochs (default: 100)
  --batch_size         Training batch size (default: 16)
  --learn_rate         Learning rate (default: 0.0004)
  --patience           Patience for early stopping (default: 20)
  --wandb_logging      Enable Weights & Biases logging (flag)
  --seed               Random seed for reproducibility (default: 42)
  --run_id             Run ID for ensemble training (default: 0)

Minisci training

Model: GNN (PONITA)

Trains a GNN to predict Minisci-type C–H alkylation outcomes from the full dataset in data/training_data/minisci_data.tsv (see Training data).

Prerequisite: build the reaction-condition vocabulary

The graph mapper encodes categorical reaction conditions from JSON vocab maps in data/minisci_rxn_emb_maps/. These ship with the repository, but to (re)build them from the dataset run:

conda activate active_disc
python -m src.minisci_utils.build_vocab

This reads data/training_data/minisci_data.tsv and writes the vocab maps to data/minisci_rxn_emb_maps/.

Example

To train a single GNN for Minisci binary reactivity prediction, writing checkpoints to a dedicated folder:

conda activate active_disc
python train_gnn_workflow.py --input_csv data/training_data/minisci_data.tsv --prediction_type minisci --minisci_target binary --use_rxn_conditions --checkpoint_path src/model_weights/your_minisci_run --epochs 1000

To train the yield-regression model instead, set --minisci_target total_yield:

python train_gnn_workflow.py --input_csv data/training_data/minisci_data.tsv --prediction_type minisci --minisci_target total_yield --use_rxn_conditions --checkpoint_path src/model_weights/your_minisci_run --epochs 1000

Point predict_minisci_gnn.py --checkpoint_folder at that folder to run Minisci prediction. Use a dedicated --checkpoint_path per run (the prediction script ensembles all .pth files in the folder, so keep only one target's checkpoints together), and use the same --use_rxn_conditions setting at prediction time as during training.

Training arguments

required arguments:
  --input_csv PATH       Path to the input CSV/TSV file with training data

optional arguments:
  --prediction_type      Type of prediction model to train: binary, regio, or minisci (default: regio)
  --minisci_target       Minisci target: binary, total_yield, mono_yield, di_yield (default: binary)
  --use_rxn_conditions   Include reaction-condition features (minisci) (flag)
  --model               Model architecture to use (default: ponita)
  --output_data_dir     Directory to save outputs (default: output)
  --checkpoint_path     Directory to save model weights (default: src/model_weights/)
  --epochs              Number of training epochs (default: 100)
  --batch_size         Training batch size (default: 16)
  --learn_rate         Learning rate (default: 0.0004)
  --patience           Patience for early stopping (default: 20)
  --wandb_logging      Enable Weights & Biases logging (flag)
  --seed               Random seed for reproducibility (default: 42)
  --run_id             Run ID for ensemble training (default: 0)

Active learning

Model: XGBoost ensemble

Input: csv or tsv file containing molecules to score for experimental testing. Must contain the column startingmat_1_smiles. Example data is provided in data/inference_examples/example_borylation_candidates.csv

This will store a al_output.csv in the output/ folder with an added column acquisition_function_value containing the model scores for the molecule. The output file will be sorted by score in descending order.

Scores are calculated according to Bayesian Active Learning by Disagreement (BALD) via an ensemble of XGBoost classifiers.

Example

To run the python script with example data:

conda activate active_disc
python active_learning.py data/inference_examples/example_borylation_candidates.csv al_output.csv

Help options for active learning script

active_learning.py Options:

positional arguments:
  input_file            Path to the input file.
  output_filename       Name of the output file.

optional arguments:
  --train_data_path PATH  Path to training data (default: data/training_data/pre_AL_binary_and_yield.csv)
  --ensemble_size N       Number of XGBoost classifiers in ensemble
  --acquisition_function F Acquisition function for scoring (default: bald)
  --num_output_mols N     Number of molecules to score and output in csv file

Toy experiments

Experiments on toy datasets can be found in src/toydataset/

Citing this Work

Please cite our work when referencing this repository.

@article{minot2025active,
  title={Active and geometric deep learning advances chemical reaction prediction in data-scarce drug discovery},
  author={Minot, Mason and Stenzhorn, Yannick and Wolfard, Jens and Strobel, Sebastian and Jablonski, Philippe and Zimmerli, Daniel and Binder, Martin and Grether, Uwe and Martin, Rainer E and M{\"u}ller, Alex T and Nippa, David F and Atz, Kenneth and Schneider, Gisbert},
  year={2025},
  publisher={ChemRxiv}
}

To cite this software specifically, use the archived Zenodo release (10.5281/zenodo.20783136), or use the "Cite this repository" button on GitHub (powered by CITATION.cff).

License

This repository is licensed under the GNU General Public License v3.0 (GPL-3.0). See LICENSE for the full text.

Copyright (c) 2026 Mason Minot (Roche & ETH Zurich) and Gisbert Schneider (ETH Zurich).

Third-party components

Several model implementations under src/models/ are derived from third-party projects and remain governed by their original licenses, not by the GPL-3.0 covering the rest of this repository. Each retains its upstream copyright notice and a LICENSE_* file in its directory, including:

  • src/models/fairchem_utils/, src/models/escn/, src/models/schnet.py, src/models/dimenet_plus_plus*.py — Meta (FAIR) / fairchem (MIT)
  • src/models/faenet/ — FAENet (MIT)
  • src/models/equiformer_v2/ — EquiformerV2
  • src/models/segnn/ — SEGNN
  • src/models/ponita/ — PONITA
  • src/models/tfn/ — Tensor Field Networks

Refer to the respective LICENSE_* files for the exact terms.