DiffDock
Model Overview
DiffDock is a diffusion model for protein-ligand molecular docking proposed by Corso et al. It supports single-complex molecular docking, batch molecular docking, evaluation, and related workflows.
Model Description
DiffDock formulates docking as a generative modeling problem. Given a protein receptor and a small-molecule ligand, it jointly models the ligand's translational, rotational, and torsional degrees of freedom through diffusion processes on SO(3)/SE(3), and generates candidate binding conformations.
Weights and datasets are not available at the moment. They will be uploaded to Hugging Face soon, and command-line downloads will be supported later.
Use Cases
| Use case | Description |
|---|---|
| Score model training | Takes processed PDBBind or MOAD data as input and outputs a DiffDock score model checkpoint |
| Single-complex molecular docking | Takes a protein PDB file and a ligand SMILES/SDF/MOL2 input, and outputs candidate ligand binding conformations in SDF format |
| Batch molecular docking | Takes a CSV file containing proteins, ligands, and complex names, and outputs sampled conformations in batches |
| Confidence rerank | Uses an additional confidence model to rank sampled conformations |
| Dataset evaluation | Computes metrics such as RMSD for sampling results on a validation or test set, with optional GNINA integration |
Usage
1. Using OneCode
You can try intelligent one-click AI4S programming through the OneCode online environment:
Try intelligent one-click AI4S programming
2. Manual Installation and Usage
Hardware Requirements
- Running on a GPU or DCU is recommended.
- CPU can be used for connectivity checks, but it is relatively slow.
- DCU users need to install DTK in advance. DTK 25.04.2 or later is recommended, or the OneScience-recommended version that matches the current cluster.
Software Requirements
Common DiffDock dependencies include PyTorch, PyTorch Geometric, RDKit, OpenBabel, e3nn, torch-scatter, torch-cluster, NumPy, SciPy, tqdm, PyYAML, and others. GNINA energy minimization during dataset evaluation requires installing gnina separately.
Environment Checks
- NVIDIA GPU:
nvidia-smi
- Hygon DCU:
hy-smi
Quick Start
1. Install the Runtime Environment
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
If the following code cannot find required libraries at runtime, activate CUDA as shown below.
source ${ROCM_PATH}/cuda/env.sh
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib/python3.11/site-packages/fastpt/torch/lib:$LD_LIBRARY_PATH"
2. Download the Model Package and Database
# If the model ID on the Hugging Face page uses different capitalization, use the actual published name.
hf download OneScience-Group/diffdock --local-dir ./diffdock
cd diffdock
Training Weights and Datasets
Weights and datasets are not available at the moment. They will be uploaded to Hugging Face soon, and command-line downloads will be supported later.
3. Check Files in the Package
The current package does not include pretrained weights. The command below should only show source code, configuration files, and example input files:
find . -maxdepth 3 -type f
If sampling or evaluation is required, first obtain a checkpoint through training, or place external DiffDock score/confidence weights in a local directory. Make sure the weight directory contains model_parameters.yml.
4. Score Model Training
Before training, update the data paths in configs/training.yml to local paths. Common fields include:
data.pdbbind_dir: processed PDBBind data directory.data.moad_dir: processed MOAD data directory.data.split_train: list of training-set complexes.data.split_val: list of validation-set complexes.runtime.log_dir: training output directory.
Start training:
cd scripts
bash train.sh
After training succeeds, the output directory usually contains:
model_parameters.yml: model architecture and training parameters.best_model.pt: weights with the best validation loss.best_ema_model.pt: EMA weights.best_inference_epoch_model.ptorbest_ema_inference_epoch_model.pt: weights saved when inference validation is enabled.last_model.pt: training state from the final epoch.
5. Molecular Docking Sampling
Sampling requires a trained score model directory, for example:
outputs/train/diffdock_cg_example/
├── model_parameters.yml
└── best_model.pt
Update the key fields in configs/sampling.yml to the actual paths:
model.model_dir: score model directory.model.ckpt: score checkpoint file name.confidence.confidence_model_dir: confidence model directory; set it tonullwhen rerank is not used.input.protein_path: protein PDB path. You can usedata/6o5u_protein_processed.pdb.input.ligand_description: SMILES string or ligand SDF/MOL2 path. You can usedata/6o5u_ligand.sdf.runtime.out_dir: sampling output directory.
Start single-complex sampling:
cd scripts
bash infer.sh
6. CSV Batch Sampling
Set input.protein_ligand_csv in configs/sampling.yml to the CSV path, and set the single-complex fields to null as needed. The CSV is recommended to contain the following columns:
complex_name,protein_path,ligand_description,protein_sequence
Here, ligand_description can be either a SMILES string or an SDF/MOL2 file path.
7. Dataset Evaluation
Before evaluation, update the dataset, model, and output directories in configs/evaluate.yml to actual paths:
python -m scripts.evaluate --config configs/evaluate.yml
If gnina.gnina_minimize=true is enabled, first make sure the following command can be run directly in the current environment:
gnina --help
8. Confidence Model Training
The confidence training entry point is provided by the installed OneScience package. This Hugging Face package does not duplicate that module. After completing score model training, run the following in the OneScience environment:
python -m onescience.confidence.diffdock.confidence_train \
--original_model_dir outputs/train/diffdock_cg_example \
--data_dir /path/to/PDBBind_processed \
--split_train /path/to/splits/timesplit_no_lig_overlap_train \
--split_val /path/to/splits/timesplit_no_lig_overlap_val
Data Preparation
DiffDock training usually requires preprocessed PDBBind or MOAD data. It is recommended to organize the data under a unified root directory, for example:
${ONESCIENCE_DATASETS_DIR}/diffdock/
├── PDBBind_processed/
├── MOAD_processed/
└── splits/
├── timesplit_no_lig_overlap_train
├── timesplit_no_lig_overlap_val
└── timesplit_test
Split files should be plain text files, with one complex name per line. Each name must correspond to a subdirectory name in the data directory.
Official OneScience Information
| Platform | OneScience main repository | Skills repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
- The original DiffDock 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 DiffDock results in research, we recommend citing the original DiffDock and DiffDock-L papers, as well as relevant OneScience project information. Depending on the actual task, also add citations for datasets or tools such as PDBBind, MOAD, RDKit, OpenBabel, and GNINA.
@inproceedings{corso2023diffdock,
title={DiffDock: Diffusion Steps, Twists, and Turns for Molecular Docking},
author={Corso, Gabriele and St{\"a}rk, Hannes and Jing, Bowen and Barzilay, Regina and Jaakkola, Tommi},
booktitle={International Conference on Learning Representations},
year={2023}
}
中文说明
模型概览
DiffDock 是 Corso 等人提出的蛋白质–配体分子对接(molecular docking)扩散模型,支持单个复合物的分子对接、批量分子对接、评估及相关工作流。
模型描述
DiffDock 将对接表述为生成式建模问题。给定蛋白质受体和小分子配体,模型通过 SO(3)/SE(3) 上的扩散过程对配体的平移、旋转及扭转自由度联合建模,并生成候选结合构象。
目前尚无可用权重和数据集。它们将于近期上传至 Hugging Face,随后将支持通过命令行下载。
使用场景
| 使用场景 | 说明 |
|---|---|
| 得分模型训练 | 接收处理后的 PDBBind 或 MOAD 数据,输出 DiffDock 得分模型权重(检查点)(checkpoint) |
| 单个复合物的分子对接 | 以蛋白质 PDB 文件和配体 SMILES/SDF/MOL2 为输入,以 SDF 格式输出候选配体结合构象 |
| 批量分子对接 | 接收包含蛋白质、配体和复合物名称的 CSV 文件,分批输出采样构象 |
| 置信度重排序 | 使用额外的置信度模型对采样构象进行排序 |
| 数据集评估 | 在验证集或测试集上为采样结果计算 RMSD 等指标,可选集成 GNINA |
使用方法
1. 使用 OneCode
可以通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 手动安装与使用
硬件要求
- 建议在 GPU 或 DCU 上运行。
- 可使用 CPU 检查连通性,但速度相对较慢。
- DCU 用户需提前安装 DTK。建议安装 DTK 25.04.2 或更高版本,或使用 OneScience 推荐且与当前集群匹配的版本。
软件要求
DiffDock 的常用依赖包括 PyTorch、PyTorch Geometric、RDKit、OpenBabel、e3nn、torch-scatter、torch-cluster、NumPy、SciPy、tqdm 和 PyYAML 等。数据集评估中的 GNINA 能量最小化需要另行安装 gnina。
环境检查
- NVIDIA GPU
nvidia-smi
- Hygon DCU
hy-smi
快速开始
1. 安装运行环境
conda create -n onescience311 python=3.11 -y
conda activate onescience311
pip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
若以下代码运行时找不到所需的库,请按下方方式激活 CUDA。
source ${ROCM_PATH}/cuda/env.sh
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$CONDA_PREFIX/lib/python3.11/site-packages/fastpt/torch/lib:$LD_LIBRARY_PATH"
2. 下载模型包和数据库
# If the model ID on the Hugging Face page uses different capitalization, use the actual published name.
hf download OneScience-Group/diffdock --local-dir ./diffdock
cd diffdock
训练权重与数据集
目前尚无可用权重和数据集。它们将于近期上传至 Hugging Face,随后将支持通过命令行下载。
3. 检查包内文件
当前模型包不包含预训练权重。以下命令应仅显示源代码、配置文件和示例输入文件。
find . -maxdepth 3 -type f
如需采样或评估,请先通过训练获得模型权重(检查点),或将外部 DiffDock 得分模型和置信度模型的权重放在本地目录。请确保该权重目录包含 model_parameters.yml。
4. 得分模型训练
训练前,将 configs/training.yml 中的数据路径更新为本地路径。常用字段包括以下几项。
data.pdbbind_dir,预处理后的 PDBBind 数据目录。data.moad_dir,预处理后的 MOAD 数据目录。data.split_train,训练集复合物列表。data.split_val,验证集复合物列表。runtime.log_dir,训练输出目录。
开始训练。
cd scripts
bash train.sh
训练成功后,输出目录通常包含以下文件。
model_parameters.yml,模型架构和训练参数。best_model.pt,验证损失最小的权重。best_ema_model.pt,EMA 权重。best_inference_epoch_model.pt或best_ema_inference_epoch_model.pt,启用推理(inference)验证时保存的权重。last_model.pt,最后一轮的训练状态。
5. 分子对接采样
采样需要一个已训练得分模型的目录,示例如下。
outputs/train/diffdock_cg_example/
├── model_parameters.yml
└── best_model.pt
将 configs/sampling.yml 中的关键字段更新为实际路径。
model.model_dir,得分模型目录。model.ckpt,得分模型权重(检查点)文件名。confidence.confidence_model_dir,置信度模型目录,未使用重排序时设为null。input.protein_path,蛋白质 PDB 路径。可以使用data/6o5u_protein_processed.pdb。input.ligand_description,SMILES 字符串或配体 SDF/MOL2 文件路径。可以使用data/6o5u_ligand.sdf。runtime.out_dir,采样输出目录。
启动单个复合物的采样。
cd scripts
bash infer.sh
6. CSV 批量采样
将 input.protein_ligand_csv(位于 configs/sampling.yml)设置为 CSV 文件路径,并根据需要将单个复合物字段设为 null。建议 CSV 文件包含以下列。
complex_name,protein_path,ligand_description,protein_sequence
此处,ligand_description 可以是 SMILES 字符串,也可以是 SDF/MOL2 文件路径。
7. 数据集评估
评估前,请将 configs/evaluate.yml 中的数据集、模型和输出目录更新为实际路径。
python -m scripts.evaluate --config configs/evaluate.yml
若启用了 gnina.gnina_minimize=true,请先确认以下命令可在当前环境直接运行。
gnina --help
8. 置信度模型训练
安装的 OneScience 软件包提供置信度训练入口。本 Hugging Face 模型包不重复提供该模块。完成得分模型训练后,在 OneScience 环境中运行以下命令。
python -m onescience.confidence.diffdock.confidence_train \
--original_model_dir outputs/train/diffdock_cg_example \
--data_dir /path/to/PDBBind_processed \
--split_train /path/to/splits/timesplit_no_lig_overlap_train \
--split_val /path/to/splits/timesplit_no_lig_overlap_val
数据准备
DiffDock 训练通常需要预处理的 PDBBind 或 MOAD 数据。建议将数据统一组织在同一个根目录下,示例如下。
${ONESCIENCE_DATASETS_DIR}/diffdock/
├── PDBBind_processed/
├── MOAD_processed/
└── splits/
├── timesplit_no_lig_overlap_train
├── timesplit_no_lig_overlap_val
└── timesplit_test
划分文件应为纯文本文件,每行一个复合物名称。每个名称必须与数据目录中的一个子目录名称对应。
OneScience 官方信息
| 平台 | OneScience 主仓库 | Skills 仓库 |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
引用与许可证
- 原始 DiffDock 代码采用 MIT License 授权。本仓库保留来源署名,并按 OneScience Hugging Face 自动化运行场景组织。
- 如果在研究中使用 DiffDock 结果,建议引用 DiffDock 和 DiffDock-L 原始论文以及相关 OneScience 项目信息。请根据实际任务补充引用 PDBBind、MOAD、RDKit、OpenBabel 和 GNINA 等数据集或工具。
@inproceedings{corso2023diffdock,
title={DiffDock: Diffusion Steps, Twists, and Turns for Molecular Docking},
author={Corso, Gabriele and St{\"a}rk, Hannes and Jing, Bowen and Barzilay, Regina and Jaakkola, Tommi},
booktitle={International Conference on Learning Representations},
year={2023}
}
- Downloads last month
- 39