- Model Introduction
- Model Description
- Use Cases
- Usage
- 1. OneCode
- 2. Manual Installation
- Download the Model Package
- Install the Runtime Environment
- Compile the Combinatorial Assembler
- Weights and Data Preparation
- Define Subunits
- Quick Inference: CPU Assembly from Existing PDB Files
- Generate Pairwise FASTA Files
- Minimal DCU Pairwise Inference
- End-to-End DCU-to-CPU Inference
- Use Crosslinking Restraints
- Optional Prediction of Larger Subcomplexes
- Training
- 1. OneCode
- OneScience Official Resources
- Citation and License
- 中文说明
CombFold
Model Introduction
CombFold is an open-source pipeline developed by dina-lab3D for predicting the structures of large protein complexes. Starting from the amino acid sequences of the individual chains in a complex, CombFold uses AlphaFold-Multimer to predict multiple candidate subcomplexes and then applies combinatorial assembly algorithms to construct the complete protein complex.
The original publication reports support for complexes containing at least 18,000 amino acids and up to 32 subunits.
Paper: Assembly of protein complexes by combining AlphaFold and combinatorial optimization
Model Description
CombFold consists of four main stages:
- Define subunits according to protein domains and chain composition and generate
subunits.json; - Generate FASTA files for all subunit pairs and predict pairwise subcomplexes using AlphaFold-Multimer;
- Optionally predict candidate subcomplexes containing more than two subunits;
- Extract relative transformations between subunits from the predicted PDB structures and use a C++ combinatorial optimization algorithm to assemble the complete complex.
The main components included in the Hugging Face model package are:
model/CombinatorialAssembler/: C++17 combinatorial assembler and theAF2transstructural transformation tool;scripts/prepare_fastas.py: generates FASTA files for pairwise or larger subunit combinations;scripts/inference.py: unified assembly entry point for the Hugging Face model package;scripts/run_on_pdbs.py: original upstream entry point for assembly from predicted PDB structures;weight/: official pretrained AlphaFold-Multimer parameters used for offline ColabFold inference;requirements.txt: additional dependencies required on top of the OneScience base environment.
CombFold itself is not a trainable neural network. Neural-network inference is performed by pretrained AlphaFold-Multimer models, while CombFold is responsible for extracting structural transformations and performing combinatorial assembly.
Use Cases
| Use Case | Description |
|---|---|
| Large protein complex prediction | Combine multiple AlphaFold-Multimer subcomplex predictions into a complete complex structure. |
| Homomer prediction | Assemble complexes containing multiple copies of the same unique subunit according to the specified stoichiometry. |
| Heteromer prediction | Integrate predictions from different subunit pairs or groups to construct the complete structure. |
| Assembly from existing AFM results | Directly use existing AlphaFold-Multimer PDB predictions without rerunning AlphaFold-Multimer. |
| Crosslink-guided assembly | Optionally incorporate crosslinking restraints to constrain candidate complex structures. |
Usage
1. OneCode
You can use the OneCode online environment for an intelligent one-click AI4S programming experience:
Try OneCode for AI4S Programming
2. Manual Installation
Hardware Requirements
- The CombFold C++ combinatorial assembly stage requires only CPU resources;
- Local AlphaFold-Multimer subcomplex prediction typically requires an accelerator;
- Memory usage for long-sequence and multi-model inference increases with the total number of residues, MSA depth, number of models, and number of recycles;
- PyTorch is not a direct runtime dependency of CombFold or the current ColabFold inference pipeline.
Download the Model Package
Install the Hugging Face command-line tool and download the model repository:
pip install -U huggingface_hub
hf download OneScience-Group/CombFold --local-dir ./CombFold
cd CombFold
Install the Runtime Environment
OneScience DCU Base Environment
conda create -n onescience311 python=3.11 -y
conda activate onescience311
python -m pip install onescience[bio-dcu] \
-i http://mirrors.onescience.ai:3141/pypi/simple/ \
--trusted-host mirrors.onescience.ai
Install the additional dependencies:
python -m pip install --no-deps -r requirements.txt
Compile the Combinatorial Assembler
The combinatorial assembly stage of CombFold is implemented in C++17 and requires the following system-level components. These components cannot be installed through requirements.txt.
| Component | Purpose | Description |
|---|---|---|
| C++17 compiler | Compile the C++ source code | g++ is commonly used on Linux |
| GNU Make | Execute the Makefile | GNU Make 4.2.1 has been validated |
| Boost headers | Compile-time headers | The directory must contain boost/algorithm/string.hpp |
| Boost program_options | Link-time runtime library | Usually provided as libboost_program_options.so on Linux |
Boost headers are generally portable across Linux distributions, but compiled Boost libraries depend on the operating system, CPU architecture, compiler, and libstdc++ ABI. Therefore, compiled Boost libraries should not be copied directly between Linux, macOS, Windows, or different CPU architectures.
It is recommended to use Boost headers and runtime libraries from the same Boost version.
The upstream Makefile is configured primarily for macOS Homebrew. On Linux, the following command can be used directly only when Boost is already available in the compiler's default search paths:
cd model/CombinatorialAssembler
make
cd ../..
Specify a Custom Boost Path
If Boost is not installed in the default compiler search paths, define the following environment variables:
export COMBFOLD_BOOST_INCLUDE="<Boost source or include directory>"
export COMBFOLD_BOOST_LIB="<Boost library directory>"
COMBFOLD_BOOST_INCLUDE must point to a directory that directly contains the boost/ subdirectory.
COMBFOLD_BOOST_LIB must point to a directory that directly contains the libboost_program_options library.
Before compilation, you can verify the paths using:
test -f "${COMBFOLD_BOOST_INCLUDE}/boost/algorithm/string.hpp" \
&& echo "Boost headers OK"
find "${COMBFOLD_BOOST_LIB}" -maxdepth 1 \
-name 'libboost_program_options*' -print
Compile the assembler:
cd model/CombinatorialAssembler
make -j4 \
BOOST_INCLUDE="${COMBFOLD_BOOST_INCLUDE}" \
BOOST_LIB="${COMBFOLD_BOOST_LIB}"
cd ../..
Weights and Data Preparation
The CombFold combinatorial assembler itself does not require model weights.
Local generation of AlphaFold-Multimer subcomplex predictions requires the five official AlphaFold-Multimer v3 parameter files:
| Asset | Location in the Model Package | Purpose |
|---|---|---|
params_model_1_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 model 1 |
params_model_2_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 model 2 |
params_model_3_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 model 3 |
params_model_4_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 model 4 |
params_model_5_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 model 5 |
Use the following ColabFold data path:
--data weight/alphafold
If you only use existing AlphaFold-Multimer PDB predictions for combinatorial assembly, AlphaFold-Multimer weights and a DCU device are not required.
Define Subunits
The input subunits.json is a JSON dictionary keyed by unique subunit names.
Each subunit contains the following fields:
name: unique subunit name;sequence: amino acid sequence;chain_names: chain names corresponding to this subunit in the complete complex. The number of entries also defines its stoichiometry;start_res: starting residue index of the sequence in the original chain.
Example:
{
"A0": {
"name": "A0",
"chain_names": ["A", "B"],
"start_res": 1,
"sequence": "MKDILEKLEERRAQARLGGGEKRLEAQHKRGKLTARERIELLLDHGSFEE"
}
}
The Hugging Face model package provides a complete example:
scripts/example/subunits.json
scripts/example/pdbs/
Quick Inference: CPU Assembly from Existing PDB Files
This is the shortest CombFold inference path and does not run AlphaFold-Multimer:
python scripts/inference.py \
--subunits scripts/example/subunits.json \
--pdbs scripts/example/pdbs \
--output output/example_assembly
The output directory must either not exist or be empty before execution.
After successful execution, the main results are located at:
output/example_assembly/assembled_results/output_clustered_0.pdb
output/example_assembly/assembled_results/confidence.txt
You can also use the original upstream positional-argument entry point:
python scripts/run_on_pdbs.py \
scripts/example/subunits.json \
scripts/example/pdbs \
output/example_assembly
Generate Pairwise FASTA Files
Generate FASTA files for every pair of unique subunits defined in subunits.json:
python scripts/prepare_fastas.py \
scripts/example/subunits.json \
--stage pairs \
--output-fasta-folder output/pair_fastas \
--max-af-size 1800
The output directory must not already exist.
The official example generates files such as:
A0_A0.fasta
A0_G0.fasta
G0_G0.fasta
Minimal DCU Pairwise Inference
For an offline smoke test on a compute node, you can use single_sequence, one model, and one recycle:
colabfold_batch \
output/pair_fastas \
output/colabfold_pairs \
--data weight/alphafold \
--model-type alphafold2_multimer_v3 \
--model-order 1 \
--num-models 1 \
--num-recycle 1 \
--num-relax 0 \
--msa-mode single_sequence \
--disable-unified-memory
The configuration:
single_sequence + 1 model + 1 recycle
is intended only to verify parameter loading, JAX/DCU forward execution, and PDB output generation.
It should not be used to evaluate formal prediction accuracy.
For production-quality predictions, prepare appropriate MSA features and increase the number of models and recycles according to available memory and runtime constraints.
End-to-End DCU-to-CPU Inference
At least one predicted PDB structure must be selected for each pair.
To select the top-ranked ColabFold structure:
mkdir -p output/combfold_pdbs
find output/colabfold_pairs -maxdepth 1 \
-type f -name '*rank_001*.pdb' \
-exec cp {} output/combfold_pdbs/ \;
Then run the CombFold combinatorial assembly stage:
python scripts/inference.py \
--subunits scripts/example/subunits.json \
--pdbs output/combfold_pdbs \
--output output/end2end_assembly
The unified inference entry point also outputs a machine-readable summary, for example:
COMBFOLD_INFERENCE_RESULT={"assembled_structures": 5, "format": "pdb", "status": "PASS", ...}
Use Crosslinking Restraints
Use the --crosslinks option to provide a crosslink restraint file:
python scripts/inference.py \
--subunits scripts/example/example_xlinks/subunits.json \
--pdbs scripts/example/example_xlinks/pdbs \
--crosslinks scripts/example/example_xlinks/crosslinks.txt \
--output output/crosslink_assembly
Optional Prediction of Larger Subcomplexes
After completing pairwise prediction, larger subcomplex FASTA files can be generated based on the pairwise results:
python scripts/prepare_fastas.py \
scripts/example/subunits.json \
--stage groups \
--output-fasta-folder output/group_fastas \
--max-af-size 1800 \
--input-pairs-results output/combfold_pdbs
Training
CombFold is an inference algorithm that performs combinatorial assembly using predictions generated by pretrained AlphaFold-Multimer models.
CombFold itself does not contain a trainable neural network, training entry point, optimizer, or training-data pipeline. Therefore, this Hugging Face model package does not provide training commands.
Retraining AlphaFold-Multimer is a separate upstream large-scale model-training task and is not part of the CombFold combinatorial assembly workflow.
OneScience Official Resources
| Platform | OneScience Main Repository | Skills Repository |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
Citation and License
- Paper: Assembly of protein complexes by combining AlphaFold and combinatorial optimization
- Official implementation: https://github.com/dina-lab3D/CombFold
- The CombFold source code is provided under the Apache License 2.0 according to the upstream repository.
- AlphaFold, AlphaFold-Multimer, ColabFold, pretrained parameters, and other third-party components are subject to their respective original copyright notices, model terms, and licenses.
中文说明
模型简介
CombFold 是 dina-lab3D 开发的开源流程,用于预测大型蛋白质复合物的结构。CombFold 以复合物中各条链的氨基酸序列为起点,使用 AlphaFold-Multimer 预测多个候选子复合物,再通过组合组装算法构建完整的蛋白质复合物。
原始论文报告该方法支持至少含有 18,000 个氨基酸、最多包含 32 个亚基的复合物。
模型描述
CombFold 包含以下四个主要阶段。
- 根据蛋白质结构域及链组成定义亚基并生成
subunits.json。 - 为所有亚基配对生成 FASTA 文件,并使用 AlphaFold-Multimer 预测成对子复合物。
- 可选预测包含两个以上亚基的候选子复合物。
- 从预测的 PDB 结构中提取亚基间的相对变换,使用 C++ 组合优化算法组装完整复合物。
Hugging Face 模型包包含以下主要组件。
model/CombinatorialAssembler/,C++17 组合组装器及AF2trans结构变换工具。scripts/prepare_fastas.py,为成对或更大亚基组合生成 FASTA 文件。scripts/inference.py,Hugging Face 模型包的统一组装入口。scripts/run_on_pdbs.py,根据预测 PDB 结构进行组装的原始上游入口。weight/,用于离线 ColabFold 推理(inference)的官方预训练 AlphaFold-Multimer 参数。requirements.txt,OneScience 基础环境之外所需的附加依赖。
CombFold 本身不是可训练的神经网络。神经网络推理由预训练 AlphaFold-Multimer 模型执行,CombFold 负责提取结构变换及执行组合组装。
使用场景
| 使用场景 | 说明 |
|---|---|
| 大型蛋白质复合物预测 | 将多个 AlphaFold-Multimer 子复合物预测合成完整的复合物结构。 |
| 同源多聚体预测 | 根据指定的化学计量组成组装含同一亚基多个副本的复合物。 |
| 异源多聚体预测 | 整合不同亚基对或亚基组的预测结果,构建完整结构。 |
| 根据现有 AFM 结果组装 | 直接使用现有 AlphaFold-Multimer PDB 预测结果,无需重新运行 AlphaFold-Multimer。 |
| 交联引导组装 | 可选纳入交联约束来限制候选复合物结构。 |
使用方法
1. OneCode
可以通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 手动安装
硬件要求
- CombFold 的 C++ 组合组装阶段仅需要 CPU 资源。
- 本地 AlphaFold-Multimer 子复合物预测通常需要加速器。
- 长序列和多模型推理的内存用量随残基总数、MSA 深度、模型数量和循环次数而增加。
- CombFold 及当前 ColabFold 推理流程均不直接依赖 PyTorch 运行。
下载模型包
安装 Hugging Face 命令行工具并下载模型仓库。
pip install -U huggingface_hub
hf download OneScience-Group/CombFold --local-dir ./CombFold
cd CombFold
安装运行环境
OneScience DCU 基础环境
conda create -n onescience311 python=3.11 -y
conda activate onescience311
python -m pip install onescience[bio-dcu] \
-i http://mirrors.onescience.ai:3141/pypi/simple/ \
--trusted-host mirrors.onescience.ai
安装附加依赖。
python -m pip install --no-deps -r requirements.txt
编译组合组装器
CombFold 的组合组装阶段使用 C++17 实现,需要以下系统级组件。这些组件无法通过 requirements.txt 安装。
| 组件 | 用途 | 说明 |
|---|---|---|
| C++17 编译器 | 编译 C++ 源代码 | Linux 上常用 g++ |
| GNU Make | 执行 Makefile | 已验证 GNU Make 4.2.1 |
| Boost 头文件 | 编译期头文件 | 目录必须包含 boost/algorithm/string.hpp |
| Boost program_options | 链接所需的运行库 | 在 Linux 上通常以 libboost_program_options.so 提供 |
Boost 头文件通常可跨 Linux 发行版使用,编译得到的 Boost 库则依赖操作系统、CPU 架构、编译器及 libstdc++ ABI。因此,请勿在 Linux、macOS、Windows 或不同 CPU 架构之间直接复制编译过的 Boost 库。
建议使用同一 Boost 版本的头文件和运行库。
上游 Makefile 主要为 macOS Homebrew 配置。在 Linux 上,仅当编译器默认搜索路径中已有 Boost 时,下列命令才可直接使用。
cd model/CombinatorialAssembler
make
cd ../..
指定自定义 Boost 路径
如果 Boost 未安装在编译器默认搜索路径下,请定义以下环境变量。
export COMBFOLD_BOOST_INCLUDE="<Boost source or include directory>"
export COMBFOLD_BOOST_LIB="<Boost library directory>"
COMBFOLD_BOOST_INCLUDE 必须指向直接包含 boost/ 子目录的目录。
COMBFOLD_BOOST_LIB 必须指向直接包含 libboost_program_options 库的目录。
编译前可通过以下命令核对路径。
test -f "${COMBFOLD_BOOST_INCLUDE}/boost/algorithm/string.hpp" \
&& echo "Boost headers OK"
find "${COMBFOLD_BOOST_LIB}" -maxdepth 1 \
-name 'libboost_program_options*' -print
编译组装器。
cd model/CombinatorialAssembler
make -j4 \
BOOST_INCLUDE="${COMBFOLD_BOOST_INCLUDE}" \
BOOST_LIB="${COMBFOLD_BOOST_LIB}"
cd ../..
权重与数据准备
CombFold 组合组装器本身不需要模型权重。
在本地生成 AlphaFold-Multimer 子复合物预测需要以下五个官方 AlphaFold-Multimer v3 参数文件。
| 文件 | 在模型包中的位置 | 用途 |
|---|---|---|
params_model_1_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 模型 1 |
params_model_2_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 模型 2 |
params_model_3_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 模型 3 |
params_model_4_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 模型 4 |
params_model_5_multimer_v3.npz |
weight/alphafold/params/ |
AFM v3 模型 5 |
使用以下 ColabFold 数据路径。
--data weight/alphafold
如果只用已有的 AlphaFold-Multimer PDB 预测进行组合组装,则无需 AlphaFold-Multimer 权重和 DCU 设备。
定义亚基
输入文件 subunits.json 是一个以唯一亚基名为键的 JSON 字典。
每个亚基包含以下字段。
name,唯一亚基名。sequence,氨基酸序列。chain_names,完整复合物中与该亚基对应的链名称。条目数也定义了该亚基的化学计量数。start_res,该序列在原始链中的起始残基索引。
示例
{
"A0": {
"name": "A0",
"chain_names": ["A", "B"],
"start_res": 1,
"sequence": "MKDILEKLEERRAQARLGGGEKRLEAQHKRGKLTARERIELLLDHGSFEE"
}
}
Hugging Face 模型包提供了完整示例。
scripts/example/subunits.json
scripts/example/pdbs/
快速推理:从现有 PDB 文件进行 CPU 组装
这是最快的 CombFold 推理流程,无需运行 AlphaFold-Multimer。
python scripts/inference.py \
--subunits scripts/example/subunits.json \
--pdbs scripts/example/pdbs \
--output output/example_assembly
执行前,输出目录必须不存在或为空。
成功执行后,主要结果位于以下位置。
output/example_assembly/assembled_results/output_clustered_0.pdb
output/example_assembly/assembled_results/confidence.txt
也可使用上游原始位置参数入口。
python scripts/run_on_pdbs.py \
scripts/example/subunits.json \
scripts/example/pdbs \
output/example_assembly
生成成对 FASTA 文件
为 subunits.json 中定义的所有唯一亚基配对生成 FASTA 文件。
python scripts/prepare_fastas.py \
scripts/example/subunits.json \
--stage pairs \
--output-fasta-folder output/pair_fastas \
--max-af-size 1800
输出目录必须尚不存在。
官方示例生成的文件如下。
A0_A0.fasta
A0_G0.fasta
G0_G0.fasta
最小规模 DCU 成对推理
若需在计算节点上进行离线冒烟测试,可使用 single_sequence、一个模型和一次循环。
colabfold_batch \
output/pair_fastas \
output/colabfold_pairs \
--data weight/alphafold \
--model-type alphafold2_multimer_v3 \
--model-order 1 \
--num-models 1 \
--num-recycle 1 \
--num-relax 0 \
--msa-mode single_sequence \
--disable-unified-memory
以下配置
single_sequence + 1 model + 1 recycle
仅用于验证参数加载、JAX/DCU 前向运行和 PDB 输出生成。
不应用于评估正式预测精度。
如需生产级预测,请准备适当的 MSA 特征,并根据可用内存和运行时间限制增加模型数量与循环次数。
从 DCU 到 CPU 的端到端推理
每个配对必须至少选定一个预测的 PDB 结构。
按以下方式选择排名第一的 ColabFold 结构。
mkdir -p output/combfold_pdbs
find output/colabfold_pairs -maxdepth 1 \
-type f -name '*rank_001*.pdb' \
-exec cp {} output/combfold_pdbs/ \;
然后运行 CombFold 组合组装阶段。
python scripts/inference.py \
--subunits scripts/example/subunits.json \
--pdbs output/combfold_pdbs \
--output output/end2end_assembly
统一推理入口还会输出机器可读的摘要,例如以下内容。
COMBFOLD_INFERENCE_RESULT={"assembled_structures": 5, "format": "pdb", "status": "PASS", ...}
使用交联约束
使用 --crosslinks 选项提供交联约束文件。
python scripts/inference.py \
--subunits scripts/example/example_xlinks/subunits.json \
--pdbs scripts/example/example_xlinks/pdbs \
--crosslinks scripts/example/example_xlinks/crosslinks.txt \
--output output/crosslink_assembly
可选预测更大的子复合物
完成成对预测后,可根据成对结果生成更大子复合物的 FASTA 文件。
python scripts/prepare_fastas.py \
scripts/example/subunits.json \
--stage groups \
--output-fasta-folder output/group_fastas \
--max-af-size 1800 \
--input-pairs-results output/combfold_pdbs
训练
CombFold 是一种推理算法,使用预训练 AlphaFold-Multimer 模型生成的预测进行组合组装。
CombFold 本身不含可训练神经网络、训练入口、优化器或训练数据管线。因此,本 Hugging Face 模型包不提供训练命令。
重新训练 AlphaFold-Multimer 是单独的上游大规模模型训练任务,不属于 CombFold 组合组装工作流。
OneScience 官方资源
| 平台 | OneScience 主仓库 | Skills 仓库 |
|---|---|---|
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
引用与许可证
- 论文 结合 AlphaFold 和组合优化组装蛋白质复合物
- 官方实现 https://github.com/dina-lab3D/CombFold
- 根据上游仓库,CombFold 源代码采用 Apache License 2.0 授权。
- AlphaFold、AlphaFold-Multimer、ColabFold、预训练参数以及其他第三方组件均受各自的原始版权声明、模型条款和许可证约束。
- Downloads last month
- 20