Add Chinese README section
Browse files199 unmodified lines200201202199 unmodified lines- 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.199 unmodified lines200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393199 unmodified lines- 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 编程。[体验智能一键 AI4S 编程](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)### 2. 手动安装与使用**硬件要求**- 建议在 GPU 或 DCU 上运行。- CPU 可用于导入检查与小型配置连通性验证,完整训练和推理速度较慢。- DCU 用户须提前安装 DTK。建议使用 DTK 25.04.2 或更高版本,或使用 OneScience 推荐的适配当前集群的版本。### 3. 快速开始#### 下载模型包```bashhf download OneScience-Group/OpenFold --local-dir ./OpenFoldcd OpenFold```#### 安装运行环境##### DCU 环境```bash# Activate DTK and CONDA firstconda create -n onescience311 python=3.11 -yconda activate onescience311# uv installation is supportedpip install onescience[bio] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai```### 快速验证```bashPYTHONPATH=$(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` 指定。运行示例```bashbash data/demo/monomer/inference.sh```如需��用其他设备,请设置 `MODEL_DEVICE`。```bashMODEL_DEVICE=cuda:0 bash data/demo/monomer/inference.sh```### 推理示例```bashpython 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 参数,请运行以下命令。```bashpython 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```### 训练示例```bashpython 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 权重```bashbash scripts/download_openfold_params.sh ./weights```Hugging Face 权重```bashbash scripts/download_openfold_params_huggingface.sh ./weights```PDB mmCIF 模板库```bashbash scripts/download_pdb_mmcif.sh /path/to/database_dir```完整的 AlphaFold/OpenFold 数据库```bashbash 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 揭示其学习机制和泛化能力](https://www.biorxiv.org/content/10.1101/2022.11.20.517210)。- AlphaFold2 原始论文:[使用 AlphaFold 实现高精度蛋白质结构预测](https://www.nature.com/articles/s41586-021-03819-2)。- 如果使用 OpenFold 的多聚体预测功能,还应引用 AlphaFold-Multimer 原始论文:[使用 AlphaFold-Multimer 预测蛋白质复合物](https://www.biorxiv.org/content/10.1101/2021.10.04.463034v1)。- 如果使用 OpenProteinSet 训练数据,还应引用 [OpenProteinSet:面向大规模结构生物学的训练数据](https://arxiv.org/abs/2308.05326)。- OpenFold 相关源代码采用 Apache License 2.0 许可证,详见仓库根目录的 `LICENSE`。模型权重及数据的使用条款遵循对应发布方的说明。- OpenProteinSet 数据集采用 CC BY 4.0 许可证。使用数据集时,应按数据集页面的要求致谢数据来源并引用 OpenProteinSet 论文。- 如果在研究中使用 OpenFold,建议引用 OpenFold 和 AlphaFold2 原始论文及相关 OneScience 项目信息。使用多聚体功能时,也请引用 AlphaFold-Multimer。使用 OpenProteinSet 或其他下游数据资源时,还请引用对应数据集、数据库及原始论文。
README.md+191