How hannesstark/boltzgen works
Purpose and Entry Points
BoltzGen is a Python/GPU molecular-binder design system. It generates candidate protein or peptide backbones, designs sequences, refolds and evaluates them, then selects a quality- and diversity-ranked output set. User-facing commands are implemented in src/boltzgen/cli/boltzgen.py; pipeline orchestration starts in src/boltzgen/task/task.py. Training has a separate config-driven entry point at src/boltzgen/resources/main.py.
Specification-to-Model Input
Design YAML files define target structures, designed chains, ligands, binding regions, structural visibility, and bonds. Prediction loaders convert those specifications or prior generated artifacts into model-ready data:
• src/boltzgen/task/predict/data_from_yaml.py
• src/boltzgen/task/predict/data_from_generated.py
• src/boltzgen/task/predict/data_ligands.py
The input boundary accepts local PDB/mmCIF files and YAML-relative paths; molecule definitions may come from a downloaded molecular dictionary.
Structural Data Pipeline
The data layer parses structures and produces token-, feature-, and template-based representations consumed by models. It also handles cropping, padding, selection, and structure serialization:
• src/boltzgen/data/parse/mmcif.py
• src/boltzgen/data/tokenize/tokenizer.py
• src/boltzgen/data/feature/featurizer.py
Generated and refolded structures are emitted as mmCIF/PDB plus NPZ metadata through src/boltzgen/data/write/mmcif.py and src/boltzgen/data/write/pdb.py.
Generative Design and Inverse Folding
The design stage uses a Boltz-based neural architecture: a trunk encodes single/pair structural representations and a diffusion module samples designed backbone geometry. Sequence generation is then handled by inverse folding, including residue-constraint masks.
• src/boltzgen/model/models/boltz.py
• src/boltzgen/model/modules/trunk.py
• src/boltzgen/model/modules/diffusion.py
• src/boltzgen/model/modules/inverse_fold.py
This is the central model boundary: structured features enter the model; candidate backbone/sequence artifacts leave it for downstream validation.
Refolding, Affinity, and Analysis
Candidate designs are refolded as complexes, and optionally as isolated binders; small-molecule protocols additionally invoke affinity prediction. Analysis computes structural and interface quality metrics over refolded outputs.
• src/boltzgen/task/predict/predict.py
• src/boltzgen/task/analyze/analyze.py
• src/boltzgen/model/modules/affinity.py
Protocol defaults determine whether isolated design folding and affinity are run. Refolded complex CIFs are the primary analysis/filtering input.
Filtering and Final Selection
Filtering applies metric thresholds and composition/quality rules, ranks survivors, then performs diversity-aware selection within the requested budget. It can be rerun independently against existing analysis artifacts.
• src/boltzgen/task/filter/filter.py
• src/boltzgen/data/filter/dynamic/filter.py
• src/boltzgen/data/sample/cluster.py
The resulting output boundary is final_ranked_designs, containing selected CIFs, metric CSVs, and overview plots.
Runtime, Configuration, and External Dependencies
Python 3.11+ runs the package; GPU execution is expected for practical design workloads, with Docker and SLURM deployment paths (Dockerfile, slurm-example/run_job_array.slurm). Step and protocol configuration is resource-backed:
• src/boltzgen/resources/config/design.yaml
• src/boltzgen/resources/config/fold.yaml
• src/boltzgen/resources/config/filtering.yaml
Model checkpoints, inference molecule data, and training datasets are downloaded from Hugging Face and cached locally. Training uses multi-GPU configurations and includes optimizer/EMA support in src/boltzgen/model/optim/.
Main entry points: tokenizer.py Structure tokenizer · task.py Pipeline orchestration · data_from_yaml.py Design YAML loader · predict.py Complex refolding
Components 21
Entry & orchestration
- BoltzGen CLI
src/boltzgen/cli/boltzgen.py - Pipeline orchestration
src/boltzgen/task/task.py
Input preparation
- Design YAML loader · Builds prediction input from target and design specifications.
src/boltzgen/task/predict/data_from_yaml.py - Generated artifact loader
src/boltzgen/task/predict/data_from_generated.py - Ligand data loader · Resolves ligand and molecular-dictionary data.
src/boltzgen/task/predict/data_ligands.py - Structure parser
src/boltzgen/data/parse/mmcif.py - Structure tokenizer
src/boltzgen/data/tokenize/tokenizer.py - Feature pipeline · Builds token, template, crop, padding, and selection features.
src/boltzgen/data/feature/featurizer.py
Design model
- Boltz design model · Transforms structured features into candidate backbone and sequence artifacts.
src/boltzgen/model/models/boltz.py - Structural trunk · Encodes single and pair structural representations.
src/boltzgen/model/modules/trunk.py - Backbone diffusion
src/boltzgen/model/modules/diffusion.py - Inverse folding · Generates sequences with residue-constraint masks.
src/boltzgen/model/modules/inverse_fold.py - Structure artifacts · Writes generated and refolded structures with metadata.
src/boltzgen/data/write/mmcif.py
Validation & selection
- Complex refolding · Refolds candidates as complexes and optionally isolated binders.
src/boltzgen/task/predict/predict.py - Affinity prediction · Optional protocol stage for small-molecule designs.
src/boltzgen/model/modules/affinity.py - Structure analysis · Computes structural and interface metrics from refolded complexes.
src/boltzgen/task/analyze/analyze.py - Filter and rank · Applies quality/composition rules and ranks survivors.
src/boltzgen/task/filter/filter.py - Metric threshold rules
src/boltzgen/data/filter/dynamic/filter.py - Diversity clustering · Selects diverse designs within the requested budget.
src/boltzgen/data/sample/cluster.py - final_ranked_designs · Selected CIFs, metric CSVs, and overview plots.
Training
- Training entry point · Runs multi-GPU training with optimizer and EMA support.
src/boltzgen/resources/main.py
Connections 23
- BoltzGen CLI → Pipeline orchestration: starts
- Pipeline orchestration → Design YAML loader: loads design specs
- Pipeline orchestration → Generated artifact loader: reloads artifacts
- Design YAML loader → Ligand data loader: resolves ligands
- Design YAML loader → Structure parser: reads target structures
- Generated artifact loader → Structure tokenizer: prepares prior designs
- Structure parser → Structure tokenizer: structures
- Ligand data loader → Structure tokenizer: molecules
- Structure tokenizer → Feature pipeline: tokens
- Feature pipeline → Boltz design model: structured features
- Boltz design model → Structural trunk: encodes
- Structural trunk → Backbone diffusion: representations
- Backbone diffusion → Inverse folding: backbone
- Inverse folding → Structure artifacts: candidate designs
- Structure artifacts → Complex refolding: candidate artifacts
- Complex refolding → Affinity prediction: small-molecule protocol
- Complex refolding → Structure analysis: refolded complex CIFs
- Affinity prediction → Structure analysis: affinity metrics
- Structure analysis → Filter and rank: analysis artifacts
- Filter and rank → Metric threshold rules: applies thresholds
- Metric threshold rules → Diversity clustering: qualified designs
- Diversity clustering → final_ranked_designs: diverse ranked set
- Training entry point → Boltz design model: trains checkpoints