How gcorso/diffdock works
Project Type and Purpose
• DiffDock is an open-source, research‐grade machine learning tool for molecular docking.
• It provides both training and inference pipelines for a diffusion‐based docking model (original & “L”), plus a simple web UI.
• Key use cases: model training (train.py), evaluation (evaluate.py), batch & single‐complex inference (inference.py), GUI application (app/main.py).
File-Structure Analysis
Top-level directories and files:
• app/ ← Web UI (Gradio)
• confidence/ ← Confidence‐score model and data processing
• data/ ← Raw & processed datasets, train/val/test splits
• datasets/ ← Dataset builders & ESM embedding preprocessing
• examples/ ← Sample PDB/SDF inputs for inference
• models/ ← Neural network definitions (AA, CG, layers)
• spyrmsd/ ← Integrated RMSD library (graph algorithms, IO)
• utils/ ← Helper functions (geometry, sampling, I/O, logging)
• train.py / evaluate.py / inference.py ← Entrypoints
• Dockerfile, environment.yml ← Deployment & environment specs
README Insights
• Describes deployment options: Conda env vs Docker.
• Highlights external dependencies: ESM‐based protein embeddings, RDKit/OBabel, GPU (CUDA).
• Specifies two modes: CLI batch inference & GUI.
Main Components and Their Interactions
A. Data Layer
1. Raw inputs: PDB files, SDF/MOL2 ligands, SMILES strings
2. Preprocessing:
– ESM embedding preparation (datasets/esm_embedding_preparation.py → FASTA → ESM2 → embeddings pt)
– Data splits & caching in data/
– RMSD calculations via spyrmsd
B. Model Layer
1. Neural nets (models/): coarse‐grained (CG) & all-atom (AA) diffusion models
2. Tensor layers & custom SO(3)/SE(3) operations (models/tensor_layers.py)
3. Confidence head (confidence/confidence_train.py)
C. Training & Evaluation
1. train.py: orchestrates data loading (datasets/, data/), model instantiation, optimizer, training loop (utils/training.py), logging (utils/logging_utils.py)
2. evaluate.py: uses saved checkpoints + default_inference_args.yaml to benchmark on splits
D. Inference & Application
1. inference.py: CLI entrypoint for batch & single‐complex docking
2. app/main.py + mol_viewer.py + run_utils.py: Gradio‐based GUI, molecule visualization
E. Deployment & Environment
1. Conda (environment.yml)
2. Docker: top‐level Dockerfile + app/Dockerfile for building reproducible containers
Architectural Patterns & Design Principles
• Modular design: clear separation of data ingestion, model definition, training, inference, and UI.
• Layered architecture:
• Data layer → Model layer → Application layer → Presentation layer
• Extensibility:
• “datasets/” can be extended to new sources; “models/” can host new architectures; “app/” can be swapped for other UIs.
• Dependency‐injection via config files (default_inference_args.yaml).