Communitygithub.com

DiffDock 分子对接

使用扩散模型 (DiffDock / DiffDock-L) 进行蛋白质-小分子结合构象预测。支持 PDB 文件或氨基酸序列输入,兼容 SMILES、SDF、MOL2 等小分子格式。可用于批量对接、虚拟筛选与构象置信度分析。不与结合亲和力预测混淆。

DiffDock 分子对接 是什么?

DiffDock 是一种基于扩散模型的分子对接工具,通过深度学习预测小分子配体与蛋白质靶标的 3D 结合构象。它代表了当前计算对接领域的最新技术水平,在基于结构的药物发现与化学生物学中发挥关键作用。该工具支持从 PDB 文件获取蛋白质结构,或通过 ESMFold 从序列生成结构;配体输入则支持 SMILES 字符串或 SDF、MOL2 文件。它既可以处理单个复合物的对接,也能进行大规模虚拟筛选(批量处理)。输出包括多个可能的结合构象,并为每个构象提供置信度分数,帮助用户评估预测的可靠性。但 DiffDock **不**预测结合亲和力(如 ΔG 或 Kd),需要与 GNINA 或 MM/GBSA 等评分函数配合使用以评估亲和力。该工具强烈建议使用 GPU 运行,首次运行时会预计算 SO(2)/SO(3) 查找表。它适合对接药物样小分子(100–1000 Da),不支持蛋白质-蛋白质对接、大肽段(>20 个残基)或共价对接。DiffDock 可在命令行和 Web 界面(支持 Gradio)上运行,并提供丰富的辅助脚本用于结果分析与环境检查。

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/K-Dense-AI/scientific-agent-skills/tree/main/skills/diffdock

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

DiffDock:基于扩散模型的分子对接

概述

DiffDock 是一种基于扩散模型的深度学习分子对接工具,用于预测小分子配体与蛋白质靶标的 3D 结合构象。它代表了当前计算对接领域的最新水平,在基于结构的药物发现和化学生物学中至关重要。

核心能力:

  • 利用深度学习高精度预测配体结合构象
  • 支持蛋白质结构(PDB 文件)或序列(通过 ESMFold)
  • 处理单个复合物或批量虚拟筛选
  • 生成置信度分数以评估预测可靠性
  • 处理多种配体输入(SMILES、SDF、MOL2)

关键区别: DiffDock 预测的是结合构象(3D 结构)和置信度(预测确定性),而不是结合亲和力(ΔG、Kd)。务必结合评分函数(如 GNINA、MM/GBSA)进行亲和力评估。

何时使用该技能

该技能适用于以下情况:

  • “将该配体对接至蛋白质”或“预测结合构象”
  • “运行分子对接”或“执行蛋白质-配体对接”
  • “虚拟筛选”或“筛选化合物库”
  • “该分子结合在何处?”或“预测结合位点”
  • 基于结构的药物设计或先导化合物优化任务
  • 涉及 PDB 文件 + SMILES 字符串或配体结构的任务
  • 多个蛋白质-配体对的批量对接

安装与环境设置

检查环境状态

在执行 DiffDock 任务之前,请验证环境设置:

# 使用提供的设置检查脚本
python scripts/setup_check.py

该脚本验证 Python 版本、PyTorch 及 CUDA、PyTorch Geometric、RDKit、ESM 及其他依赖项。

安装选项

选项 1:Conda(推荐)

git clone https://github.com/gcorso/DiffDock.git
cd DiffDock
conda env create --file environment.yml
conda activate diffdock

选项 2:Docker

docker pull rbgcsail/diffdock
docker run -it --gpus all --entrypoint /bin/bash rbgcsail/diffdock
micromamba activate diffdock

重要提示:

  • 强烈建议使用 GPU(比 CPU 快 10–100 倍)
  • 首次运行会预计算 SO(2)/SO(3) 查找表(约 2–5 分钟)
  • 模型检查点(约 500MB)会自动下载(如果不存在)
  • 当前上游版本为 DiffDock v1.1.3;default_inference_args.yaml 中默认使用 DiffDock-L 模型

核心工作流

工作流 1:单个蛋白质-配体对接

应用场景: 将一个配体对接至一个蛋白质靶标

输入要求:

  • 蛋白质:PDB 文件或氨基酸序列
  • 配体:SMILES 字符串或结构文件(SDF/MOL2)

命令:

python -m inference \
  --config default_inference_args.yaml \
  --protein_path protein.pdb \
  --ligand_description "CC(=O)Oc1ccccc1C(=O)O" \
  --out_dir results/single_docking/

替代方案(蛋白质序列):

python -m inference \
  --config default_inference_args.yaml \
  --protein_sequence "MSKGEELFTGVVPILVELDGDVNGHKF..." \
  --ligand_description ligand.sdf \
  --out_dir results/sequence_docking/

输出结构:

results/single_docking/
└── complex_0/
    ├── rank1.sdf                    # 排名第一的构象的便捷副本
    ├── rank1_confidence0.87.sdf     # 排名第一的构象,文件名包含置信度
    ├── rank2_confidence0.42.sdf     # 排名第二的构象
    ├── ...
    └── rank10_confidence-1.23.sdf   # 第 10 个构象(默认:10 个样本)

当前 inference.py 注册了 --ligand_description 用于单复合物运行。部分上游 README 文本仍显示 --ligand;请使用 --ligand_description,除非您的本地代码明确支持 --ligand 别名。

工作流 2:批量处理多个复合物

应用场景: 对接多个配体至蛋白质,虚拟筛选活动

第一步:准备批处理 CSV

使用提供的脚本创建或验证批处理输入:

# 创建模板
python scripts/prepare_batch_csv.py --create --output batch_input.csv

# 验证现有 CSV
python scripts/prepare_batch_csv.py my_input.csv --validate

CSV 格式:

complex_name,protein_path,ligand_description,protein_sequence
complex1,protein1.pdb,CC(=O)Oc1ccccc1C(=O)O,
complex2,,COc1ccc(C#N)cc1,MSKGEELFT...
complex3,protein3.pdb,ligand3.sdf,

必需列:

  • complex_name:唯一标识符
  • protein_path:PDB 文件路径(如果使用序列,则留空)
  • ligand_description:SMILES 字符串或配体文件路径
  • protein_sequence:氨基酸序列(如果使用 PDB,则留空)

第二步:运行批量对接

python -m inference \
  --config default_inference_args.yaml \
  --protein_ligand_csv batch_input.csv \
  --out_dir results/batch/ \
  --batch_size 10

对于大型虚拟筛选(>100 个化合物):

预先计算蛋白质嵌入以加快处理速度:

# 预先计算嵌入
python datasets/esm_embedding_preparation.py \
  --protein_ligand_csv screening_input.csv \
  --out_file protein_embeddings.pt

# 使用预先计算的嵌入运行
python -m inference \
  --config default_inference_args.yaml \
  --protein_ligand_csv screening_input.csv \
  --esm_embeddings_path protein_embeddings.pt \
  --out_dir results/screening/

工作流 3:分析结果

对接完成后,分析置信度分数并排序预测结果:

# 分析所有结果
python scripts/analyze_results.py results/batch/

# 每个复合物显示前 5 个
python scripts/analyze_results.py results/batch/ --top 5

# 根据置信度阈值筛选
python scripts/analyze_results.py results/batch/ --threshold 0.0

# 导出至 CSV
python scripts/analyze_results.py results/batch/ --export summary.csv

# 显示所有复合物中前 20 个最佳预测
python scripts/analyze_results.py results/batch/ --best 20

分析脚本将:

  • 解析所有预测的置信度分数
  • 分类为高(>0)、中等(-1.5 至 0)或低(<-1.5)
  • 在复合物内部和跨复合物之间对预测进行排序
  • 生成统计摘要
  • 将结果导出至 CSV 供下游分析

置信度分数解读

理解分数:

分数范围置信度等级解读
> 0高强预测,很可能准确
-1.5 至 0中等合理预测,需仔细验证
< -1.5低不确定预测,需要验证

关键说明:

  1. 置信度 ≠ 亲和力:高置信度仅表示模型对结构的确定性,而非强结合
  2. 背景很重要:根据以下情况调整期望:
    • 大配体(>500 Da):置信度预期较低
    • 多个蛋白质链:可能降低置信度
    • 新型蛋白质家族:可能表现不佳
  3. 多个样本:查看前 3–5 个预测,寻找一致性

详细指导: 使用 Read 工具阅读 references/confidence_and_limitations.md

参数定制

使用自定义配置

为特定用例创建自定义配置:

# 复制模板
cp assets/custom_inference_config.yaml my_config.yaml

# 编辑参数(参见模板中的预设)
# 然后使用自定义配置运行
python -m inference \
  --config my_config.yaml \
  --protein_ligand_csv input.csv \
  --out_dir results/

要调整的关键参数

采样密度:

  • samples_per_complex: 10 → 对于困难情况增加至 20–40
  • 更多样本 = 更好的覆盖范围,但运行时间更长

推理步骤:

  • inference_steps: 20 → 增加至 25–30 以提高精度
  • 更多步骤 = 可能更好的质量,但速度更慢

温度参数(控制多样性):

  • temp_sampling_tor: 7.04 → 对于柔性配体增加(8–10)
  • temp_sampling_tor: 7.04 → 对于刚性配体减少(5–6)
  • 更高的温度 = 更多样的构象

模板中可用的预设:

  1. 高精度:更多样本 + 步骤,较低温度
  2. 快速筛选:更少样本,更快
  3. 柔性配体:增加扭转温度
  4. 刚性配体:降低扭转温度

完整的参数说明: 使用 Read 工具阅读 references/parameters_reference.md

高级技术

集成对接(蛋白质柔性)

对于已知柔性的蛋白质,对接至多个构象:

# 创建集成 CSV
import pandas as pd

conformations = ["conf1.pdb", "conf2.pdb", "conf3.pdb"]
ligand = "CC(=O)Oc1ccccc1C(=O)O"

data = {
    "complex_name": [f"ensemble_{i}" for i in range(len(conformations))],
    "protein_path": conformations,
    "ligand_description": [ligand] * len(conformations),
    "protein_sequence": [""] * len(conformations)
}

pd.DataFrame(data).to_csv("ensemble_input.csv", index=False)

增加采样量后运行对接:

python -m inference \
  --config default_inference_args.yaml \
  --protein_ligand_csv ensemble_input.csv \
  --samples_per_complex 20 \
  --out_dir results/ensemble/

与评分函数集成

DiffDock 生成构象;与其他工具结合评估亲和力:

GNINA(快速神经网络评分):

for pose in results/single_docking/complex_0/*confidence*.sdf; do
    gnina -r protein.pdb -l "$pose" --score_only
done

MM/GBSA(更准确,更慢): 在能量最小化后使用 AmberTools MMPBSA.py 或 gmx_MMPBSA

自由能计算(最准确): 使用 OpenMM + OpenFE 或 GROMACS 进行 FEP/TI 计算

推荐工作流:

  1. DiffDock → 生成带有置信度分数的构象
  2. 视觉检查 → 检查结构合理性
  3. GNINA 或 MM/GBSA → 根据亲和力重新评分和排序
  4. 实验验证 → 生化检测

局限性与范围

DiffDock 设计用于:

  • 小分子配体(通常 100–1000 Da)
  • 药物样有机化合物
  • 小肽(<20 个残基)
  • 单链或多链蛋白质

DiffDock 不适用于:

  • 大生物分子(蛋白质-蛋白质对接)→ 使用 DiffDock-PP 或 AlphaFold-Multimer
  • 大肽(>20 个残基)→ 使用其他方法
  • 共价对接 → 使用专用共价对接工具
  • 结合亲和力预测 → 与评分函数结合使用
  • 膜蛋白 → 未经专门训练,谨慎使用

完整局限性: 使用 Read 工具阅读 references/confidence_and_limitations.md

故障排除

常见问题

问题:所有预测的置信度分数均较低

  • 原因:大/异常配体、结合位点不明确、蛋白质柔性
  • 解决方案:增加 samples_per_complex(20–40),尝试集成对接,验证蛋白质结构

问题:内存不足错误

  • 原因:GPU 内存不足以处理批次大小
  • 解决方案:减少 --batch_size 2 或一次处理更少的复合物

问题:性能缓慢

  • 原因:在 CPU 而非 GPU 上运行
  • 解决方案:使用 python -c "import torch; print(torch.cuda.is_available())" 验证 CUDA,使用 GPU

问题:不切实际的结合构象

  • 原因:蛋白质准备不良、配体过大、结合位点错误
  • 解决方案:检查蛋白质是否有缺失残基,移除远处的水分子,考虑指定结合位点

问题:“模块未找到”错误

  • 原因:缺少依赖项或环境错误
  • 解决方案:运行 python scripts/setup_check.py 进行诊断

性能优化

为获得最佳结果:

  1. 使用 GPU(对实际使用至关重要)
  2. 对重复使用的蛋白质预先计算 ESM 嵌入
  3. 批量处理多个复合物
  4. 从默认参数开始,然后根据需要调整
  5. 验证蛋白质结构(解析缺失残基)
  6. 使用配体的规范 SMILES

图形用户界面

如需交互式使用,启动 Web 界面:

python app/main.py
# 导航至 http://localhost:7860

或无需安装即可使用在线演示:

资源

辅助脚本(scripts/)

prepare_batch_csv.py:创建和验证批处理输入 CSV 文件

  • 使用示例条目创建模板
  • 验证文件路径和 SMILES 字符串
  • 检查必需列和格式问题

analyze_results.py:分析置信度分数并排序预测结果

  • 解析单次或批量运行的结果
  • 生成统计摘要
  • 导出至 CSV 供下游分析
  • 识别跨复合物的最佳预测

setup_check.py:验证 DiffDock 环境设置

  • 检查 Python 版本和依赖项
  • 验证 PyTorch 和 CUDA 的可用性
  • 测试 RDKit 和 PyTorch Geometric 安装
  • 在需要时提供安装说明

参考文档(references/)

parameters_reference.md:完整的参数文档

  • 所有命令行选项和配置参数
  • 默认值和可接受范围
  • 控制多样性的温度参数
  • 模型检查点位置和版本标志

当用户需要时阅读此文件:

  • 详细的参数说明
  • 针对特定系统的微调指导
  • 替代采样策略

confidence_and_limitations.md:置信度分数解读和工具局限性

  • 详细的置信度分数解读
  • 何时信任预测
  • DiffDock 的范围和局限性
  • 与互补工具的集成
  • 预测质量故障排除

当用户需要时阅读此文件:

  • 帮助解读置信度分数
  • 了解何时不使用 DiffDock
  • 与其他工具结合的指导
  • 验证策略

workflows_examples.md:全面的工作流示例

  • 详细的安装说明
  • 所有工作流的分步示例
  • 高级集成模式
  • 常见问题故障排除
  • 最佳实践和优化技巧

当用户需要时阅读此文件:

  • 包含代码的完整工作流示例
  • 与 GNINA、OpenMM 或其他工具的集成
  • 虚拟筛选工作流
  • 集成对接流程

资产(assets/)

batch_template.csv:模板

……(为翻译而截断)

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

adaptyv

How to use the Adaptyv Bio Foundry API and Python SDK for protein experiment design, submission, and results retrieval. Use this skill whenever the user mentions Adaptyv, Foundry API, protein binding assays, protein screening experiments, BLI/SPR assays, thermostability assays, or wants to submit protein sequences for experimental characterization. Also trigger when code imports `adaptyv`, `adaptyv_sdk`, or `FoundryClient`, or references `foundry-api-public.adaptyvbio.com`.

aeon

This skill should be used for time series machine learning tasks including classification, regression, clustering, forecasting, anomaly detection, segmentation, and similarity search. Use when working with temporal data, sequential patterns, or time-indexed observations requiring specialized algorithms beyond standard ML approaches. Particularly suited for univariate and multivariate time series analysis with scikit-learn compatible APIs.

alphagenome

Look up precomputed AlphaGenome Atlas effects for any GRCh38 single-nucleotide variant (AVI score with Phred and 18 SHAP feature attributions, plus raw and quantile scores for RNA-seq, DNase, ATAC, ChIP-TF, ChIP-histone, CAGE, PRO-cap, splicing, polyadenylation and contact-map tracks), score variants or scan windows on demand with the AlphaGenome model for human and mouse (variant scoring, in silico mutagenesis, REF-versus-ALT track prediction), and build Atlas website deep links. Use when the user mentions AlphaGenome, AlphaGenome Atlas, AVI or AlphaGenome Variant Impact, DeepMind variant effect prediction, or wants to prioritise or mechanistically interpret non-coding, regulatory, splicing, enhancer, promoter, or chromatin-accessibility effects of SNVs from a VCF, credible set, or region. Research use only; not a clinical tool.

analytical-method-validation

Plan, execute, and document validation, verification, and transfer of analytical procedures under the governing framework - ICH Q2(R2) and Q14, USP <1220>/<1225>/<1226>, ICH M10 bioanalytical, CLSI EP, or ISO/IEC 17025. Use for HPLC, LC-MS/MS, GC, CE, ICP-MS, dissolution, qNMR, qPCR, NIR, and ligand binding or cell-based assays whenever the question is whether a procedure is fit for its intended purpose. Triggers include

anndata

Data structure for annotated matrices in single-cell analysis. Use when working with .h5ad files or integrating with the scverse ecosystem. This is the data format skill—for analysis workflows use scanpy; for probabilistic models use scvi-tools; for population-scale queries use cellxgene-census.

arbor

Autonomously improve a real artifact (code, training recipe, agent harness, data pipeline, prompt) against an objective and an evaluator, using Hypothesis Tree Refinement (HTR) from the Arbor paper. Use this whenever someone wants to iteratively optimize something over many experiments without overfitting — e.g.

arboreto

Infer gene regulatory networks (GRNs) from gene expression data using scalable algorithms (GRNBoost2, GENIE3). Use when analyzing transcriptomics data (bulk RNA-seq, single-cell RNA-seq) to identify transcription factor-target gene relationships and regulatory interactions. Supports distributed computation for large-scale datasets.

astropy

Core Python library for astronomy and astrophysics workflows that need Astropy APIs, including units/quantities, coordinates, FITS I/O, tables, time systems, WCS, and cosmology. Use when implementing or debugging astronomical data analysis code with Astropy.

autoskill

Observe the user

benchling-integration

Benchling Python SDK and REST API integration for registry entities, inventory, ELN entries, workflows, Benchling Apps, and Data Warehouse queries. Use when automating lab data with benchling-sdk or the v2 API.

bgpt-paper-search

Search scientific papers and retrieve structured experimental data extracted from full-text studies via the BGPT MCP server. Returns 25+ fields per paper including methods, results, sample sizes, quality scores, and conclusions. Use for literature reviews, evidence synthesis, and finding experimental details not available in abstracts alone.

bids

>

biopython

Comprehensive molecular biology toolkit. Use for sequence manipulation, file parsing (FASTA/GenBank/PDB), phylogenetics, and programmatic NCBI/PubMed access (Bio.Entrez). Best for batch processing, custom bioinformatics pipelines, BLAST automation. For quick lookups use gget; for multi-service integration use bioservices.

bioservices

Unified Python interface to 40+ bioinformatics services. Use when querying multiple databases (UniProt, KEGG, ChEMBL, Reactome) in a single workflow with consistent API. Best for cross-database analysis, ID mapping across services. For quick single-database lookups use gget; for sequence/file manipulation use biopython.

bulk-rnaseq

End-to-end bulk RNA-seq orchestrator — takes raw FASTQ reads through QC and trimming (FastQC, fastp/Trim Galore), alignment and quantification (STAR, Salmon, featureCounts), assembles a gene-level counts matrix, then hands off to differential expression (pydeseq2), pathway/GSEA enrichment (pathway-enrichment), and publication figures (scientific-visualization). Use whenever the user has bulk RNA-seq reads or quant output and wants a complete, reproducible differential-expression workflow — e.g.

cellxgene-census

Query the CZ CELLxGENE Census programmatically for versioned public single-cell and spatial transcriptomics data. Use when you need population-scale cell metadata, gene expression slices, Census summary counts, source H5AD URIs/downloads, embeddings, spatial Census data, or reference atlas comparisons across organisms, tissues, diseases, assays, and cell types. For analyzing your own local single-cell data use scanpy, anndata, or scvi-tools.

cirq

Google quantum computing framework. Use when targeting Google Quantum AI hardware, designing noise-aware circuits, or running quantum characterization experiments. Best for Google hardware, noise modeling, and low-level circuit design. For IBM hardware use qiskit; for quantum ML with autodiff use pennylane; for physics simulations use qutip.

citation-management

Comprehensive citation management for academic research. Search OpenAlex, PubMed, and Google Scholar for papers, extract accurate metadata, validate citations, and generate properly formatted BibTeX entries. This skill should be used when you need to find papers, verify citation information, convert DOIs to BibTeX, or ensure reference accuracy in scientific writing.

clinical-decision-support

Prepare and validate research-only clinical decision-support evaluation, evidence-profile, cohort, survival, biomarker/model, privacy, and governance artifacts. Use for aggregate or synthetic research documentation and traceability—not patient care or live clinical operation.

clinical-reports

Create safety-bounded draft structures and run local deterministic checks for clinical case, diagnostic, trial, safety, and aggregate research reports. Use only with synthetic, de-identified, or aggregate inputs and verified source-fact manifests; every output requires qualified review.

相关技能