boltzgen:基于 Python 的蛋白质设计生成工具项目

可用于设计蛋白质、肽段等与目标分子结合的结构。通过配置 YAML 文件指定设计目标,支持多种设计协议,能生成并优化排名的设计结果,需 GPU 运行。【此简介由AI生成】

分支8Tags10
文件最后提交记录最后更新时间
9 个月前
9 个月前
5 个月前
8 个月前
3 个月前
6 个月前
9 个月前
9 个月前
9 个月前
9 个月前
6 个月前
9 个月前
3 个月前

安装

在 python >=3.11 的环境中:

pip install boltzgen
点击查看详细安装说明

1 - 安装 Miniconda

选择适合您操作系统的安装程序,下载并按照屏幕提示进行操作:

安装完成后,打开终端 / 命令提示符(Windows 系统可能需要搜索 “Anaconda Prompt”)。

2 - 创建 Miniconda Python 环境

在终端中运行以下命令,创建一个名为 bg 的全新环境,并使用 Python 3.12:

conda create -n bg python=3.12

3 - 激活环境(每次使用 BoltzGen 时都需执行此操作)

conda activate bg

如果你之后打开一个新的终端会话,在使用 BoltzGen 之前必须再次运行 conda activate bg

4 - 安装 BoltzGen

运行以下命令从 PyPI 安装 BoltzGen:

pip install boltzgen

或者,如果你更倾向于安装一个可编辑的本地管理副本,请下载 BoltzGen 代码库,切换到 boltzgen 目录,并从源代码安装 BoltzGen:

pip install -e .
若您倾向于使用 Docker,请点击查看可选的 Docker 说明

构建并运行 docker 镜像的步骤:

# Build
docker build -t boltzgen .

# Run an example
mkdir -p workdir  # output
mkdir -p cache    # where models will be downloaded to
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

在上面的示例中,模型权重会在首次运行镜像时下载。若要在构建时将权重嵌入镜像,请运行:

docker build -t boltzgen:weights --build-arg DOWNLOAD_WEIGHTS=true .

运行 BoltzGen

alt text

boltzgen run 命令接收一个设计规范 .yaml 文件,并生成一组经过排序的设计方案。
⚠️ 该命令会下载模型(约 6GB)至 ~/.cache 目录。你可以通过传递 --cache YOUR_PATH 参数或设置 $HF_HOME 环境变量来更改此路径。
⚠️ 若运行过程意外中断,可使用 --reuse 参数重启,不会丢失任何进度。

boltzgen run example/vanilla_protein/1g13prot.yaml \
  --output workbench/test_run \
  --protocol protein-anything \
  --num_designs 10 \
  --budget 2
# --num_designs is the number of intermediate designs. In practice you will want between 10,000 - 60,000
# --budget is how many designs should be in the final diversity optimized set

所有命令行参数的说明请参见“所有命令行参数”

设计制作分步指南:

  1. 创建指定目标和设计需求的 .yaml 文件。我们在 example 目录中提供了许多示例,例如 example/vanilla_peptide_with_target_binding_site/beetletert.yaml。详细说明请参见“如何制作设计规范 .yaml”
  2. 检查您的设计规范是否符合预期。
    1. 运行 boltzgen check example/vanilla_peptide_with_target_binding_site/beetletert.yaml
    2. 在蛋白质结构查看器(例如 PyMOL、Chimera 或在线工具:https://molstar.org/viewer/)中可视化生成的 mmcif 文件。
    3. 您的查看器应显示结合位点与目标蛋白的其他部分颜色不同。
  3. 如上文所述,对您的 .yaml 文件运行 boltzgen run ... 命令。
  4. 经过筛选和排序的设计集将保存在 --output 指定的目录中。 Seconds per design
  5. 您可能需要使用不同的设置重新运行筛选步骤(耗时约 15 秒)。使用 boltzgen run --steps filtering --output ... 或 Jupyter 笔记本 filter.ipynb(通常更方便)。详细说明请参见“重新运行筛选(推荐)”

应生成多少个设计? 越多越好。“最低数量”取决于您的目标。 BoltzGen 应在 GPU 上运行。右侧图表显示了在 A100 GPU 上单个设计流程中每个步骤所需的时间。

我们建议首先使用例如 --num_design 50 运行,检查一切是否按预期进行,然后将 --num_design 增加到 10,000 - 60,000 之间。

流程输出

当流程完成时,您的输出目录将包含:

  • config/steps.yaml:配置文件。
  • intermediate_designs/:设计步骤的输出
    • /*.cif/*.npz:逆向折叠前的设计蛋白质和目标的 CIF 和 NPZ(元数据文件)
  • intermediate_designs_inverse_folded/:逆向折叠、折叠和分析步骤的输出
    • /*.cif/*.npz:逆向折叠后的设计蛋白质和目标的 CIF 和 NPZ。注意:对于设计的残基,只有主链原子会有坐标(侧链坐标将为 0,0,0)。
    • /refold_cif:重新折叠的复合物结构(目标和结合剂)。这是分析和筛选步骤的主要输入。
    • /refold_design_cif:重新折叠的结合剂结构,不包含目标。
    • /aggregate_metrics_analyze.csv/per_target_metrics_analyze.csv — 分析步骤的输出。
  • final_ranked_designs/:筛选步骤的输出
    • /intermediate_ranked_<N>_designs/ — 排名前 N 的高质量设计。CIF 文件从上述 refold_cif 复制而来。
    • /final_<budget>_designs/ — 兼顾质量和多样性的集合。CIF 文件从 refold_cif/ 复制而来。
    • /all_designs_metrics.csv — 筛选过程中考虑的所有设计的指标。
    • /final_designs_metrics_<budget>.csv — 所选最终集合的指标。
    • /results_overview.pdf — 图表

协议

协议(设计目标) 适用场景 主要配置差异
protein-anything 设计可结合蛋白质或多肽的蛋白质 包含 design folding 步骤。
peptide-anything 设计(环)多肽或其他分子以结合蛋白质 反向折叠过程中不会生成半胱氨酸(Cys)。无 design folding 步骤。不计算最大疏水补丁。
protein-small_molecule 设计可结合小分子的蛋白质 包含结合亲和力预测。包含 design folding 步骤。
antibody-anything 设计抗体 CDR 区 反向折叠过程中不会生成半胱氨酸(Cys)。无 design folding 步骤。不计算最大疏水补丁。
nanobody-anything 设计纳米抗体 CDR 区 与 antibody-anything 配置相同
protein-redesign 重新设计或优化现有蛋白质 design folding 步骤。使用 design_mask 定义目标/模板。

所有配置参数都可以使用 --config 选项进行覆盖;有关详细信息,请参见 boltzgen run --help 或下面的“高级用户”部分。

如何制作设计规范 .yaml 文件

有关我们的 .yaml 设计规范文件工作原理的更详细说明,请参见 example/README.md。下面是一个基于示例的说明,足以满足大多数任务的需求。

重要提示: ⚠️ 所有残基索引均从 1 开始指定,并且我们使用规范的 mmcif 残基索引 label_asym_id而非 auth_asym_id 作者残基索引! 您可以通过在 https://molstar.org/viewer/ 中打开 mmcif 文件,将鼠标悬停在残基上,并检查右下角的索引来查看文件中的索引。您将看到类似这样的内容,其中 41 是我们使用的索引,auth id 22 是不正确的

构建好 .yaml 文件后,建议您对其运行 check 命令:

  1. 运行 boltzgen check example/vanilla_peptide_with_target_binding_site/beetletert.yaml
  2. 在蛋白质结构查看器(例如 PyMOL、Chimera 或在线工具:https://molstar.org/viewer/)中可视化生成的 mmcif 文件。
  3. 您的查看器应显示结合位点与目标蛋白的其他部分颜色不同。

基于示例的说明:

我们在 example/ 目录中提供了许多示例 .yaml 文件,包括:

  • example/design_spec_showcasing_all_functionalities.yaml
  • example/vanilla_peptide_with_target_binding_site/beetletert.yaml
  • example/peptide_against_specific_site_on_ragc/rragc.yaml
  • example/nanobody/penguinpox.yaml
  • example/fab_targets/pdl1.yaml
  • example/denovo_zinc_finger_against_dna/zinc_finger.yaml
  • example/protein_binding_small_molecule/chorismite.yaml
  • example/small_molecule_from_file_and_smiles/4g37.yaml

针对未指定结合位点的靶蛋白进行蛋白质设计的小示例:

entities:
  # Designed protein with between 80 and 140 residues 
  # (The length is randomly sampled)
  - protein: 
      id: B
      sequence: 80..140

  # The target is extracted from a .cif file
  - file:
      # file references are relative to the location of the .yaml file
      path: 6m1u.cif # .pdb files also work

      # Which chain in the .cif file to use as target (uses all chains if unspecified)
      include: 
        - chain:
            id: A

重要提示: ⚠️ YAML 文件中的文件引用(例如指向 CIF 文件的引用)是相对于 YAML 文件所在目录进行解释的。

突出显示众多(并非全部)功能的示例:

entities:
  # Specification of the target which is extracted from a .cif file
  - file:
      path: 8r3a.cif # .pdb files also work
      
      # Which chain and residues in the .cif file to use as target (uses all chains if unspecified)
      include: 
        - chain:
            id: A
            res_index: 2..50,55.. # residues between 2 and 50 and anything larger than 55
        - chain:
            id: B

      # Wich regions of the target the design should or should NOT
      # bind to (this can be left unspecified, then we just bind anywhere)
      binding_types:
        - chain:
            id: A
            binding: 5..7,13
        - chain:
            id: B
            not_binding: "all" 
      
      # Which regions of the target should have their structure specified.
      # By default, everything is visibility 1 which means that the structure is specified.
      # If the visibility is 0, then the structure is not specified.
      structure_groups:
        - group:
            visibility: 1
            id: A
            res_index: 10..13
        - group:
            # The relative positioning of things in structure group 2
            # is not specified w.r.t to things in structure group 1
            visibility: 2 
            id: B
        # Overwrite the previous visibility setting and set it to 0 for res_index 13
        - group:
            visibility: 0
            id: A
            res_index: 13 

      # Optionally you can say that some residues in a loaded .cif file should also be redesigned.
      design:
        - chain:
            id: A
            res_index: 14..19

      # For designed regions you can say what secondary structure they should have
      secondary_structure:
        - chain:
            id: A
            loop: 14
            helix: 15..17
            sheet: 19

  # Specify a NON-designed protein chain
  - protein: 
      id: X
      sequence: AAVTTTTPPP

  # Specify a designed protein chain 
  # Numbers specify what is being designed
  - protein: 
      id: G
      # random number between 15 and 20 of designed residues (inclusive)
      sequence: 15..20AAAAAAVTTTT18PPP 

  # A designed helical peptides with WHL staple  
  # (see the constraints below that connect the peptide with the WHL ligand)
  - protein: 
      id: R
      # Random number of design residues between 3 and 5,
      # then a Cystein, then 6 design residues, then ...
      sequence: 3..5C6C3 
  - ligand:
      id: Q
      ccd: WHL
  
  # A designed peptide with 17 residues
  - protein:
      id: H
      sequence: 17

  # specification for a designed peptide with two Cys and a disulfide bond (see constraints)
  - protein:
      id: S
      sequence: 10..14C6C3

constraints:
    # specify connections as if the minimum possible number of residues was sampled
  - bond:
      atom1: [R, 4, SG] # connection for a helical peptides with WHL staple  between small molecule and designed peptide
      atom2: [Q, 1, CK]
  - bond:
      atom1: [R, 11, SG] # connection for a helical peptides with WHL staple  between small molecule and designed peptide
      atom2: [Q, 1, CH]
  - bond:
      atom1: [S, 11, SG] # connection for a disulfide bond between Cys and Cys in designed peptide
      atom2: [S, 18, SG]

对称复合物设计(仅适用于反向折叠)

对于对称复合物(例如同源二聚体),您可以通过为每个对称链指定 symmetric_group 来在反向折叠过程中关联序列生成。protein-redesign 协议支持对复合物进行评分,无需单独的结合体/靶标。

entities:
  - file:
      path: symmetric_dimer.cif
      include:
        - chain:
            id: A
            res_index: 100..300
            symmetric_group: 1  # Link chains A and B for symmetric sampling
        - chain:
            id: B
            res_index: 100..300
            symmetric_group: 1  # Same group = same sampled insertion length

      # Mark residues to redesign on both chains
      design:
        - chain:
            id: A
            res_index: 200..210
        - chain:
            id: B
            res_index: 200..210

仅运行特定的管道步骤

您可以使用 --steps 标志仅运行管道的特定部分:

仅运行 design 和 inverse_folding 步骤:

boltzgen run example/cyclotide/3ivq.yaml \
  --output workbench/partial-run \
  --protocol peptide-anything \
  --steps design inverse_folding \
  --num_designs 2

如果您只想运行反向折叠及后续的设计评估步骤(而非骨架设计步骤),也可以执行以下操作:

仅运行 inverse_folding 步骤:

boltzgen run example/inverse_folding/1brs.yaml \
  --output workbench/if-only \
  --only_inverse_fold \
  --inverse_fold_num_sequences 2

可用步骤:

  • design - 根据您的设计规范,使用扩散模型生成 num_design 个候选方案
  • inverse_folding - 使用我们的反向折叠模型重新设计上一步的序列
  • folding - 使用 Boltz-2 模型将设计的结合剂与其靶标一起重新折叠
  • design_folding - 单独重新折叠设计的结合剂(不含靶标,对于肽和纳米抗体结合剂不可用)
  • affinity - 使用 Boltz-2 预测设计蛋白质与其靶标小分子之间的结合亲和力(仅适用于小分子结合剂的设计)
  • analysis - 使用各种指标分析折叠结构,以评估设计质量
  • filtering - 根据分析结果筛选和排序设计,以选择最佳候选方案

重新运行筛选(推荐)

生成设计后,您可能需要多次重新运行筛选步骤(运行速度非常快),以调整选择优质设计的标准。

您可以使用 boltzgen 命令或我们提供的 jupyter notebook 来运行筛选步骤。在大多数情况下,notebook 更为便捷。如果您更倾向于使用命令行,以下是不借助 notebook 重新运行筛选器的示例。

首先,假设我们最初使用默认筛选选项生成了一些设计:

boltzgen run example/binding_disordered_peptides/tpp4.yaml \
  --output workbench/tpp4 \
  --protocol protein-anything \
  --num_designs 20

运行完成后,我们发现只有少数设计通过了筛选。此时,我们可以通过运行以下命令来调整筛选条件:

boltzgen run example/binding_disordered_peptides/tpp4.yaml \
  --output workbench/tpp4 \
  --protocol protein-anything \
  --steps filtering \
  --refolding_rmsd_threshold 3.0 \
  --filter_biased=false \
  --additional_filters 'ALA_fraction<0.3' 'filter_rmsd_design<2.5' \
  --metrics_override plip_hbonds_refolded=4 \
  --alpha 0.2

在 SLURM 上运行

详见 slurm-example

所有命令行参数

boltzgen run

boltzgen run 命令用于执行 BoltzGen 结合体设计流程。以下是所有可用选项:

设计规范

  • design_spec - 设计规范 YAML 文件的路径,或包含已准备好配置文件的目录

常规配置

  • --protocol {protein-anything,peptide-anything,protein-small_molecule,nanobody-anything,antibody-anything} - 用于设计的协议。该协议决定默认设置,在某些情况下还决定运行哪些步骤。默认值:protein-anything。详见协议部分。
  • --output OUTPUT - 流程结果的输出目录
  • --config CONFIG [CONFIG ...] - 覆盖流程步骤配置,格式为 <step_name> <arg1>=<value1> <arg2>=<value2> ...(示例:--config folding num_workers=4 trainer.devices=4)。可多次使用。
  • --devices DEVICES - 要使用的设备数量。默认使用所有可用设备。
  • --num_workers NUM_WORKERS - DataLoader 工作进程的数量。
  • --config_dir CONFIG_DIR - 默认配置文件的目录路径。默认值:src/boltzgen/resources/config
  • --use_kernels {auto,true,false} - 是否使用内核。选项为 'auto'、'true' 或 'false'。默认值:auto。若为 'auto',当设备能力 >= 8 时将使用内核。
  • --moldir MOLDIR - moldir 的路径。默认值:huggingface:boltzgen/inference-data:mols.zip
  • --reuse - 重用所有步骤的现有结果。仅生成达到指定总设计数量所需的新设计。

设计

  • --num_designs NUM_DESIGNS - 要生成的总设计数量。通常可以是 10,000 之类的数值。生成 10,000 个设计后,我们会在过滤步骤中将其筛选至 --budget 指定的数量。
  • --diffusion_batch_size DIFFUSION_BATCH_SIZE - 每次主干运行生成的扩散样本数量。如果未指定,若 --num-designs 小于 100,默认值为 1,否则为 10。请注意,对于随机采样结合体长度(或以其他方式使用随机性)的设计任务,同一批次中生成的所有设计将共享相同的长度。因此,扩散批次大小远大于要生成的总设计数量时,将无法均匀采样可能的长度。
  • --design_checkpoints DESIGN_CHECKPOINTS [DESIGN_CHECKPOINTS ...] - boltzgen 检查点的路径。支持一个或多个检查点。只需在此处指定单个路径即可。每个检查点将用于生成同等比例的设计。默认情况下,使用两个检查点。默认值:['huggingface:boltzgen/boltzgen1_diverse:boltzgen1_diverse.ckpt', 'huggingface:boltzgen/boltzgen1_adherence:boltzgen1_adherence.ckpt']
  • --step_scale STEP_SCALE - 要使用的固定步长缩放(例如 1.8)。默认使用调度表。
  • --noise_scale NOISE_SCALE - 要使用的固定噪声缩放(例如 0.98)。默认使用调度表。

反向折叠

  • --skip_inverse_folding - 跳过反向折叠步骤
  • --inverse_fold_num_sequences INVERSE_FOLD_NUM_SEQUENCES - 反向折叠步骤中每个骨架生成的序列数量。默认值:1
  • --inverse_fold_checkpoint INVERSE_FOLD_CHECKPOINT - 反向折叠检查点的路径或Hugging Face仓库及文件名。默认值:huggingface:boltzgen/boltzgen1_ifold:boltzgen1_ifold.ckpt
  • --inverse_fold_avoid INVERSE_FOLD_AVOID - 禁用的氨基酸残基,以单字母氨基酸代码字符串形式表示,例如'KEC'。此功能在反向折叠步骤中实现,因此仅在启用反向折叠时才会影响结果。默认值:蛋白质设计为无,肽和纳米抗体设计为'C'。如果您使用纳米抗体或肽方案并希望生成半胱氨酸(Cysteins),请传递空列表。
  • --only_inverse_fold - 跳过设计步骤,仅运行反向折叠。需要完整指定的结构。

折叠与亲和力预测

  • --folding_checkpoint FOLDING_CHECKPOINT - 折叠检查点的路径。默认值:huggingface:boltzgen/boltz2_conf_final:boltz2_conf_final.ckpt
  • --affinity_checkpoint AFFINITY_CHECKPOINT - 亲和力预测器检查点的路径。默认值:huggingface:boltzgen/boltz2_affinity:boltz2_aff.ckpt

筛选

  • --budget BUDGET - 最终多样性优化集合中应包含的设计数量。用于筛选步骤。
  • --alpha ALPHA - 序列多样性选择的权衡参数:0.0=仅考虑质量,1.0=仅考虑多样性。默认值为0.01(肽-任意方案)或0.001(其他方案)。
  • --filter_biased {true,false} - 移除氨基酸组成异常值(默认对ALA/GLY/GLU/LEU/VAL设置上限)。默认值:true。
  • --metrics_override METRICS_OVERRIDE [METRICS_OVERRIDE ...] - 用于排序的每个指标的逆重要性权重。格式:metric_name=weight(例如,plip_hbonds_refolded=4 delta_sasa_refolded=2)。值越大,该指标的排名权重越低。使用metric_name=none可移除某个指标。
  • --additional_filters ADDITIONAL_FILTERS [ADDITIONAL_FILTERS ...] - 额外的硬筛选条件。格式:feature>thresholdfeature<threshold(例如,'design_ALA>0.3' 'design_GLY<0.2')。如果值越高越好,使用 '>';如果值越低越好,使用 '<'。请确保对字符串使用单引号,以免您的shell被<和>字符混淆。
  • --size_buckets SIZE_BUCKETS [SIZE_BUCKETS ...] - 大小范围内设计数量的可选约束。格式:min-max:count(例如,10-20:5 20-30:10 30-40:5)。
  • --refolding_rmsd_threshold REFOLDING_RMSD_THRESHOLD - 用于基于RMSD的筛选的阈值(值越低越好)。

执行选项

  • --no_subprocess - 在主进程中运行每个步骤。当设备数量大于1时会导致问题。
  • --steps {design,inverse_folding,design_folding,folding,affinity,analysis,filtering} [{design,inverse_folding,design_folding,folding,affinity,analysis,filtering} ...] - 仅运行指定的流水线步骤(默认:运行所有步骤)。详情请参见各个流水线步骤部分。

模型和数据下载选项

  • --force_download - 强制(重新)下载模型和数据。
  • --models_token MODELS_TOKEN - 用于我们模型托管服务(Hugging Face)的秘密令牌。默认值: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
  • --cache CACHE - 存储下载模型的目录。默认值:~/.cache

boltzgen download

boltzgen download命令用于下载 BoltzGen 所需的模型权重和数据制品。在大多数情况下,您无需使用boltzgen download,因为boltzgen run会自动下载所需内容。

下载的权重和数据集默认存储在~/.cache中,但可以通过指定--cache来更改此位置。

示例

boltzgen download all # downloads all models
boltzgen download inverse-fold # downloads only the inverse folding model

使用方法

boltzgen download [-h] [--force_download] [--models_token MODELS_TOKEN] [--cache CACHE] {affinity,design-adherence,design-diverse,folding,inverse-fold,moldir,all} [{affinity,design-adherence,design-diverse,folding,inverse-fold,moldir,all} ...]

位置参数

  • {affinity,design-adherence,design-diverse,folding,inverse-fold,moldir,all} - 要下载的工件子集,或使用 'all' 下载所有工件。

选项

  • --force_download - 强制(重新)下载模型和数据。
  • --models_token MODELS_TOKEN - 用于我们模型托管服务的秘密令牌。通常不需要。
  • --cache CACHE - 存储下载模型的目录。默认值:~/.cache

boltzgen configure

为了更好地控制您的设计流程,您可以将配置生成与执行分开:

示例

boltzgen configure example/cyclotide/3ivq.yaml \
  --output workbench/test-peptide-protein \
  --protocol peptide-anything \
  --num_designs 2 \
  --reuse

这会在 workbench/test-peptide-protein/ 中创建配置文件,但不会运行实际的设计流程。如果需要,你可以编辑这些文件,然后运行 boltzgen execute workbench/test-peptide-protein 来执行工作流。

boltzgen configure 接受的选项是 boltzgen run 选项的子集,因此我们在此不再全部列出。如果需要帮助,请尝试 boltzgen configure --help

boltzgen execute

boltzgen execute 命令从由 boltzgen configure 命令生成的配置文件目录中执行预配置的流程。

用法

boltzgen execute [-h] [--no_subprocess] [--steps {design,inverse_folding,design_folding,folding,affinity,analysis,filtering} [{design,inverse_folding,design_folding,folding,affinity,analysis,filtering} ...]] output

位置参数

  • output - 包含预配置管道文件的目录(由 'configure' 命令生成)

执行选项

  • --no_subprocess - 在主进程中运行每个步骤。当设备数 >1 时会导致问题。
  • --steps {design,inverse_folding,design_folding,folding,affinity,analysis,filtering} [{design,inverse_folding,design_folding,folding,affinity,analysis,filtering} ...] - 仅运行指定的管道步骤(默认:运行所有步骤)

boltzgen merge

如果您在多个管道运行中生成了设计(例如用于并行化),可以将最终输出合并到一个目录中,然后对合并后的集合重新运行快速过滤步骤。

示例

boltzgen merge workbench/run_a workbench/run_b workbench/run_c \
  --output workbench/merged_run

# Now rerun filtering (with any tweaked parameters you like)
boltzgen run example/vanilla_protein/1g13prot.yaml \
  --steps filtering \
  --output workbench/merged_run \
  --protocol protein-anything \
  --budget 60 \
  --alpha 0.05

使用方法

boltzgen merge [-h] --output OUTPUT source [source ...]

参数

  • source(位置参数)—— 一个或多个 BoltzGen 输出目录,其中已包含折叠/分析结果(即您之前运行管道时传递给 --output 的目录)。
  • --output OUTPUT—— 合并数据的目标目录。该命令会在此文件夹内创建(或替换)设计产物,以便后续执行 boltzgen run --steps filtering --output OUTPUT ...

训练 BoltzGen 模型

以开发模式安装,这将安装 wandb 等额外软件包。

git clone https://github.com/HannesStark/boltzgen
pip install -e .[dev]

1 – 下载训练数据和检查点

# Choose any location; this is default in yaml files
mkdir -p training_data
cd training_data

# ─ Targets ─
wget -O targets.zip "https://huggingface.co/datasets/boltzgen/boltzgen1_train/resolve/main/targets.zip?download=true"
unzip targets.zip      # → training_data/targets/

# ─ MSAs  ─
wget -O msa.zip "https://huggingface.co/datasets/boltzgen/boltzgen1_train/resolve/main/msa.zip?download=true"
unzip msa.zip          # → training_data/msa/

# ─ 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 ..

# ─ Folding checkpoint  ─
wget -O boltz2_fold.ckpt "https://huggingface.co/boltzgen/boltzgen-1/resolve/main/boltz2_conf_final.ckpt?download=true"

# ─────────── (optional) pretrained structure-only ckpt ───────────
# Needed ONLY if you want to resume from a structure-trained model.
wget -O boltzgen1_structuretrained_small.ckpt \
  "https://huggingface.co/boltzgen/boltzgen-1/resolve/main/boltzgen1_structuretrained_small.ckpt?download=true"

生成的布局

training_data/
 ├─ targets/     (used for target_dir in yaml)     
 ├─ msa/         (used for msa_dir in yaml)     
 ├─ mols/        (used for mol_dir in yaml) 
 ├─ boltz2_fold.ckpt    (used for folding_checkpoint in yaml) 
 └─ boltzgen1_structuretrained_small.ckpt   (used for pretrained in yaml)

training_data 目录是示例 YAML 配置文件中引用的默认位置。如果您将数据放置在其他位置,请确保相应地更新这些路径。

2 – 训练 YAML 文件

以下是三种训练配置的快速参考,以及路径设置完成后如何启动它们:

配置文件 用途 示例命令
src/boltzgen/resources/config/train/boltzgen_small.yaml 训练 小型 Boltzgen 模型(推荐用于开发,8 个 GPU,梯度累积 16) python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/boltzgen_small.yaml name=boltzgen_small
src/boltzgen/resources/config/train/boltzgen.yaml 训练 大型 BoltzGen 模型 python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/boltzgen.yaml name=boltzgen_large
src/boltzgen/resources/config/train/inverse_folding.yaml 仅训练 反向折叠 模型 python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/inverse_folding.yaml name=boltzgen_if

如果您将数据存储在 ./training_data 以外的位置,请在所有三个 YAML 文件中搜索并替换该路径。您可能需要更新的典型键包括 target_dirmsa_dirmoldirpretrainedfolding_checkpointmonomer_target_dirligand_target_dir

示例位置:

data:
  datasets:
    - target_dir: ./training_data/targets
      msa_dir:    ./training_data/msa
  moldir: ./training_data/mols

pretrained: ./training_data/boltzgen1_structuretrained_small.ckpt

folding_checkpoint: ./training_data/boltz2_fold.ckpt

3 – 训练模型(示例命令)

在 8 块 GPU 上训练小型模型,梯度累积设为 16(推荐的开发环境设置):

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/boltzgen_small.yaml \
       name=boltzgen_small

大模型:

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/boltzgen.yaml \
       name=boltzgen_large

逆折叠模型:

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/inverse_folding.yaml \
       name=boltzgen_if

注意:目前大模型需要额外的蒸馏数据集(即将发布)。您仍可以通过调整路径来探索其超参数,并仅基于 PDB 数据进行训练。

可选:从检查点恢复

CUDA_VISIBLE_DEVICES=0,1,2,3,4,5,6,7 \
python src/boltzgen/resources/main.py src/boltzgen/resources/config/train/boltzgen_small.yaml \
       pretrained=./training_data/boltzgen1_structuretrained_small.ckpt \
       name=boltzgen_small_pretrained

引用

@article{stark2025boltzgen,
	author = {Stark, Hannes and Faltings, Felix and Choi, MinGyu and Xie, Yuxin and Hur, Eunsu and O{\textquoteright}Donnell, Timothy John and Bushuiev, Anton and U{\c c}ar, Talip and Passaro, Saro and Mao, Weian and Reveiz, Mateo and Bushuiev, Roman and Pluskal, Tom{\'a}{\v s} and Sivic, Josef and Kreis, Karsten and Vahdat, Arash and Ray, Shamayeeta and Goldstein, Jonathan T. and Savinov, Andrew and Hambalek, Jacob A. and Gupta, Anshika and Taquiri-Diaz, Diego A. and Zhang, Yaotian and Hatstat, A. Katherine and Arada, Angelika and Kim, Nam Hyeong and Tackie-Yarboi, Ethel and Boselli, Dylan and Schnaider, Lee and Liu, Chang C. and Li, Gene-Wei and Hnisz, Denes and Sabatini, David M. and DeGrado, William F. and Wohlwend, Jeremy and Corso, Gabriele and Barzilay, Regina and Jaakkola, Tommi},
	title = {BoltzGen: Toward Universal Binder Design},
	year = {2025},
	doi = {10.1101/2025.11.20.689494},
	journal = {bioRxiv}
}

项目介绍

可用于设计蛋白质、肽段等与目标分子结合的结构。通过配置 YAML 文件指定设计目标,支持多种设计协议,能生成并优化排名的设计结果,需 GPU 运行。【此简介由AI生成】

定制我的领域