BoltzGen

repository·main·Indexed 21 days ago

https://github.com/hannesstark/boltzgen

A protein design tool (v0.3.2) that utilizes a pipeline of models to generate, fold, and filter protein designs. It supports protocols for protein-protein, peptide, small molecule, and antibody design. The tool uses .yaml specification files to define entities—including proteins, ligands (via CCD or SMILES), and imported .cif structures—and constraints such as covalent bonds, disulfide bridges, and secondary structure requirements.

Tokens
32.4K
Snippets
95
Records
136
Agent score
77%

What's inside boltzgen

  1. Design symmetric complexes (inverse-folding only)

    main

    For symmetric complexes like homo-dimers, you can ensure symmetric sequence generation during the inverse folding step by assigning the same symmetric_group ID to the corresponding chains in the entities section. The protein-redesign protocol supports scoring these complexes without needing separate binders and targets.

    entities:
      - file:
          path: symmetric_dimer.cif
          include:
            - chain:
                id: A
                res_index: 100..300
                symmetric_group: 1
            - chain:
                id: B
                res_index: 100..300
                symmetric_group: 1
          design:
            - chain:
                id: A
                res_index: 200..210
            - chain:
                id: B
                res_index: 200..210
  2. Design specification .yaml indexing rules

    main

    When creating a .yaml design specification, you must use the correct residue indexing:

    CRITICAL: All residue indices must start at 1 and use the canonical mmcif residue index label_asym_id. Do not use auth_asym_id (the author residue index).

    To verify the correct index, open your mmcif file in Mol* and hover over a residue. The index shown in the bottom right is the label_asym_id you should use in your YAML file.

  3. Install and run BoltzGen via Docker

    main

    To use Docker, build the image and run it with volume mounts for your work directory, cache, and examples.

    Build the image:

    docker build -t boltzgen .

    Run an example:

    docker run --rm --gpus all -v "$(realpath workdir)":/workdir -v "$(realpath cache)":/cache -v "$(realpath example)":/example boltzgen \
        boltzgen run /example/vanilla_protein/1g13prot.yaml --output /workdir/test \
     	--protocol protein-anything \
      	--num_designs 2

    Bake model weights into the image at build time:

    docker build -t boltzgen:weights --build-arg DOWNLOAD_WEIGHTS=true .
    docker build -t boltzgen .
    docker run --rm --gpus all -v "$(realpath workdir)":/workdir -v "$(realpath cache)":/cache -v "$(realpath example)":/example boltzgen \
        boltzgen run /example/vanilla_protein/1g13prot.yaml --output /workdir/test \
     	--protocol protein-anything \
      	--num_designs 2
  4. Verify design specification with boltzgen check

    main

    Before running a full design pipeline, verify your .yaml specification using the check command. This ensures your target and binding sites are correctly defined.

    1. Run the check:
      boltzgen check example/vanilla_peptide_with_target_binding_site/beetletert.yaml
    2. Visualize: Open the resulting .mmcif file in a viewer like PyMOL, Chimera, or Mol* (https://molstar.org/viewer/).
    3. Confirm: Ensure the binding site is highlighted in a different color than the rest of the target.
    boltzgen check example/vanilla_peptide_with_target_binding_site/beetletert.yaml
  5. Run BoltzGen design pipeline

    main

    The boltzgen run command processes a .yaml design specification to produce ranked designs.

    Key considerations:

    • Model Weights: Downloads ~6GB to ~/.cache. Use --cache YOUR_PATH or set $HF_HOME to change this.
    • Resuming: If interrupted, use the --reuse flag to restart without losing progress.
    • Design Volume: For production, use --num_designs between 10,000 and 60,000. For testing, start with a small number like 50.
    • Diversity: Use --budget to specify how many designs should be in the final diversity-optimized set.

    Example command:

    boltzgen run example/vanilla_protein/1g13prot.yaml \
      --output workbench/test_run \
      --protocol protein-anything \
      --num_designs 10 \
      --budget 2
  6. Download training data and checkpoints

    main

    BoltzGen requires specific datasets and checkpoints for training. By default, the configuration files expect these to be located in a directory named training_data.

    # Create and enter training directory
    mkdir -p training_data
    cd training_data
    
    # Download Targets
    wget -O targets.zip "https://huggingface.co/datasets/boltzgen/boltzgen1_train/resolve/main/targets.zip?download=true"
    unzip targets.zip      # → training_data/targets/
    
    # Download MSAs
    wget -O msa.zip "https://huggingface.co/datasets/boltzgen/boltzgen1_train/resolve/main/msa.zip?download=true"
    unzip msa.zip          # → training_data/msa/
    
    # Download Small-molecule dictionary
    wget -O mols.zip "https://huggingface.co/datasets/boltzgen/inference-data/resolve/main/mols.zip?download=true"
    mkdir mols && cd mols && unzip ../mols.zip && cd ..
    
    # Download Folding checkpoint
    wget -O boltz2_fold.ckpt "https://huggingface.co/boltzgen/boltzgen-1/resolve/main/boltz2_conf_final.ckpt?download=true"
    
    # (Optional) Download pretrained structure-only checkpoint
    wget -O boltzgen1_structuretrained_small.ckpt "https://huggingface.co/boltzgen/boltzgen-1/resolve/main/boltzgen1_structuretrained_small.ckpt?download=true"
  7. Configure SLURM job submission scripts

    main

    The provided SLURM example requires manual configuration to match your specific cluster environment and analysis task. You must modify the following files:

    • run.sh: The wrapper script used to submit or process jobs.
    • run_job_array.slurm: The SLURM job array definition script.

    Once modified, use bash run.sh submit to start the generation phase and bash run.sh process to execute the merge and filtering phase.

  8. Run BoltzGen on SLURM using job arrays

    main

    To run BoltzGen on a SLURM cluster, use a job array approach where each job handles a small subset of designs. The workflow consists of two main phases:

    1. Generation Phase: Launch a job array of single-GPU jobs. Each job executes boltzgen run to perform the full pipeline (design generation, refolding, etc.) for its assigned subset of designs.
    2. Processing Phase: Once the job array completes, run boltzgen merge on a login node to combine all individual task results, followed by boltzgen run --steps filtering to apply filters to the unified set.

    Note: While this example uses job arrays for many single-GPU jobs, individual BoltzGen pipeline steps (like design generation or refolding) also support parallelization across multiple GPUs within a single step.

    # 1. Submit the job array
    $ bash run.sh submit
    
    # 2. After jobs finish, merge and filter results
    $ bash run.sh process
  9. Generate and execute pre-configured pipelines

    main

    For complex workflows, you can separate configuration generation from execution using configure and execute.

    1. Configure: Use boltzgen configure to create a directory of configuration files based on a design spec without running the pipeline. This allows for manual editing of the generated configs.
    2. Execute: Use boltzgen execute to run the pipeline using the files in the pre-configured directory.

    This pattern is useful for fine-tuning parameters in a controlled environment before committing to a long run.

    # 1. Generate configuration files
    boltzgen configure example/cyclotide/3ivq.yaml \
      --output workbench/test-peptide-protein \
      --protocol peptide-anything \
      --num_designs 2 \
      --reuse
    
    # 2. Run the pre-configured workflow
    boltzgen execute workbench/test-peptide-protein
  10. Install BoltzGen using Miniconda

    main

    For a managed environment, follow these steps:

    1. Install Miniconda for your OS (Windows, macOS, or Linux).
    2. Create a Python 3.12 environment named bg:
      conda create -n bg python=3.12
    3. Activate the environment (required for every new terminal session):
      conda activate bg
    4. Install BoltzGen:
      pip install boltzgen

    Alternatively, to install an editable version from source:

    pip install -e .
    conda create -n bg python=3.12
    conda activate bg
    pip install boltzgen
  11. Create a design specification .yaml file

    main

    BoltzGen uses .yaml files to define design specifications, including protein sequences, ligands, and target structures.

    CRITICAL: Residue Indexing All residue indices must use the canonical mmCIF label_asym_id (starting at 1). Do NOT use the auth_asym_id (author residue index).

    Verification Workflow

    1. Construct your .yaml file.
    2. Run the check command to validate the specification:
      boltzgen check path/to/your_spec.yaml
    3. Open the resulting .mmcif file in a viewer (e.g., PyMOL, Chimera, or Mol*). The binding site should be visually distinct from the rest of the target.

    File Paths All file references (e.g., to .cif files) inside the YAML are interpreted relative to the directory containing the YAML file.

    boltzgen check example/vanilla_peptide_with_target_binding_site/beetletert.yaml