Communitygithub.com

diffdock

利用擴散模型進行分子對接:從 PDB 或序列,搭配 SMILES/SDF/MOL2 檔案,預測蛋白質與小分子的結合構形。支援批次對接、虛擬篩選與信心分數解讀。不適用於結合親和力預測。

diffdock 是什麼?

DiffDock 是一款基於擴散模型的深度學習分子對接工具,能預測小分子配體與蛋白質目標的 3D 結合構形,是結構基礎藥物發現與化學生物學中的最先進技術。使用者可從 PDB 檔案或蛋白質序列(透過 ESMFold)輸入蛋白質,並以 SMILES、SDF 或 MOL2 格式提供配體,即可執行單一複合物對接或大規模虛擬篩選。此技能會產生多個預測構形,並附帶信心分數(DiffDock-L 模型),協助使用者評估預測可靠性。重要的是,DiffDock 預測的是結合構形與信心度,而非結合親和力(ΔG、Kd),因此建議將產生的構形搭配 GNINA 或 MM/GBSA 等評分函數進行親和力評估。此技能支援 GPU 加速(建議使用)、批次處理、蛋白質構形集合對接,並可與其他計算工具整合。

相容平台~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:批次處理多個複合物

使用案例: 將多個配體對接到多個蛋白質,虛擬篩選任務

步驟 1:準備批次 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 則留空)

步驟 2:執行批次對接

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 個預測,尋找一致結果

詳細指南請參閱: 使用讀取工具閱讀 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. 剛性配體:降低扭轉溫度

完整參數參考請參閱: 使用讀取工具閱讀 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 個殘基)→ 請使用其他方法
  • 共價對接 → 請使用專用共價對接工具
  • 結合親和力預測 → 請搭配評分函數使用
  • 膜蛋白 → 未經專門訓練,請謹慎使用

完整限制說明請參閱: 使用讀取工具閱讀 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

圖形使用者介面

如需互動操作,請啟動網頁介面:

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:批次輸入 CSV 範本

custom_inference_config.yaml:自訂推論設定範本

參考文獻

@article{corso2022diffdock,
  title={DiffDock: Diffusion Steps, Twists, and Turns for Molecular Docking},
  author={Corso, Gabriele and Stärk, Hannes and Jing, Bowen and Barzilay, Regina and Jaakkola, Tommi},
  journal={International Conference on Learning Representations (ICLR)},
  year={2023}
}

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.

相關技能