AlphaFold3
Model Introduction
AlphaFold 3 is a biomolecular structure prediction model developed by Google DeepMind and Isomorphic Labs. It predicts the three-dimensional structures and interactions of proteins, DNA, RNA, small-molecule ligands, and their complexes.
Paper: Accurate structure prediction of biomolecular interactions with AlphaFold 3
https://www.nature.com/articles/s41586-024-07487-w
Model Description
AlphaFold 3 uses a Pairformer and a diffusion model to predict biomolecular complex structures. This model package provides a JAX / Flax inference implementation and database-search scripts, together with the accompanying Hugging Face dataset OneScience-Group/AlphaFold3_dataset.
Use Cases
| Scenario | Description |
|---|---|
| Direct inference from existing features | Takes an AlphaFold 3 JSON file containing precomputed features such as MSAs and templates as input and produces structure predictions |
| Protein structure prediction | Takes a protein sequence as input, generates features by searching databases, and predicts its structure |
| Biomolecular complex modeling | Takes multicomponent systems comprising proteins, DNA, RNA, ligands, and other molecules as input and predicts their 3D structures |
| Database-search pipeline validation | Uses Jackhmmer / Nhmmer or MMseqs pipelines to verify database paths and the availability of search tools |
| Hugging Face / OneCode execution | After downloading the model project and complete dataset, quickly verifies that the scripts run correctly in a life-sciences runtime environment |
Usage Instructions
1. OneCode
Try one-click AI4S development in the OneCode online environment:
Try one-click AI4S development
2. Manual Installation
Hardware Requirements
- GPU or DCU is recommended.
- A CPU can be used for import checks and lightweight configuration tests; full training and inference will be slow.
- DCU users must install DTK in advance. DTK 25.04.2 or later is recommended, or a OneScience-recommended version matching the current cluster.
Environment Check
- NVIDIA GPU:
nvidia-smi
- Hygon DCU:
hy-smi
Download the Model Package
hf download OneScience-Group/AlphaFold3 --local-dir ./AlphaFold3
cd AlphaFold3
Install the Runtime Environment
DCU Environment
# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation supported
pip install onescience[bio-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
After installation, return to the model package directory:
cd ./AlphaFold3
If the AlphaFold 3 C++ extension and runtime data files have not yet been built in the current environment, run:
python -m onescience.flax_model.alphafold3.build_extension
python -m onescience.flax_models.alphafold3.build_data
Training and Inference Data Overview
The OneScience community has uploaded the complete data required for AlphaFold 3 inference and database searches to Hugging Face: OneScience-Group/AlphaFold3_dataset. This model package does not include a training entry point; the dataset is primarily used to construct MSA / template features and perform database searches before inference.
hf download OneScience-Group/AlphaFold3_dataset \
--repo-type dataset \
--local-dir ./data/alphafold3
Model Weights
Model weights will be available soon.
Preparing Weights
Place the AlphaFold 3 model weights in the following directory, or specify them via environment variables:
weight/
AlphaFold3/
...
Default lookup order:
ALPHAFOLD3_MODEL_DIR${ONESCIENCE_MODELS_DIR}/AlphaFold3weight/AlphaFold3
Example:
export ALPHAFOLD3_MODEL_DIR=/path/to/AlphaFold3
Direct Inference
When the input JSON already contains features such as MSA and templates, you can run inference directly:
bash scripts/infer.sh
Equivalent Python command example:
python scripts/run_alphafold.py \
--json_path inputs/7r6r_data.json \
--model_dir weight/AlphaFold3 \
--output_dir outputs \
--run_data_pipeline=false \
--flash_attention_implementation=triton
Output is written to outputs/ and includes the top-ranked structure, structures generated from different seed / sample combinations, a CSV file containing ranking scores, and a copy of the input JSON.
Jackhmmer / Nhmmer Database Search
When the input JSON contains only sequences and requires a local database search, use:
bash scripts/infer_jackhmmer.sh
Common environment variables:
export ALPHAFOLD3_DATASET_ROOT=/path/to/alphafold3
export ALPHAFOLD3_MODEL_DIR=/path/to/AlphaFold3
export ALPHAFOLD3_JSON_PATH=inputs/t1119_search.json
export ALPHAFOLD3_OUTPUT_DIR=outputs
export ALPHAFOLD3_RUN_INFERENCE=false
ALPHAFOLD3_DATASET_ROOT is expected to contain directories such as public_databases/, jackhmmer_split/, and mmseqsDB/.
MMseqs Database Search
If the runtime environment provides the MMseqs executable and the required MMseqs databases, use:
bash scripts/infer_mmseqs.sh
Common environment variables:
export ALPHAFOLD3_MMSEQS_HOME=/path/to/mmseqs
export ALPHAFOLD3_DATASET_ROOT=/path/to/alphafold3
export ALPHAFOLD3_MMSEQS_DB_DIR=/path/to/alphafold3/mmseqsDB
export ALPHAFOLD3_RUN_INFERENCE=false
To proceed with inference after the database search, set ALPHAFOLD3_RUN_INFERENCE to true and ensure that the weights directory is available.
Data Format
AlphaFold 3 inputs are provided in JSON format with the following basic structure:
{
"dialect": "alphafold3",
"version": 1,
"name": "example",
"sequences": [
{
"protein": {
"id": "A",
"sequence": "..."
}
}
],
"modelSeeds": [100],
"bondedAtomPairs": null,
"userCCD": null
}
This repository provides two examples:
inputs/7r6r_data.json: contains sequence, MSA, and template information; suitable for direct inference.inputs/t1119_search.json: contains only sequences; suitable for database-search pipeline validation.
It is recommended to download the full Hugging Face dataset OneScience-Group/AlphaFold3_dataset to data/alphafold3/ under the model package. The relative directory structure expected by the database-search pipeline is as follows:
data/
alphafold3/
public_databases/
mmcif_files/
pdb_seqres_2022_09_28.fasta
...
jackhmmer_split/
bfd-first_non_consensus_sequences.fasta@64
mgy_clusters_2022_05.fa@512
uniprot_cluster_annot_2021_04.fa@256
uniref90_2022_05.fa@128
mmseqsDB/
small_bfd_db
mgnify_db
uniprot_cluster_annot_db
uniref90_db
Verification
Static import check:
python tests/check_import_boundaries.py
OneScience Official 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 |
Citation & License
- This repository is adapted from the open-source AlphaFold 3 model to support DCUs.
- The AlphaFold 3 source code is licensed under CC BY-NC-SA 4.0; model parameters are subject to separate usage terms.
- For scientific use, please cite the original paper: Accurate structure prediction of biomolecular interactions with AlphaFold 3.
中文说明
模型简介
AlphaFold 3 是由 Google DeepMind 和 Isomorphic Labs 开发的生物分子结构预测模型。它可预测蛋白质、DNA、RNA、小分子配体及其复合物的三维结构和相互作用。
论文:使用 AlphaFold 3 精确预测生物分子相互作用结构
https://www.nature.com/articles/s41586-024-07487-w
模型描述
AlphaFold 3 使用 Pairformer 和扩散模型预测生物分子复合物结构。此模型包包含基于 JAX / Flax 的推理(inference)实现和数据库搜索脚本,以及配套的 Hugging Face 数据集 OneScience-Group/AlphaFold3_dataset。
使用场景
| 场景 | 说明 |
|---|---|
| 使用已有特征直接推理 | 以包含 MSA 和模板等预计算特征的 AlphaFold 3 JSON 文件为输入,生成结构预测结果 |
| 蛋白质结构预测(protein structure prediction) | 输入蛋白质序列,通过搜索数据库生成特征并预测其结构 |
| 生物分子复合物建模 | 输入由蛋白质、DNA、RNA、配体及其他分子组成的多组分体系,预测其 3D 结构 |
| 数据库搜索流程验证 | 使用 Jackhmmer / Nhmmer 或 MMseqs 流程检查数据库路径和搜索工具的可用性 |
| Hugging Face / OneCode 运行 | 下载模型项目及完整数据集后,快速验证脚本能否在生命科学运行环境中正常运行 |
使用指南
1. OneCode
通过 OneCode 在线环境体验一键 AI4S 开发。
2. 手动安装
硬件要求
- 建议使用 GPU 或 DCU。
- CPU 可用于导入检查和轻量配置测试,完整训练和推理速度较慢。
- DCU 用户必须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的与当前集群匹配的版本。
环境检查
- NVIDIA GPU
nvidia-smi
- Hygon DCU
hy-smi
下载模型包
hf download OneScience-Group/AlphaFold3 --local-dir ./AlphaFold3
cd AlphaFold3
安装运行环境
DCU 环境
# Activate DTK and CONDA first
conda create -n onescience311 python=3.11 -y
conda activate onescience311
# uv installation supported
pip install onescience[bio-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
安装后返回模型包目录。
cd ./AlphaFold3
如果尚未在当前环境中构建 AlphaFold 3 的 C++ 扩展和运行时数据文件,请运行以下命令。
python -m onescience.flax_model.alphafold3.build_extension
python -m onescience.flax_models.alphafold3.build_data
训练和推理数据概览
OneScience 社区已将 AlphaFold 3 推理及数据库搜索所需的完整数据上传到 Hugging Face,见 OneScience-Group/AlphaFold3_dataset。本模型包不含训练入口,数据集主要用于在推理前构建 MSA / 模板特征和搜索数据库。
hf download OneScience-Group/AlphaFold3_dataset \
--repo-type dataset \
--local-dir ./data/alphafold3
模型权重
模型权重即将提供。
准备权重
将 AlphaFold 3 模型权重放入以下目录,或通过环境变量指定路径。
weight/
AlphaFold3/
...
默认查找顺序
ALPHAFOLD3_MODEL_DIR${ONESCIENCE_MODELS_DIR}/AlphaFold3weight/AlphaFold3
示例
export ALPHAFOLD3_MODEL_DIR=/path/to/AlphaFold3
直接推理
当输入 JSON 已包含 MSA 和模板等特征时,可以直接运行推理。
bash scripts/infer.sh
等效的 Python 命令示例
python scripts/run_alphafold.py \
--json_path inputs/7r6r_data.json \
--model_dir weight/AlphaFold3 \
--output_dir outputs \
--run_data_pipeline=false \
--flash_attention_implementation=triton
输出写入 outputs/,包括排名最高的结构、由不同随机种子和样本组合生成的结构、包含排名分数的 CSV 文件以及输入 JSON 的副本。
Jackhmmer / Nhmmer 数据库搜索
当输入 JSON 仅包含序列且需要搜索本地数据库时,请使用以下命令。
bash scripts/infer_jackhmmer.sh
常用环境变量
export ALPHAFOLD3_DATASET_ROOT=/path/to/alphafold3
export ALPHAFOLD3_MODEL_DIR=/path/to/AlphaFold3
export ALPHAFOLD3_JSON_PATH=inputs/t1119_search.json
export ALPHAFOLD3_OUTPUT_DIR=outputs
export ALPHAFOLD3_RUN_INFERENCE=false
ALPHAFOLD3_DATASET_ROOT 应包含 public_databases/、jackhmmer_split/ 和 mmseqsDB/ 等目录。
MMseqs 数据库搜索
如果运行环境提供 MMseqs 可执行文件及所需的 MMseqs 数据库,请使用以下命令。
bash scripts/infer_mmseqs.sh
常用环境变量
export ALPHAFOLD3_MMSEQS_HOME=/path/to/mmseqs
export ALPHAFOLD3_DATASET_ROOT=/path/to/alphafold3
export ALPHAFOLD3_MMSEQS_DB_DIR=/path/to/alphafold3/mmseqsDB
export ALPHAFOLD3_RUN_INFERENCE=false
若要在数据库搜索完成后继续推理,将 ALPHAFOLD3_RUN_INFERENCE 设为 true,并确保权重目录可用。
数据格式
AlphaFold 3 的输入采用 JSON 格式,基本结构如下。
{
"dialect": "alphafold3",
"version": 1,
"name": "example",
"sequences": [
{
"protein": {
"id": "A",
"sequence": "..."
}
}
],
"modelSeeds": [100],
"bondedAtomPairs": null,
"userCCD": null
}
本仓库提供两个示例。
inputs/7r6r_data.json包含序列、MSA 和模板信息,适用于直接推理。inputs/t1119_search.json仅包含序列,适用于验证数据库搜索流程。
建议将 Hugging Face 上的完整数据集 OneScience-Group/AlphaFold3_dataset 下载至模型包下的 data/alphafold3/。数据库搜索流程所需的相对目录结构如下。
data/
alphafold3/
public_databases/
mmcif_files/
pdb_seqres_2022_09_28.fasta
...
jackhmmer_split/
bfd-first_non_consensus_sequences.fasta@64
mgy_clusters_2022_05.fa@512
uniprot_cluster_annot_2021_04.fa@256
uniref90_2022_05.fa@128
mmseqsDB/
small_bfd_db
mgnify_db
uniprot_cluster_annot_db
uniref90_db
验证
静态导入检查
python tests/check_import_boundaries.py
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 3 模型改编,以支持 DCU。
- AlphaFold 3 源代码采用 CC BY-NC-SA 4.0 许可,模型参数另行适用使用条款。
- 用于科学研究时,请引用原始论文 使用 AlphaFold 3 精确预测生物分子相互作用结构。
- Downloads last month
- 30