TargetDiff is a bioinformatics model for target-aware molecule generation and protein-ligand affinity prediction.
The original paper is 3D Equivariant Diffusion for Target-Aware Molecule Generation and Affinity Prediction (ICLR 2023).
Model Description
TargetDiff is based on a 3D equivariant diffusion network. Given a protein binding pocket, it generates candidate small molecules and can use an EGNN property prediction branch to predict protein-ligand complex affinity.
The current package organizes TargetDiff example scripts, a snapshot of the model implementation, sample inputs, and pretrained weights in the same directory. Datasets will be uploaded later.
Use Cases
Use case
Description
Protein-ligand affinity prediction
Takes a protein PDB file and ligand SDF file as input, and outputs molar concentration predictions for Ki, Kd, or IC50
Target-aware small molecule generation
Takes a protein binding pocket PDB file as input, and outputs generated molecule sample.pt files and SDF files for molecules that can be reconstructed
Diffusion model training
Trains the TargetDiff molecule generation model using CrossDocked2020 pocket data
Property prediction training
Trains an EGNN affinity prediction model using PDBbind data
Generated result evaluation
Computes metrics such as stability, reconstruction success rate, QED, SA, and optional Vina docking metrics for sampling results
Usage
1. Using OneCode
You can try intelligent one-click AI4S programming through the OneCode online environment:
Training weights are already included in the weights folder and can be used directly after downloading the model package.
Datasets will be uploaded to Hugging Face soon, and command-line downloads will be supported later.
3. Affinity Prediction
3.1 Affinity Prediction Training
bash scripts/train_prop.sh
This script automatically performs the following steps:
Extract binding pockets from the PDBbind refined set.
Split the training, validation, and test sets according to the coreset.
Train an EGNN-based protein-ligand binding affinity prediction model.
3.2 Affinity Prediction Evaluation
Use the trained affinity prediction model to evaluate on the test set. The expected official metrics on PDBBind v2016 are:
RMSE
MAE
R²
Pearson
Spearman
1.316
1.031
0.633
0.797
0.782
Run:
bash
1exportPYTHONPATH=../../../src:$PYTHONPATH2python scripts/property_prediction/eval_prop.py \3 --ckpt_path ${ONESCIENCE_MODELS_DIR}/targetdiff/pretrained_models/egnn_pdbbind_v2016.pt \4 --device cuda
3.3 Affinity Prediction Inference
bash scripts/inference.sh
By default, this script performs affinity prediction on the example protein-ligand pair 3ug2, using the default weights and example data:
Model weights: ${ONESCIENCE_MODELS_DIR}/targetdiff/pretrained_models/egnn_pdbbind_v2016.pt
This script reads the diffusion model checkpoint from configs/sampling.yml, generates candidate ligand molecules for the i-th pocket in the test set, and saves the result as result_i.pt.
Root directory of the original protein files, used for docking evaluation
--eval_step
No
Which sampling step to evaluate, default -1 (the final step)
--eval_num_examples
No
Number of samples to evaluate, default all
--exhaustiveness
No
Docking search intensity, default 16
--save
No
Whether to save evaluation results, default True
Supported docking modes:
Mode
Description
none
Computes only metrics such as validity, uniqueness, and novelty, without docking
vina_score
Uses AutoDock Vina to score generated molecules
vina_dock
Uses AutoDock Vina to redock generated molecules
qvina
Uses QuickVina for docking
The first run in vina_score or vina_dock mode may take some time to prepare pdbqt and pqr files.
5.2 Evaluation from Meta Files
The official project provides sampled and docked meta files, including TargetDiff and baselines such as CVAE, AR, and Pocket2Mol. These files can be downloaded and evaluated directly:
The affinity prediction training script train_prop.sh automatically performs pocket extraction and dataset splitting. To run these steps separately, use the following commands:
The original TargetDiff code is licensed under the MIT License. This repository retains source attribution and is organized for OneScience Hugging Face automated runtime scenarios.
If you use TargetDiff results in research, we recommend citing the original TargetDiff paper and relevant OneScience project information. Depending on the actual task, also add citations for datasets or tools such as CrossDocked2020, PDBbind, RDKit, OpenBabel, and Vina/QVina.
bibtex
1@inproceedings{guan3d,
2 title={3D Equivariant Diffusion for Target-Aware Molecule Generation and Affinity Prediction},
3 author={Guan, Jiaqi and Qian, Wesley Wei and Peng, Xingang and Su, Yufeng and Peng, Jian and Ma, Jianzhu},
4 booktitle={International Conference on Learning Representations},
5 year={2023}
6}