Configuration Parsing Warning:Invalid JSON for config file config.json
OpenFold
Model Introduction
OpenFold is an open-source framework for predicting three-dimensional protein structures from protein sequences, multiple sequence alignments (MSAs), and template information. As a trainable reproduction of AlphaFold2, its core network architecture includes Evoformer, Structure Module, template modules, MSA modules, and other components, supporting a complete structural prediction experiment workflow that includes training, inference, and weight conversion.
Paper: OpenFold: Retraining AlphaFold2 yields new insights into its learning mechanisms and capacity for generalization https://www.biorxiv.org/content/10.1101/2022.11.20.517210v2
Model Description
OpenFold is based on the Evoformer + Structure Module architecture and is trained with PDB and UniRef data. It is designed for protein three-dimensional structure prediction, model fine-tuning, and research on architectural improvements. The core network contains 48 Evoformer Blocks and 8 Structure Module layers. Through triangle attention and invariant point attention mechanisms, it enables bidirectional fusion of evolutionary information and spatial geometry. Compared with the original AlphaFold2, OpenFold adds memory-efficient attention, mixed-precision training support, and seamless weight conversion capabilities, significantly reducing GPU memory usage and fixing trainability issues.
Applicable Scenarios
| Scenario | Description |
|---|---|
| Local OpenFold invocation | Users can call OpenFold training or inference through the scripts in this repository. |
| Reuse of the OneScience base | Continue using shared OneScience modules such as datapipes, utils, loss, and np. |
| ModelScope/OneCode release | Expose only scripts, models, configurations, and weight directories to reduce the release package size. |
| Weight conversion and data preparation | Use the tools under scripts/ to download databases, preprocess alignments, and convert weights. |
Usage
1. Using OneCode
You can try intelligent one-click AI4S programming through the OneCode online environment:
Try intelligent one-click AI4S programming
2. Manual Installation and Usage
Hardware Requirements
- Running on a GPU or DCU is recommended.
- A CPU can be used for import checks and small-configuration connectivity validation, but full training and inference will be slow.
- DCU users need to install DTK in advance. DTK 25.04.2 or later is recommended, or the OneScience-recommended version that matches the current cluster.
3. Quick Start
Download the Model Package
hf download OneScience-Group/OpenFold --local-dir ./OpenFold
cd OpenFold
Install the Runtime Environment
DCU Environment
# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
Quick Verification
PYTHONPATH=$(pwd)/model python -c "from openfold.model import AlphaFold; from config.config import model_config; import onescience; print('openfold wrapper ok')"
If dependencies such as torch, ml_collections, or deepspeed are reported as missing, install the OneScience-recommended runtime environment first, or install the corresponding dependencies for your DCU/GPU version.
Example Data
The data/ directory is used to store the example inputs required by OpenFold and user-provided data. The current repository includes a monomer inference example at data/demo/monomer, making it easy to quickly check the inference script, model import, and alignment loading workflow.
Directory structure:
| Path | Description |
|---|---|
data/demo/monomer/fasta_dir/6kwc.fasta |
Example protein sequence. The FASTA header is 6KWC_1. |
data/demo/monomer/alignments/6KWC_1/ |
Precomputed MSA/template search results corresponding to the FASTA header. |
data/demo/monomer/alignments/6KWC_1/bfd_uniref_hits.a3m |
BFD/UniRef alignment results. |
data/demo/monomer/alignments/6KWC_1/uniref90_hits.sto |
UniRef90 alignment results. |
data/demo/monomer/alignments/6KWC_1/mgnify_hits.sto |
MGnify alignment results. |
data/demo/monomer/alignments/6KWC_1/hhsearch_output.hhr |
HHsearch template search results. |
data/demo/monomer/inference.sh |
Monomer inference example script using the FASTA and precomputed alignments above. |
The example data does not include OpenFold weights or the PDB mmCIF template library. Before running the demo, prepare:
weight/openfold.pt, or specify the weights withCHECKPOINT_PATH=/path/to/openfold.pt.- The PDB mmCIF template directory. By default,
data/databases/pdb_mmcif/mmcif_filesis read; it can also be specified withTEMPLATE_MMCIF_DIR=/path/to/mmcif_files.
Run the example:
bash data/demo/monomer/inference.sh
To use another device, set MODEL_DEVICE:
MODEL_DEVICE=cuda:0 bash data/demo/monomer/inference.sh
Inference Example
python scripts/inference.py /path/to/fasta_dir /path/to/template_mmcif_dir \
--output_dir ./outputs/inference \
--config_preset model_1_ptm \
--model_device cuda:0 \
--use_precomputed_alignments /path/to/alignments \
--openfold_checkpoint_path ./weight/openfold.pt
If using AlphaFold JAX parameters:
python scripts/inference.py /path/to/fasta_dir /path/to/template_mmcif_dir \
--output_dir ./outputs/inference \
--config_preset model_1_ptm \
--model_device cuda:0 \
--use_precomputed_alignments /path/to/alignments \
--jax_param_path ./weight/params_model_1_ptm.npz
Training Example
python scripts/train.py \
/path/to/train_mmcif \
/path/to/train_alignments \
/path/to/template_mmcif \
./outputs/train \
2021-10-10 \
--config_preset initial_training \
--max_epochs 1 \
--train_epoch_len 1 \
--gpus 1
Multi-GPU training can be launched with torchrun; adjust the specific parameters according to your runtime environment.
Data and Weight Downloads
OpenFold weights:
bash scripts/download_openfold_params.sh ./weights
Hugging Face weights:
bash scripts/download_openfold_params_huggingface.sh ./weights
PDB mmCIF template library:
bash scripts/download_pdb_mmcif.sh /path/to/database_dir
Complete AlphaFold/OpenFold databases:
bash scripts/download_alphafold_dbs.sh /path/to/database_dir full_dbs
Official OneScience Information
| 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 |
Citations and License
Original OpenFold paper: OpenFold: Retraining AlphaFold2 yields new insights into its learning mechanisms and capacity for generalization.
Original AlphaFold2 paper: Highly accurate protein structure prediction with AlphaFold.
If you use OpenFold's multimer prediction functionality, you should also cite the original AlphaFold-Multimer paper: Protein complex prediction with AlphaFold-Multimer.
If you use OpenProteinSet training data, you should also cite: OpenProteinSet: Training data for structural biology at scale.
OpenFold-related source code uses the Apache License 2.0. See
LICENSEin the repository root for details. The terms of use for model weights and data should follow the instructions provided by the corresponding publishers.The OpenProteinSet dataset uses the CC BY 4.0 License. When using this dataset, you should acknowledge the data source and cite the OpenProteinSet paper as required by the dataset page.
If you use OpenFold in research, it is recommended to cite the original OpenFold and AlphaFold2 papers as well as relevant OneScience project information. When using multimer functionality, also cite AlphaFold-Multimer. When using OpenProteinSet or other downstream data resources, also include citations for the corresponding datasets, databases, and original papers.
中文说明
模型简介
OpenFold 是一个开源框架,使用蛋白质序列、多序列比对(MSAs)及模板信息进行三维蛋白质结构预测(protein structure prediction)。作为 AlphaFold2 的可训练复现,其核心网络架构包括 Evoformer、Structure Module、模板模块、MSA 模块等组件,支持包含训练、推理(inference)和权重转换的完整结构预测实验流程。
论文:OpenFold:重新训练 AlphaFold2 揭示其学习机制和泛化能力 https://www.biorxiv.org/content/10.1101/2022.11.20.517210v2
模型描述
OpenFold 基于 Evoformer + Structure Module 架构,使用 PDB 和 UniRef 数据训练,适用于三维蛋白质结构预测、模型微调(fine-tuning)和架构改进研究。核心网络包含 48 个 Evoformer Blocks 和 8 层 Structure Module,通过三角注意力和不变点注意力机制实现进化信息与空间几何的双向融合。与原版 AlphaFold2 相比,OpenFold 增加了节省显存的注意力机制、混合精度训练支持和无缝权重转换功能,显著减少了 GPU 显存使用并解决了可训练性问题。
适用场景
| 场景 | 说明 |
|---|---|
| 在本地调用 OpenFold | 用户可通过本仓库的脚本调用 OpenFold 的训练或推理。 |
| 复用 OneScience 基础组件 | 继续使用 datapipes、utils、loss 和 np 等 OneScience 共享模块。 |
| 在 ModelScope/OneCode 发布 | 仅发布脚本、模型、配置及权重目录,以缩小发布包体积。 |
| 权重转换和数据准备 | 使用 scripts/ 下的工具下载数据库、预处理序列比对及转换权重。 |
使用指南
1. 使用 OneCode
通过 OneCode 在线环境体验智能一键 AI4S 编程。
2. 手动安装与使用
硬件要求
- 建议在 GPU 或 DCU 上运行。
- CPU 可用于导入检查与小型配置连通性验证,完整训练和推理速度较慢。
- DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的适配当前集群的版本。
3. 快速开始
下载模型包
hf download OneScience-Group/OpenFold --local-dir ./OpenFold
cd OpenFold
安装运行环境
DCU 环境
# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation is supported
pip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
快速验证
PYTHONPATH=$(pwd)/model python -c "from openfold.model import AlphaFold; from config.config import model_config; import onescience; print('openfold wrapper ok')"
如果提示缺少 torch、ml_collections 或 deepspeed 等依赖,请先安装 OneScience 推荐的运行环境,或安装对应 DCU/GPU 版本的依赖。
示例数据
data/ 目录存放 OpenFold 所需的示例输入及用户提供的数据。当前仓库在 data/demo/monomer 中包含单体推理示例,便于快速检查推理脚本、模型导入及序列比对加载流程。
目录结构
| Path | 说明 |
|---|---|
data/demo/monomer/fasta_dir/6kwc.fasta |
示例蛋白质序列。FASTA 标题为 6KWC_1。 |
data/demo/monomer/alignments/6KWC_1/ |
与 FASTA 标题对应的预计算 MSA/模板搜索结果。 |
data/demo/monomer/alignments/6KWC_1/bfd_uniref_hits.a3m |
BFD/UniRef 序列比对结果。 |
data/demo/monomer/alignments/6KWC_1/uniref90_hits.sto |
UniRef90 序列比对结果。 |
data/demo/monomer/alignments/6KWC_1/mgnify_hits.sto |
MGnify 序列比对结果。 |
data/demo/monomer/alignments/6KWC_1/hhsearch_output.hhr |
HHsearch 模板搜索结果。 |
data/demo/monomer/inference.sh |
使用上述 FASTA 和预计算序列比对的单体推理示例脚本。 |
示例数据未包含 OpenFold 权重或 PDB mmCIF 模板库。运行示例前,请准备以下内容。
weight/openfold.pt,或通过CHECKPOINT_PATH=/path/to/openfold.pt指定权重。- PDB mmCIF 模板目录。默认读取
data/databases/pdb_mmcif/mmcif_files,也可通过TEMPLATE_MMCIF_DIR=/path/to/mmcif_files指定。
运行示例
bash data/demo/monomer/inference.sh
如需使用其他设备,请设置 MODEL_DEVICE。
MODEL_DEVICE=cuda:0 bash data/demo/monomer/inference.sh
推理示例
python scripts/inference.py /path/to/fasta_dir /path/to/template_mmcif_dir \
--output_dir ./outputs/inference \
--config_preset model_1_ptm \
--model_device cuda:0 \
--use_precomputed_alignments /path/to/alignments \
--openfold_checkpoint_path ./weight/openfold.pt
如果使用 AlphaFold JAX 参数,请运行以下命令。
python scripts/inference.py /path/to/fasta_dir /path/to/template_mmcif_dir \
--output_dir ./outputs/inference \
--config_preset model_1_ptm \
--model_device cuda:0 \
--use_precomputed_alignments /path/to/alignments \
--jax_param_path ./weight/params_model_1_ptm.npz
训练示例
python scripts/train.py \
/path/to/train_mmcif \
/path/to/train_alignments \
/path/to/template_mmcif \
./outputs/train \
2021-10-10 \
--config_preset initial_training \
--max_epochs 1 \
--train_epoch_len 1 \
--gpus 1
可使用 torchrun 启动多 GPU 训练,具体参数按运行环境调整。
下载数据及权重
OpenFold 权重
bash scripts/download_openfold_params.sh ./weights
Hugging Face 权重
bash scripts/download_openfold_params_huggingface.sh ./weights
PDB mmCIF 模板库
bash scripts/download_pdb_mmcif.sh /path/to/database_dir
完整的 AlphaFold/OpenFold 数据库
bash scripts/download_alphafold_dbs.sh /path/to/database_dir full_dbs
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 |
引用与许可证
OpenFold 原始论文:OpenFold:重新训练 AlphaFold2 揭示其学习机制和泛化能力。
AlphaFold2 原始论文:使用 AlphaFold 实现高精度蛋白质结构预测。
如果使用 OpenFold 的多聚体预测功能,还应引用 AlphaFold-Multimer 原始论文:使用 AlphaFold-Multimer 预测蛋白质复合物。
如果使用 OpenProteinSet 训练数据,还应引用 OpenProteinSet:面向大规模结构生物学的训练数据。
OpenFold 相关源代码采用 Apache License 2.0 许可证,详见仓库根目录的
LICENSE。模型权重及数据的使用条款遵循对应发布方的说明。OpenProteinSet 数据集采用 CC BY 4.0 许可证。使用数据集时,应按数据集页面的要求致谢数据来源并引用 OpenProteinSet 论文。
如果在研究中使用 OpenFold,建议引用 OpenFold 和 AlphaFold2 原始论文及相关 OneScience 项目信息。使用多聚体功能时,也请引用 AlphaFold-Multimer。使用 OpenProteinSet 或其他下游数据资源时,还请引用对应数据集、数据库及原始论文。
- Downloads last month
- 12