# AF2 ## 论文 - [https://www.nature.com/articles/s41586-021-03819-2](https://www.nature.com/articles/s41586-021-03819-2) ## 模型结构 模型核心是一个基于Transformer架构的神经网络,包括两个主要组件:Sequence to Sequence Model和Structure Model,这两个组件通过迭代训练进行优化,以提高其预测准确性。 ![img](./docs/alphafold2.png) ## 算法原理 AlphaFold2通过从蛋白质序列和结构数据中提取信息,使用神经网络模型来预测蛋白质三维结构。 ![img](./docs/alphafold2_1.png) ## 环境配置 提供[光源](https://www.sourcefind.cn/#/service-details)拉取推理的docker镜像: ``` docker pull image.sourcefind.cn:5000/dcu/admin/base/custom:alphafold2-2.2.1-centos7.6-dtk-22.04.2-py38 # 用上面拉取docker镜像的ID替换 # 主机端路径 # 容器映射路径 docker run -it --name alphafold --shm-size=32G --device=/dev/kfd --device=/dev/dri/ --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --ulimit memlock=-1:-1 --ipc=host --network host --group-add video -v : /bin/bash ``` 镜像版本依赖: * DTK驱动:dtk22.04.2 * Jax: 0.3.14 * TensorFlow2: 2.10.0 * python: python3.8 激活镜像环境: `source /opt/dtk-22.04.2/env.sh` `source /opt/openmm-hip/env.sh` 测试目录: `/opt/docker/tests/alphafold` ## 数据集 推荐使用AlphaFold2中的开源数据集,包括BFD、MGnify、PDB70、Uniclust、Uniref90等,数据集大小约2.2TB。数据集格式如下: ``` $DOWNLOAD_DIR/ bfd/ bfd_metaclust_clu_complete_id30_c90_final_seq.sorted_opt_hhm.ffindex bfd_metaclust_clu_complete_id30_c90_final_seq.sorted_opt_hhm.ffdata bfd_metaclust_clu_complete_id30_c90_final_seq.sorted_opt_cs219.ffindex ... mgnify/ mgy_clusters_2018_12.fa params/ params_model_1.npz params_model_2.npz params_model_3.npz ... pdb70/ pdb_filter.dat pdb70_hhm.ffindex pdb70_hhm.ffdata ... pdb_mmcif/ mmcif_files/ 100d.cif 101d.cif 101m.cif ... obsolete.dat pdb_seqres/ pdb_seqres.txt small_bfd/ bfd-first_non_consensus_sequences.fasta uniclust30/ uniclust30_2018_08/ uniclust30_2018_08_md5sum uniclust30_2018_08_hhm_db.index uniclust30_2018_08_hhm_db ... uniprot/ uniprot.fasta uniref90/ uniref90.fasta ``` 此处提供了一个脚本download_all_data.sh用于下载使用的数据集和模型文件: ./scripts/download_all_data.sh 数据集下载目录 ## 推理 分别提供了基于Jax的单体和多体的推理脚本. 设置DOWNLOAD_DIR路径和output_dir路径。确保输出目录存在,并且您有足够的权限对其进行写入。 # Set to target of download all databases DOWNLOAD_DIR = '/path/to/database' # Path to a directory that will store the results. output_dir = '/path/to/output_dir' ### 单体 python3 run_alphafold.py \ --fasta_paths=monomer.fasta \ --output_dir=./ \ --max_template_date=2020-05-14 \ --model_preset=monomer \ --run_relax=true \ --use_gpu_relax=true 或者使用`./run_monomer.sh` #### 单体推理参数说明 monomer.fasta为推理的单体序列;`--output_dir`为输出目录;`--model_preset`选择模型配置;`--run_relax=true`为进行relax操作;`--use_gpu_relax=true`为使用gpu进行relax操作(速度更快,但可能不太稳定),`--use_gpu_relax=false`为使用CPU进行relax操作(速度慢,但稳定);若添加--use_precomputed_msas=true则可以加载已经搜索对齐的序列,否则默认进行搜索对齐; ### 多体 python3 run_alphafold.py \ --fasta_paths=multimer.fasta \ --output_dir=./ \ --uniprot_database_path=/data/uniprot/uniprot_trembl.fasta \ --pdb_seqres_database_path=/data/pdb_seqres/pdb_seqres.txt \ --pdb70_database_path= \ --max_template_date=2020-05-14 \ --model_preset=multimer \ --run_relax=true \ --use_gpu_relax=true 或者使用`./run_multimer.sh` #### 多体推理参数说明 multimer.fasta为推理的多体序列,data为数据集下载路径,其他参数同单体推理参数说明一致。 ## result `--output_dir`目录结构如下: ``` / features.pkl ranked_{0,1,2,3,4}.pdb ranking_debug.json relaxed_model_{1,2,3,4,5}.pdb result_model_{1,2,3,4,5}.pkl timings.json unrelaxed_model_{1,2,3,4,5}.pdb msas/ bfd_uniclust_hits.a3m mgnify_hits.sto uniref90_hits.sto ... ``` 查看蛋白质3D结构:[https://www.pdbus.org/3d-view](https://www.pdbus.org/3d-view) ![img](./docs/result_pdb.png) ## 精度 测试数据:[casp14](https://www.predictioncenter.org/casp14/targetlist.cgi)、[uniprot](https://www.uniprot.org/), 使用的加速卡:1张 DCU 1代-16G 1、计算lddt的值 python3 pkl2plddt.py 其中,data_path为推理生成的pkl文件路径。 2、其它精度值计算:[https://zhanggroup.org/TM-score/](https://zhanggroup.org/TM-score/) 准确性数据: | 数据类型 | 序列类型 | 序列标签 | 序列长度 | GDT-TS | GDT-HA | LDDT | TM score | MaxSub | RMSD | | :------: | :------: | :------: | :------: |:------: |:------: | :------: | :------: | :------: |:------: | | fp32 | 单体 | T1026 | 172 | 0.849 | 0.658 | 75.050 | 0.901 | 0.851 | 1.6 | | fp32 | 单体 | T1053 | 580 | 0.941 | 0.789 | 92.316 | 0.985 | 0.935 | 1.1 | | fp32 | 单体 | T1091 | 863 | 0.492 | 0.332 | 85.083 | 0.740 | 0.388 | 6.7 | ## 应用场景 ### 算法类别 NLP ### 热点应用行业 医疗,科研,教育 ## 源码仓库及问题反馈 * [https://developer.hpccube.com/codes/modelzoo/alphafold2_jax](https://developer.hpccube.com/codes/modelzoo/alphafold2_jax) ## 参考 * [https://github.com/deepmind/alphafold](https://github.com/deepmind/alphafold)