Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +45 -0
- .msc +3 -0
- .mv +1 -0
- LICENSE +10 -0
- README.md +277 -0
- configuration.json +1 -0
- data/README.md +14 -0
- flax_model/__init__.py +1 -0
- flax_model/alphafold3/CMakeLists.txt +161 -0
- flax_model/alphafold3/README.md +81 -0
- flax_model/alphafold3/__init__.py +26 -0
- flax_model/alphafold3/_build.py +649 -0
- flax_model/alphafold3/_data/libcifpp/components.cif +3 -0
- flax_model/alphafold3/_data/libcifpp/mmcif_ddl.dic +0 -0
- flax_model/alphafold3/_data/libcifpp/mmcif_ma.dic +0 -0
- flax_model/alphafold3/_data/libcifpp/mmcif_pdbx.dic +0 -0
- flax_model/alphafold3/_tools/hmmer/.built +1 -0
- flax_model/alphafold3/_tools/hmmer/bin/alimask +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/easel +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-afetch +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alimanip +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alimap +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alimask +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alimerge +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alipid +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alirev +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-alistat +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-compalign +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-compstruct +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-construct +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-histplot +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-mask +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-mixdchlet +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-reformat +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-selectn +0 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-seqrange +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-seqstat +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-sfetch +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-shuffle +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-ssdraw +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-translate +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/esl-weight +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmalign +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmbuild +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmconvert +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmemit +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmfetch +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmlogo +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmpgmd +3 -0
- flax_model/alphafold3/_tools/hmmer/bin/hmmpgmd_shard +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,48 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
.msc filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
flax_model/alphafold3/_data/libcifpp/components.cif filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
flax_model/alphafold3/_tools/hmmer/bin/alimask filter=lfs diff=lfs merge=lfs -text
|
| 39 |
+
flax_model/alphafold3/_tools/hmmer/bin/easel filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-afetch filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alimanip filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alimap filter=lfs diff=lfs merge=lfs -text
|
| 43 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alimask filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alimerge filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alipid filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alirev filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-alistat filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-compalign filter=lfs diff=lfs merge=lfs -text
|
| 49 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-compstruct filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-construct filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-histplot filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-mask filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-mixdchlet filter=lfs diff=lfs merge=lfs -text
|
| 54 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-reformat filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-seqrange filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-seqstat filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-sfetch filter=lfs diff=lfs merge=lfs -text
|
| 58 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-shuffle filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-ssdraw filter=lfs diff=lfs merge=lfs -text
|
| 60 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-translate filter=lfs diff=lfs merge=lfs -text
|
| 61 |
+
flax_model/alphafold3/_tools/hmmer/bin/esl-weight filter=lfs diff=lfs merge=lfs -text
|
| 62 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmalign filter=lfs diff=lfs merge=lfs -text
|
| 63 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmbuild filter=lfs diff=lfs merge=lfs -text
|
| 64 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmconvert filter=lfs diff=lfs merge=lfs -text
|
| 65 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmemit filter=lfs diff=lfs merge=lfs -text
|
| 66 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmfetch filter=lfs diff=lfs merge=lfs -text
|
| 67 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmlogo filter=lfs diff=lfs merge=lfs -text
|
| 68 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmpgmd filter=lfs diff=lfs merge=lfs -text
|
| 69 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmpgmd_shard filter=lfs diff=lfs merge=lfs -text
|
| 70 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmpress filter=lfs diff=lfs merge=lfs -text
|
| 71 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmscan filter=lfs diff=lfs merge=lfs -text
|
| 72 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmsearch filter=lfs diff=lfs merge=lfs -text
|
| 73 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmsim filter=lfs diff=lfs merge=lfs -text
|
| 74 |
+
flax_model/alphafold3/_tools/hmmer/bin/hmmstat filter=lfs diff=lfs merge=lfs -text
|
| 75 |
+
flax_model/alphafold3/_tools/hmmer/bin/jackhmmer filter=lfs diff=lfs merge=lfs -text
|
| 76 |
+
flax_model/alphafold3/_tools/hmmer/bin/makehmmerdb filter=lfs diff=lfs merge=lfs -text
|
| 77 |
+
flax_model/alphafold3/_tools/hmmer/bin/nhmmer filter=lfs diff=lfs merge=lfs -text
|
| 78 |
+
flax_model/alphafold3/_tools/hmmer/bin/nhmmscan filter=lfs diff=lfs merge=lfs -text
|
| 79 |
+
flax_model/alphafold3/_tools/hmmer/bin/phmmer filter=lfs diff=lfs merge=lfs -text
|
| 80 |
+
flax_model/alphafold3/cpp.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
|
.msc
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:6129f311c9362dd58261a8352929e2f2dbeed73bbe7364170648ca396cb152ed
|
| 3 |
+
size 196183
|
.mv
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
Revision:master,CreatedAt:1784688613
|
LICENSE
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
AlphaFold3 source files in this split retain the license headers from the
|
| 2 |
+
upstream AlphaFold 3 implementation integrated in OneScience.
|
| 3 |
+
|
| 4 |
+
The copied AlphaFold3 source headers state that AlphaFold 3 source code is
|
| 5 |
+
licensed under CC BY-NC-SA 4.0 and refer to:
|
| 6 |
+
|
| 7 |
+
https://creativecommons.org/licenses/by-nc-sa/4.0/
|
| 8 |
+
|
| 9 |
+
Model parameters are not included in this repository and are subject to their
|
| 10 |
+
own terms of use.
|
README.md
ADDED
|
@@ -0,0 +1,277 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-nc-sa-4.0
|
| 3 |
+
tasks:
|
| 4 |
+
- protein-complex-structure-prediction
|
| 5 |
+
frameworks:
|
| 6 |
+
- jax
|
| 7 |
+
language:
|
| 8 |
+
- en
|
| 9 |
+
- zh
|
| 10 |
+
tags:
|
| 11 |
+
- OneScience
|
| 12 |
+
- Life Sciences
|
| 13 |
+
- Protein Structure Prediction
|
| 14 |
+
- Biomolecular Interactions
|
| 15 |
+
- Complex Structure Prediction
|
| 16 |
+
- AlphaFold3
|
| 17 |
+
datasets:
|
| 18 |
+
- OneScience/AlphaFold3_dataset
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
<p align="center">
|
| 22 |
+
<strong>
|
| 23 |
+
<span style="font-size: 30px;">AlphaFold3</span>
|
| 24 |
+
</strong>
|
| 25 |
+
</p>
|
| 26 |
+
|
| 27 |
+
# Model Introduction
|
| 28 |
+
|
| 29 |
+
AlphaFold3 is a biomolecular structure prediction model proposed by Google DeepMind and Isomorphic Labs. It can predict the three-dimensional structures and interactions of molecules and their complexes, including proteins, DNA, RNA, and small-molecule ligands.
|
| 30 |
+
|
| 31 |
+
Paper: Accurate structure prediction of biomolecular interactions with AlphaFold 3
|
| 32 |
+
https://www.nature.com/articles/s41586-024-07487-w
|
| 33 |
+
|
| 34 |
+
# Model Description
|
| 35 |
+
|
| 36 |
+
AlphaFold3 uses Pairformer and diffusion models to predict biomolecular complex structures. This model package provides a JAX / Flax inference project and data search scripts, and is released together with the ModelScope dataset `OneScience/AlphaFold3_dataset`.
|
| 37 |
+
|
| 38 |
+
# Applicable Scenarios
|
| 39 |
+
|
| 40 |
+
| Scenario | Description |
|
| 41 |
+
| :---: | :--- |
|
| 42 |
+
| Direct inference with existing features | Input an AlphaFold3 JSON containing features such as MSA / template, and output structure prediction results |
|
| 43 |
+
| Protein structure prediction | Input a protein sequence, generate features together with search databases, and predict the structure |
|
| 44 |
+
| Biomolecular complex modeling | Input multi-component objects such as proteins, DNA, RNA, and ligands, and predict the spatial conformation of the complex |
|
| 45 |
+
| Data search workflow verification | Use Jackhmmer / Nhmmer or MMseqs workflows to check database paths and search tool connectivity |
|
| 46 |
+
| ModelScope / OneCode runtime | After downloading the model project and complete dataset, quickly verify script connectivity in a biology-domain runtime environment |
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
# Usage Instructions
|
| 51 |
+
|
| 52 |
+
## 1. OneCode Usage
|
| 53 |
+
|
| 54 |
+
You can experience intelligent one-click AI4S programming through the OneCode online environment:
|
| 55 |
+
|
| 56 |
+
[Click to experience intelligent one-click AI4S programming](https://web-2069360198568017922-iaaj.ksai.scnet.cn:58043/home)
|
| 57 |
+
|
| 58 |
+
## 2. Manual Installation and Usage
|
| 59 |
+
|
| 60 |
+
**Hardware Requirements**
|
| 61 |
+
|
| 62 |
+
- GPU or DCU runtime is recommended.
|
| 63 |
+
- CPU can be used for import checks and small-configuration connectivity verification, but full training and inference are slow.
|
| 64 |
+
- DCU users need to install DTK in advance. DTK 25.04.2 or later is recommended, or the OneScience-recommended version matching the current cluster.
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
**Environment Check**
|
| 71 |
+
|
| 72 |
+
- NVIDIA GPU:
|
| 73 |
+
|
| 74 |
+
```bash
|
| 75 |
+
nvidia-smi
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
- Hygon DCU:
|
| 79 |
+
|
| 80 |
+
```bash
|
| 81 |
+
hy-smi
|
| 82 |
+
```
|
| 83 |
+
|
| 84 |
+
### Download the Model Package
|
| 85 |
+
|
| 86 |
+
```bash
|
| 87 |
+
modelscope download --model OneScience/AlphaFold3 --local_dir ./AlphaFold3
|
| 88 |
+
cd AlphaFold3
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
### Install the Runtime Environment
|
| 92 |
+
|
| 93 |
+
**DCU Environment**
|
| 94 |
+
|
| 95 |
+
```bash
|
| 96 |
+
# First activate DTK and Conda
|
| 97 |
+
conda create -n onescience311 python=3.11 -y
|
| 98 |
+
conda activate onescience311
|
| 99 |
+
# Supports uv installation
|
| 100 |
+
pip install onescience[bio-dcu] -i http://mirrors.onescience.ai:3141/pypi/simple/ --trusted-host mirrors.onescience.ai
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
After installation, return to the model package directory:
|
| 104 |
+
|
| 105 |
+
```bash
|
| 106 |
+
cd ./AlphaFold3
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
If the current environment has not yet built the AlphaFold3 C++ extension and runtime data files, execute:
|
| 110 |
+
|
| 111 |
+
```bash
|
| 112 |
+
python -m onescience.flax_model.alphafold3.build_extension
|
| 113 |
+
python -m onescience.flax_models.alphafold3.build_data
|
| 114 |
+
```
|
| 115 |
+
|
| 116 |
+
### Training and Inference Data Introduction
|
| 117 |
+
|
| 118 |
+
The OneScience community has uploaded the complete data required for AlphaFold3 inference and data search to ModelScope: [OneScience/AlphaFold3_dataset](https://modelscope.cn/datasets/OneScience/AlphaFold3_dataset). This model package does not include a training entry point; this dataset is mainly used for MSA / template feature construction and pre-inference data search.
|
| 119 |
+
|
| 120 |
+
```bash
|
| 121 |
+
modelscope download --dataset OneScience/AlphaFold3_dataset --local_dir ./data/alphafold3
|
| 122 |
+
```
|
| 123 |
+
### Training Weights
|
| 124 |
+
|
| 125 |
+
Weights will be uploaded soon.
|
| 126 |
+
|
| 127 |
+
### Prepare Weights
|
| 128 |
+
|
| 129 |
+
Place the AlphaFold3 model weights in the following directory, or specify them through an environment variable:
|
| 130 |
+
|
| 131 |
+
```text
|
| 132 |
+
weight/
|
| 133 |
+
AlphaFold3/
|
| 134 |
+
...
|
| 135 |
+
```
|
| 136 |
+
|
| 137 |
+
The default lookup order is:
|
| 138 |
+
|
| 139 |
+
- `ALPHAFOLD3_MODEL_DIR`
|
| 140 |
+
- `${ONESCIENCE_MODELS_DIR}/AlphaFold3`
|
| 141 |
+
- `weight/AlphaFold3`
|
| 142 |
+
|
| 143 |
+
Example:
|
| 144 |
+
|
| 145 |
+
```bash
|
| 146 |
+
export ALPHAFOLD3_MODEL_DIR=/path/to/AlphaFold3
|
| 147 |
+
```
|
| 148 |
+
|
| 149 |
+
### Direct Inference
|
| 150 |
+
|
| 151 |
+
When the input JSON already contains features such as MSA and template, you can run directly:
|
| 152 |
+
|
| 153 |
+
```bash
|
| 154 |
+
bash scripts/infer.sh
|
| 155 |
+
```
|
| 156 |
+
|
| 157 |
+
Equivalent Python command example:
|
| 158 |
+
|
| 159 |
+
```bash
|
| 160 |
+
python scripts/run_alphafold.py \
|
| 161 |
+
--json_path inputs/7r6r_data.json \
|
| 162 |
+
--model_dir weight/AlphaFold3 \
|
| 163 |
+
--output_dir outputs \
|
| 164 |
+
--run_data_pipeline=false \
|
| 165 |
+
--flash_attention_implementation=triton
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
The output will be written to `outputs/`, including the best structure, structure results for different seeds / samples, the ranking score CSV, and a copy of the input JSON.
|
| 169 |
+
|
| 170 |
+
### Jackhmmer / Nhmmer Data Search
|
| 171 |
+
|
| 172 |
+
When the input JSON contains only sequences and requires local database search, use:
|
| 173 |
+
|
| 174 |
+
```bash
|
| 175 |
+
bash scripts/infer_jackhmmer.sh
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
Common environment variables:
|
| 179 |
+
|
| 180 |
+
```bash
|
| 181 |
+
export ALPHAFOLD3_DATASET_ROOT=/path/to/alphafold3
|
| 182 |
+
export ALPHAFOLD3_MODEL_DIR=/path/to/AlphaFold3
|
| 183 |
+
export ALPHAFOLD3_JSON_PATH=inputs/t1119_search.json
|
| 184 |
+
export ALPHAFOLD3_OUTPUT_DIR=outputs
|
| 185 |
+
export ALPHAFOLD3_RUN_INFERENCE=false
|
| 186 |
+
```
|
| 187 |
+
|
| 188 |
+
Here, `ALPHAFOLD3_DATASET_ROOT` is expected by default to contain database directories such as `public_databases/`, `jackhmmer_split/`, and `mmseqsDB/`.
|
| 189 |
+
|
| 190 |
+
### MMseqs Data Search
|
| 191 |
+
|
| 192 |
+
If the runtime environment provides the MMseqs program and MMseqs database, use:
|
| 193 |
+
|
| 194 |
+
```bash
|
| 195 |
+
bash scripts/infer_mmseqs.sh
|
| 196 |
+
```
|
| 197 |
+
|
| 198 |
+
Common environment variables:
|
| 199 |
+
|
| 200 |
+
```bash
|
| 201 |
+
export ALPHAFOLD3_MMSEQS_HOME=/path/to/mmseqs
|
| 202 |
+
export ALPHAFOLD3_DATASET_ROOT=/path/to/alphafold3
|
| 203 |
+
export ALPHAFOLD3_MMSEQS_DB_DIR=/path/to/alphafold3/mmseqsDB
|
| 204 |
+
export ALPHAFOLD3_RUN_INFERENCE=false
|
| 205 |
+
```
|
| 206 |
+
|
| 207 |
+
To continue inference after searching, set `ALPHAFOLD3_RUN_INFERENCE` to `true` and make sure the weight directory is available.
|
| 208 |
+
|
| 209 |
+
# Data Format
|
| 210 |
+
|
| 211 |
+
AlphaFold3 input uses JSON format. The basic structure is as follows:
|
| 212 |
+
|
| 213 |
+
```json
|
| 214 |
+
{
|
| 215 |
+
"dialect": "alphafold3",
|
| 216 |
+
"version": 1,
|
| 217 |
+
"name": "example",
|
| 218 |
+
"sequences": [
|
| 219 |
+
{
|
| 220 |
+
"protein": {
|
| 221 |
+
"id": "A",
|
| 222 |
+
"sequence": "..."
|
| 223 |
+
}
|
| 224 |
+
}
|
| 225 |
+
],
|
| 226 |
+
"modelSeeds": [100],
|
| 227 |
+
"bondedAtomPairs": null,
|
| 228 |
+
"userCCD": null
|
| 229 |
+
}
|
| 230 |
+
```
|
| 231 |
+
|
| 232 |
+
This repository provides two examples:
|
| 233 |
+
|
| 234 |
+
- `inputs/7r6r_data.json`: Contains information such as sequence, MSA, and template, and is suitable for direct inference.
|
| 235 |
+
- `inputs/t1119_search.json`: Contains only sequence and is suitable for data search workflow verification.
|
| 236 |
+
|
| 237 |
+
The complete ModelScope dataset `OneScience/AlphaFold3_dataset` is recommended to be downloaded to `data/alphafold3/` under the model package. The relative structure read by the data search workflow by default is as follows:
|
| 238 |
+
|
| 239 |
+
```text
|
| 240 |
+
data/
|
| 241 |
+
alphafold3/
|
| 242 |
+
public_databases/
|
| 243 |
+
mmcif_files/
|
| 244 |
+
pdb_seqres_2022_09_28.fasta
|
| 245 |
+
...
|
| 246 |
+
jackhmmer_split/
|
| 247 |
+
bfd-first_non_consensus_sequences.fasta@64
|
| 248 |
+
mgy_clusters_2022_05.fa@512
|
| 249 |
+
uniprot_cluster_annot_2021_04.fa@256
|
| 250 |
+
uniref90_2022_05.fa@128
|
| 251 |
+
mmseqsDB/
|
| 252 |
+
small_bfd_db
|
| 253 |
+
mgnify_db
|
| 254 |
+
uniprot_cluster_annot_db
|
| 255 |
+
uniref90_db
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
+
# Verification
|
| 259 |
+
|
| 260 |
+
Static import check:
|
| 261 |
+
|
| 262 |
+
```bash
|
| 263 |
+
python tests/check_import_boundaries.py
|
| 264 |
+
```
|
| 265 |
+
|
| 266 |
+
# Official OneScience Information
|
| 267 |
+
|
| 268 |
+
| Platform | OneScience Main Repository | Skills Repository |
|
| 269 |
+
| --- | --- | --- |
|
| 270 |
+
| Gitee | https://gitee.com/onescience-ai/onescience | https://gitee.com/onescience-ai/oneskills |
|
| 271 |
+
| GitHub | https://github.com/onescience-ai/OneScience | https://github.com/onescience-ai/oneskills |
|
| 272 |
+
|
| 273 |
+
# Citations and License
|
| 274 |
+
|
| 275 |
+
- This repository is based on the AlphaFold3 open-source model and provides DCU adaptation.
|
| 276 |
+
- AlphaFold3 source code uses the CC BY-NC-SA 4.0 license; model parameters are subject to separate terms of use.
|
| 277 |
+
- For scientific research, cite the original paper: [Accurate structure prediction of biomolecular interactions with AlphaFold 3](https://www.nature.com/articles/s41586-024-07487-w).
|
configuration.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"framework":"JAX","task":"protein-structure-prediction"}
|
data/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This model repository does not upload the AlphaFold3 dataset payload.
|
| 2 |
+
|
| 3 |
+
Download the required dataset separately:
|
| 4 |
+
|
| 5 |
+
```bash
|
| 6 |
+
modelscope download --dataset OneScience/AlphaFold3_dataset
|
| 7 |
+
```
|
| 8 |
+
|
| 9 |
+
Then link the dataset package data directory into this model package:
|
| 10 |
+
|
| 11 |
+
```bash
|
| 12 |
+
mkdir -p data
|
| 13 |
+
ln -s /path/to/AlphaFold3_dataset/data data/alphafold3_dataset
|
| 14 |
+
```
|
flax_model/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""Local flax model namespace for the split AlphaFold3 project."""
|
flax_model/alphafold3/CMakeLists.txt
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Copyright 2024 DeepMind Technologies Limited
|
| 2 |
+
#
|
| 3 |
+
# AlphaFold 3 source code is licensed under CC BY-NC-SA 4.0. To view a copy of
|
| 4 |
+
# this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/
|
| 5 |
+
#
|
| 6 |
+
# To request access to the AlphaFold 3 model parameters, follow the process set
|
| 7 |
+
# out at https://github.com/google-deepmind/alphafold3. You may only use these
|
| 8 |
+
# if received directly from Google. Use is subject to terms of use available at
|
| 9 |
+
# https://github.com/google-deepmind/alphafold3/blob/main/WEIGHTS_TERMS_OF_USE.md
|
| 10 |
+
|
| 11 |
+
cmake_minimum_required(VERSION 3.24)
|
| 12 |
+
project(
|
| 13 |
+
"${SKBUILD_PROJECT_NAME}"
|
| 14 |
+
LANGUAGES CXX
|
| 15 |
+
VERSION "${SKBUILD_PROJECT_VERSION}")
|
| 16 |
+
|
| 17 |
+
include(FetchContent)
|
| 18 |
+
set(CMAKE_CXX_STANDARD 20)
|
| 19 |
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
| 20 |
+
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
| 21 |
+
set(ABSL_PROPAGATE_CXX_STD ON)
|
| 22 |
+
|
| 23 |
+
# Remove support for scan deps, which is only useful when using C++ modules.
|
| 24 |
+
unset(CMAKE_CXX_SCANDEP_SOURCE)
|
| 25 |
+
|
| 26 |
+
set(ENV{GIT_CONFIG_PARAMETERS} "'init.defaultRefFormat=files'")
|
| 27 |
+
|
| 28 |
+
if(DEFINED ENV{ALPHAFOLD3_DEP_DIR})
|
| 29 |
+
set(DEP_BASE_DIR "$ENV{ALPHAFOLD3_DEP_DIR}")
|
| 30 |
+
endif()
|
| 31 |
+
|
| 32 |
+
function(declare_af3_dependency dep_name local_path_env repo_env tag_env)
|
| 33 |
+
if(DEFINED ENV{${local_path_env}} AND EXISTS "$ENV{${local_path_env}}")
|
| 34 |
+
message(STATUS "Using local dependency for ${dep_name}: $ENV{${local_path_env}}")
|
| 35 |
+
FetchContent_Declare(
|
| 36 |
+
${dep_name}
|
| 37 |
+
SOURCE_DIR $ENV{${local_path_env}}
|
| 38 |
+
${ARGN})
|
| 39 |
+
else()
|
| 40 |
+
message(STATUS "Fetching remote dependency for ${dep_name}: $ENV{${repo_env}} @ $ENV{${tag_env}}")
|
| 41 |
+
FetchContent_Declare(
|
| 42 |
+
${dep_name}
|
| 43 |
+
GIT_REPOSITORY $ENV{${repo_env}}
|
| 44 |
+
GIT_TAG $ENV{${tag_env}}
|
| 45 |
+
${ARGN})
|
| 46 |
+
endif()
|
| 47 |
+
endfunction()
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
declare_af3_dependency(
|
| 51 |
+
abseil-cpp
|
| 52 |
+
ABSEIL_LOCAL_PATH
|
| 53 |
+
ABSEIL_REPO
|
| 54 |
+
ABSEIL_TAG
|
| 55 |
+
EXCLUDE_FROM_ALL)
|
| 56 |
+
|
| 57 |
+
declare_af3_dependency(
|
| 58 |
+
pybind11
|
| 59 |
+
PYBIND11_LOCAL_PATH
|
| 60 |
+
PYBIND11_REPO
|
| 61 |
+
PYBIND11_TAG
|
| 62 |
+
EXCLUDE_FROM_ALL)
|
| 63 |
+
|
| 64 |
+
declare_af3_dependency(
|
| 65 |
+
pybind11_abseil
|
| 66 |
+
PYBIND11_ABSEIL_LOCAL_PATH
|
| 67 |
+
PYBIND11_ABSEIL_REPO
|
| 68 |
+
PYBIND11_ABSEIL_TAG
|
| 69 |
+
EXCLUDE_FROM_ALL)
|
| 70 |
+
|
| 71 |
+
declare_af3_dependency(
|
| 72 |
+
cifpp
|
| 73 |
+
CIFPP_LOCAL_PATH
|
| 74 |
+
CIFPP_REPO
|
| 75 |
+
CIFPP_TAG)
|
| 76 |
+
|
| 77 |
+
declare_af3_dependency(
|
| 78 |
+
dssp
|
| 79 |
+
DSSP_LOCAL_PATH
|
| 80 |
+
DSSP_REPO
|
| 81 |
+
DSSP_TAG
|
| 82 |
+
EXCLUDE_FROM_ALL)
|
| 83 |
+
|
| 84 |
+
if(DEFINED ENV{ALPHAFOLD3_INSTALL_PREFIX})
|
| 85 |
+
set(CMAKE_INSTALL_PREFIX $ENV{ALPHAFOLD3_INSTALL_PREFIX} CACHE PATH "Install prefix" FORCE)
|
| 86 |
+
message(STATUS "Setting install prefix to AlphaFold3 package directory: $ENV{ALPHAFOLD3_INSTALL_PREFIX}")
|
| 87 |
+
elseif(DEFINED ENV{CONDA_PREFIX})
|
| 88 |
+
set(CMAKE_INSTALL_PREFIX $ENV{CONDA_PREFIX} CACHE PATH "Install prefix" FORCE)
|
| 89 |
+
message(STATUS "Setting install prefix to conda environment: $ENV{CONDA_PREFIX}")
|
| 90 |
+
endif()
|
| 91 |
+
|
| 92 |
+
if(DEFINED ENV{ALPHAFOLD3_CIFPP_DATA_DIR})
|
| 93 |
+
set(CIFPP_DATA_DIR "$ENV{ALPHAFOLD3_CIFPP_DATA_DIR}" CACHE PATH "CIFPP data directory" FORCE)
|
| 94 |
+
message(STATUS "Setting CIFPP_DATA_DIR to ${CIFPP_DATA_DIR}")
|
| 95 |
+
elseif(DEFINED ENV{CONDA_PREFIX})
|
| 96 |
+
execute_process(
|
| 97 |
+
COMMAND python -c "import site; print(site.getsitepackages()[0])"
|
| 98 |
+
OUTPUT_VARIABLE PYTHON_SITE_PACKAGES
|
| 99 |
+
OUTPUT_STRIP_TRAILING_WHITESPACE
|
| 100 |
+
ERROR_QUIET
|
| 101 |
+
)
|
| 102 |
+
|
| 103 |
+
if(PYTHON_SITE_PACKAGES)
|
| 104 |
+
set(CIFPP_DATA_DIR "${PYTHON_SITE_PACKAGES}/share/libcifpp" CACHE PATH "CIFPP data directory" FORCE)
|
| 105 |
+
message(STATUS "Setting CIFPP_DATA_DIR to Python site-packages: ${CIFPP_DATA_DIR}")
|
| 106 |
+
endif()
|
| 107 |
+
endif()
|
| 108 |
+
|
| 109 |
+
FetchContent_MakeAvailable(pybind11 abseil-cpp pybind11_abseil cifpp dssp)
|
| 110 |
+
|
| 111 |
+
find_package(
|
| 112 |
+
Python3
|
| 113 |
+
COMPONENTS Interpreter Development NumPy
|
| 114 |
+
REQUIRED)
|
| 115 |
+
|
| 116 |
+
message(STATUS "AF3 Python3_EXECUTABLE=${Python3_EXECUTABLE}")
|
| 117 |
+
message(STATUS "AF3 Python3_VERSION=${Python3_VERSION}")
|
| 118 |
+
message(STATUS "AF3 Python3_INCLUDE_DIRS=${Python3_INCLUDE_DIRS}")
|
| 119 |
+
message(STATUS "AF3 Python3_SITELIB=${Python3_SITELIB}")
|
| 120 |
+
message(STATUS "AF3 Python3_SITEARCH=${Python3_SITEARCH}")
|
| 121 |
+
message(STATUS "AF3 Python3_NumPy_INCLUDE_DIRS=${Python3_NumPy_INCLUDE_DIRS}")
|
| 122 |
+
|
| 123 |
+
include_directories(${Python3_INCLUDE_DIRS})
|
| 124 |
+
include_directories(${Python3_NumPy_INCLUDE_DIRS})
|
| 125 |
+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
|
| 126 |
+
|
| 127 |
+
# Only compile AF3's own C++ sources.
|
| 128 |
+
file(GLOB_RECURSE cpp_srcs ${CMAKE_CURRENT_SOURCE_DIR}/*.cc)
|
| 129 |
+
# Drop any third-party / build-time sources such as benchmarks/tests/examples.
|
| 130 |
+
list(FILTER cpp_srcs EXCLUDE REGEX ".*/_deps/.*")
|
| 131 |
+
list(FILTER cpp_srcs EXCLUDE REGEX ".*/mirror_deps/.*")
|
| 132 |
+
list(FILTER cpp_srcs EXCLUDE REGEX ".*/CMake/install_test_project/.*")
|
| 133 |
+
list(FILTER cpp_srcs EXCLUDE REGEX "${CMAKE_CURRENT_SOURCE_DIR}/test/.*")
|
| 134 |
+
#list(FILTER cpp_srcs EXCLUDE REGEX ".*\\(_test\\|_main\\|_benchmark\\).cc$")
|
| 135 |
+
list(FILTER cpp_srcs EXCLUDE REGEX ".*(_test|_main|_benchmark)\\.cc$")
|
| 136 |
+
message(STATUS "AF3 cpp_srcs after filter: ${cpp_srcs}")
|
| 137 |
+
|
| 138 |
+
add_compile_definitions(NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
|
| 139 |
+
|
| 140 |
+
pybind11_add_module(cpp ${cpp_srcs})
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
|
| 144 |
+
target_link_libraries(
|
| 145 |
+
cpp
|
| 146 |
+
PRIVATE absl::check
|
| 147 |
+
absl::flat_hash_map
|
| 148 |
+
absl::node_hash_map
|
| 149 |
+
absl::strings
|
| 150 |
+
absl::status
|
| 151 |
+
absl::statusor
|
| 152 |
+
absl::log
|
| 153 |
+
pybind11_abseil::absl_casters
|
| 154 |
+
Python3::NumPy
|
| 155 |
+
dssp::dssp
|
| 156 |
+
cifpp::cifpp)
|
| 157 |
+
|
| 158 |
+
target_compile_definitions(cpp PRIVATE VERSION_INFO=${PROJECT_VERSION})
|
| 159 |
+
install(TARGETS cpp LIBRARY DESTINATION .)
|
| 160 |
+
|
| 161 |
+
|
flax_model/alphafold3/README.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AlphaFold 3 Integration for OneScience
|
| 2 |
+
|
| 3 |
+
This is the AlphaFold 3 implementation integrated into the OneScience framework as a submodule.
|
| 4 |
+
|
| 5 |
+
## Overview
|
| 6 |
+
|
| 7 |
+
AlphaFold 3 is a state-of-the-art machine learning model for predicting protein structure, developed by DeepMind. This submodule integrates AlphaFold 3 into the OneScience framework, allowing it to be used as part of larger scientific computing workflows.
|
| 8 |
+
|
| 9 |
+
## Installation
|
| 10 |
+
|
| 11 |
+
### As Part of OneScience
|
| 12 |
+
|
| 13 |
+
The recommended way to install alphafold3 is as part of the complete OneScience package:
|
| 14 |
+
|
| 15 |
+
```bash
|
| 16 |
+
# Install OneScience with alphafold3 support
|
| 17 |
+
|
| 18 |
+
# install jackhmmer
|
| 19 |
+
# mkdir ~/hmmer_build ~/hmmer
|
| 20 |
+
# wget http://eddylab.org/software/hmmer/hmmer-3.4.tar.gz --directory-prefix ~/hmmer_build
|
| 21 |
+
# cd ~/hmmer_build && tar zxf hmmer-3.4.tar.gz && rm hmmer-3.4.tar.gz
|
| 22 |
+
# patch -p0 < jackhmmer_seq_limit.patch
|
| 23 |
+
# cd ~/hmmer-3.4
|
| 24 |
+
# ./configure --prefix ~/hmmer
|
| 25 |
+
# make -j && make install && cd ./easel && make install
|
| 26 |
+
# rm -R ~/hmmer_build
|
| 27 |
+
|
| 28 |
+
# # install extension
|
| 29 |
+
# pip install .[bio] -c constraints.txt
|
| 30 |
+
# cp -r /public/onestore/onedatasets/alphafold3/_dep xxx/
|
| 31 |
+
# export ALPHAFOLD3_DEP_DIR=/public/onestore/onedatasets/alphafold3/_dep
|
| 32 |
+
# cd src/onescience/flax_models/alphafold3/
|
| 33 |
+
# python build_extension.py
|
| 34 |
+
|
| 35 |
+
# optional create mmseqs2 database (please contact ai4s@sugon.com for mmseqs2 program)
|
| 36 |
+
export mmfasta=/root/public_databases
|
| 37 |
+
cd /root/public_databases && mkdir mmseqsDB
|
| 38 |
+
export mmdb=/root/public_databases/mmseqsDB
|
| 39 |
+
export CUDA_VISIBLE_DEVICES=0
|
| 40 |
+
mmseqs createdb $mmfasta/bfd-first_non_consensus_sequences.fasta $mmdb/small_bfd_db --gpu 1 --threads 32 --createdb-mode 2
|
| 41 |
+
mmseqs createdb $mmfasta/mgy_clusters_2022_05.fa $mmdb/mgnify_db --gpu 1 --threads 32 --createdb-mode 2
|
| 42 |
+
mmseqs createdb $mmfasta/uniprot_all_2021_04.fa $mmdb/uniprot_cluster_annot_db --gpu 1 --threads 32 --createdb-mode 2
|
| 43 |
+
mmseqs createdb $mmfasta/uniref90_2022_05.fa $mmdb/uniref90_db --gpu 1 --threads 32 --createdb-mode 2
|
| 44 |
+
```
|
| 45 |
+
|
| 46 |
+
## Usage
|
| 47 |
+
|
| 48 |
+
```python
|
| 49 |
+
# Import alphafold3 as part of onescience
|
| 50 |
+
import flax_model.alphafold3 as af3
|
| 51 |
+
|
| 52 |
+
# Access alphafold3 components
|
| 53 |
+
from flax_model.alphafold3 import structure, model, data
|
| 54 |
+
|
| 55 |
+
# Use alphafold3 functionality
|
| 56 |
+
print(f"AlphaFold3 version: {af3.__version__}")
|
| 57 |
+
```
|
| 58 |
+
|
| 59 |
+
## Requirements
|
| 60 |
+
|
| 61 |
+
- Python 3.11+
|
| 62 |
+
- JAX with CUDA support (optional, for GPU acceleration)
|
| 63 |
+
- CMake 3.28+ (for building C++ extensions)
|
| 64 |
+
- Additional dependencies listed in pyproject.toml
|
| 65 |
+
|
| 66 |
+
## License
|
| 67 |
+
|
| 68 |
+
This code is licensed under CC BY-NC-SA 4.0. See the original AlphaFold 3 repository for more details on usage restrictions and licensing terms.
|
| 69 |
+
|
| 70 |
+
## Citation
|
| 71 |
+
|
| 72 |
+
If you use this code in your research, please cite the AlphaFold 3 paper:
|
| 73 |
+
|
| 74 |
+
```
|
| 75 |
+
Abramson, J., Adler, J., Dunger, J. et al. Accurate structure prediction of biomolecular interactions with AlphaFold 3. Nature 630, 493�?00 (2024).
|
| 76 |
+
```
|
| 77 |
+
|
| 78 |
+
## Links
|
| 79 |
+
|
| 80 |
+
- [Original AlphaFold 3 Repository](https://github.com/google-deepmind/alphafold3)
|
| 81 |
+
- [AlphaFold 3 Paper](https://www.nature.com/articles/s41586-024-07487-w)
|
flax_model/alphafold3/__init__.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
|
| 3 |
+
"""An implementation of the inference pipeline of AlphaFold 3."""
|
| 4 |
+
from importlib import resources
|
| 5 |
+
from pathlib import Path
|
| 6 |
+
import os
|
| 7 |
+
import warnings
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _data_artifacts_exist() -> bool:
|
| 11 |
+
try:
|
| 12 |
+
root = Path(
|
| 13 |
+
resources.files(__name__ + ".constants.converters")
|
| 14 |
+
)
|
| 15 |
+
except Exception:
|
| 16 |
+
return False
|
| 17 |
+
return (root / "ccd.pickle").exists() and (root / "chemical_component_sets.pickle").exists()
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
if not _data_artifacts_exist():
|
| 21 |
+
warnings.warn(
|
| 22 |
+
"AlphaFold3 data files (ccd.pickle, chemical_component_sets.pickle) are missing.\n"
|
| 23 |
+
"Please run the following command once to build local artifacts:\n\n"
|
| 24 |
+
" python -m flax_model.alphafold3.build_extension\n",
|
| 25 |
+
stacklevel=1,
|
| 26 |
+
)
|
flax_model/alphafold3/_build.py
ADDED
|
@@ -0,0 +1,649 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
import shutil
|
| 4 |
+
import subprocess
|
| 5 |
+
import sys
|
| 6 |
+
import sysconfig
|
| 7 |
+
import tarfile
|
| 8 |
+
import tempfile
|
| 9 |
+
import urllib.request
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
|
| 12 |
+
ROOT = Path(__file__).resolve().parents[2]
|
| 13 |
+
MIRROR_CONFIG_PATH = ROOT / "docs" / "af3_dependency_mirrors.template.json"
|
| 14 |
+
AF3_DIR = Path(__file__).resolve().parent
|
| 15 |
+
CONVERTERS_DIR = AF3_DIR / "constants" / "converters"
|
| 16 |
+
TMP_ROOT = Path(os.environ.get("ALPHAFOLD3_TMP_ROOT", tempfile.gettempdir())).resolve() / "alphafold3_split_af3"
|
| 17 |
+
BUILD_DIR = TMP_ROOT / "build"
|
| 18 |
+
REMOTE_DEPS_DIR = TMP_ROOT / "mirror_deps"
|
| 19 |
+
HMMER_INSTALL_DIR = AF3_DIR / "_tools" / "hmmer"
|
| 20 |
+
HMMER_BIN_DIR = HMMER_INSTALL_DIR / "bin"
|
| 21 |
+
HMMER_PATCH_PATH = AF3_DIR / "jackhmmer_seq_limit.patch"
|
| 22 |
+
HMMER_SOURCE_URL = "https://gitee.com/zhang-yuqi-sudo/hmmer-github/releases/download/hmmer-3.4/hmmer-3.4.tar.gz"
|
| 23 |
+
HMMER_ARCHIVE_NAME = "hmmer-3.4.tar.gz"
|
| 24 |
+
HMMER_SOURCE_DIRNAME = "hmmer-3.4"
|
| 25 |
+
HMMER_BINARIES = ("jackhmmer", "nhmmer", "hmmalign", "hmmsearch", "hmmbuild")
|
| 26 |
+
HMMER_BUILD_ROOT = TMP_ROOT / "hmmer_build"
|
| 27 |
+
HMMER_BUILD_DIR = HMMER_BUILD_ROOT / HMMER_SOURCE_DIRNAME
|
| 28 |
+
HMMER_ARCHIVE_PATH = HMMER_BUILD_ROOT / HMMER_ARCHIVE_NAME
|
| 29 |
+
HMMER_PATCH_MARKER = HMMER_BUILD_ROOT / ".patch_applied"
|
| 30 |
+
HMMER_BUILD_MARKER = HMMER_INSTALL_DIR / ".built"
|
| 31 |
+
DATA_FILES = (
|
| 32 |
+
CONVERTERS_DIR / "ccd.pickle",
|
| 33 |
+
CONVERTERS_DIR / "chemical_component_sets.pickle",
|
| 34 |
+
)
|
| 35 |
+
LIB_PATTERNS = ("cpp*.so", "cpp*.pyd", "cpp*.dll", "cpp*.dylib")
|
| 36 |
+
|
| 37 |
+
TOP_LEVEL_MIRROR_MAP = {
|
| 38 |
+
"abseil-cpp": "ABSEIL",
|
| 39 |
+
"pybind11": "PYBIND11",
|
| 40 |
+
"pybind11_abseil": "PYBIND11_ABSEIL",
|
| 41 |
+
"libcifpp": "CIFPP",
|
| 42 |
+
"dssp": "DSSP",
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
DEFAULT_DOWNSTREAM_TAGS = {
|
| 46 |
+
"boost-regex": "boost-1.87.0",
|
| 47 |
+
"libmcfp": "v1.4.2",
|
| 48 |
+
"catch2": "v3.4.0",
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
PREPARED_ENV: dict[str, str] | None = None
|
| 52 |
+
PREPARED_DEP_DIR: Path | None = None
|
| 53 |
+
PREPARED_REMOTE = False
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
class AF3BuildError(RuntimeError):
|
| 57 |
+
pass
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def _env_flag(name: str, default: str = "auto") -> str:
|
| 61 |
+
return os.environ.get(name, default).strip().lower()
|
| 62 |
+
|
| 63 |
+
|
| 64 |
+
def load_mirror_config() -> dict:
|
| 65 |
+
if not MIRROR_CONFIG_PATH.exists():
|
| 66 |
+
return {}
|
| 67 |
+
return json.loads(MIRROR_CONFIG_PATH.read_text())
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def mirror_value(name: str, field: str, default: str | None = None) -> str | None:
|
| 71 |
+
entry = load_mirror_config().get(name, {})
|
| 72 |
+
value = entry.get(field)
|
| 73 |
+
if isinstance(value, str) and value.strip() and "<fill-" not in value and "<your-org>" not in value:
|
| 74 |
+
return value.strip()
|
| 75 |
+
return default
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def reset_prepared_state() -> None:
|
| 79 |
+
global PREPARED_ENV, PREPARED_DEP_DIR, PREPARED_REMOTE
|
| 80 |
+
PREPARED_ENV = None
|
| 81 |
+
PREPARED_DEP_DIR = None
|
| 82 |
+
PREPARED_REMOTE = False
|
| 83 |
+
|
| 84 |
+
|
| 85 |
+
def should_build() -> bool:
|
| 86 |
+
if _env_flag("ALPHAFOLD3_SKIP_BUILD", "0") in {"1", "true", "on", "yes"}:
|
| 87 |
+
return False
|
| 88 |
+
if _env_flag("ONESCIENCE_SKIP_AF3_BUILD", "0") in {"1", "true", "on", "yes"}:
|
| 89 |
+
return False
|
| 90 |
+
mode = _env_flag("ALPHAFOLD3_BUILD", _env_flag("ONESCIENCE_BUILD_AF3", "auto"))
|
| 91 |
+
if mode in {"0", "false", "off", "no"}:
|
| 92 |
+
return False
|
| 93 |
+
if mode in {"1", "true", "on", "yes", "force"}:
|
| 94 |
+
return True
|
| 95 |
+
return AF3_DIR.exists()
|
| 96 |
+
|
| 97 |
+
|
| 98 |
+
def is_strict() -> bool:
|
| 99 |
+
return _env_flag("ALPHAFOLD3_STRICT", _env_flag("ONESCIENCE_AF3_STRICT", "0")) in {"1", "true", "on", "yes"}
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def force_rebuild() -> bool:
|
| 103 |
+
return _env_flag("ALPHAFOLD3_FORCE_REBUILD", _env_flag("ONESCIENCE_AF3_FORCE_REBUILD", "0")) in {"1", "true", "on", "yes"}
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
def resolve_dep_dir() -> Path | None:
|
| 107 |
+
dep_dir = os.environ.get("ALPHAFOLD3_DEP_DIR")
|
| 108 |
+
if dep_dir:
|
| 109 |
+
return Path(dep_dir).expanduser().resolve()
|
| 110 |
+
candidate = ROOT / "third_party" / "alphafold3_deps"
|
| 111 |
+
if candidate.exists():
|
| 112 |
+
return candidate
|
| 113 |
+
return None
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def using_remote_dependencies() -> bool:
|
| 117 |
+
return resolve_dep_dir() is None
|
| 118 |
+
|
| 119 |
+
|
| 120 |
+
def install_destination() -> Path:
|
| 121 |
+
return AF3_DIR
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
def build_data_output_dir() -> Path:
|
| 125 |
+
return CONVERTERS_DIR
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def cifpp_data_dir() -> Path | None:
|
| 129 |
+
env_path = os.environ.get("ALPHAFOLD3_CIFPP_DATA_DIR")
|
| 130 |
+
if env_path:
|
| 131 |
+
return Path(env_path)
|
| 132 |
+
return AF3_DIR / "_data" / "libcifpp"
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
def cifpp_components_path() -> Path | None:
|
| 136 |
+
data_dir = cifpp_data_dir()
|
| 137 |
+
if data_dir is None:
|
| 138 |
+
return None
|
| 139 |
+
return data_dir / "components.cif"
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def current_python_include_dir() -> str:
|
| 143 |
+
paths = sysconfig.get_paths()
|
| 144 |
+
return paths.get("include", "")
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def current_numpy_include_dir() -> str | None:
|
| 148 |
+
try:
|
| 149 |
+
import numpy
|
| 150 |
+
return numpy.get_include()
|
| 151 |
+
except Exception:
|
| 152 |
+
return None
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def _lib_exists() -> bool:
|
| 156 |
+
return any(AF3_DIR.glob(pattern) for pattern in LIB_PATTERNS)
|
| 157 |
+
|
| 158 |
+
|
| 159 |
+
def _data_exists() -> bool:
|
| 160 |
+
return all(path.exists() for path in DATA_FILES)
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def artifacts_exist() -> bool:
|
| 164 |
+
return _lib_exists() and _data_exists()
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
def hmmer_binaries_exist() -> bool:
|
| 168 |
+
return all((HMMER_BIN_DIR / name).exists() for name in HMMER_BINARIES)
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
def download_hmmer_source() -> None:
|
| 172 |
+
if HMMER_ARCHIVE_PATH.exists():
|
| 173 |
+
return
|
| 174 |
+
HMMER_BUILD_ROOT.mkdir(parents=True, exist_ok=True)
|
| 175 |
+
print(f"[AF3] downloading HMMER source from {HMMER_SOURCE_URL}")
|
| 176 |
+
urllib.request.urlretrieve(HMMER_SOURCE_URL, HMMER_ARCHIVE_PATH)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def extract_hmmer_source() -> None:
|
| 180 |
+
if HMMER_BUILD_DIR.exists():
|
| 181 |
+
return
|
| 182 |
+
HMMER_BUILD_ROOT.mkdir(parents=True, exist_ok=True)
|
| 183 |
+
with tarfile.open(HMMER_ARCHIVE_PATH, "r:gz") as tar:
|
| 184 |
+
tar.extractall(HMMER_BUILD_ROOT)
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def apply_hmmer_patch() -> None:
|
| 188 |
+
if HMMER_PATCH_MARKER.exists():
|
| 189 |
+
return
|
| 190 |
+
subprocess.run(
|
| 191 |
+
["patch", "-p0", "-i", str(HMMER_PATCH_PATH.resolve())],
|
| 192 |
+
cwd=HMMER_BUILD_ROOT,
|
| 193 |
+
check=True,
|
| 194 |
+
)
|
| 195 |
+
HMMER_PATCH_MARKER.write_text("patched\n")
|
| 196 |
+
|
| 197 |
+
|
| 198 |
+
def build_hmmer_tools() -> None:
|
| 199 |
+
if hmmer_binaries_exist() and HMMER_BUILD_MARKER.exists():
|
| 200 |
+
return
|
| 201 |
+
if shutil.which("make") is None and shutil.which("gmake") is None:
|
| 202 |
+
raise AF3BuildError("make or gmake is required to build HMMER tools.")
|
| 203 |
+
make_program = shutil.which("gmake") or shutil.which("make")
|
| 204 |
+
download_hmmer_source()
|
| 205 |
+
extract_hmmer_source()
|
| 206 |
+
apply_hmmer_patch()
|
| 207 |
+
HMMER_INSTALL_DIR.mkdir(parents=True, exist_ok=True)
|
| 208 |
+
print(f"[AF3] building HMMER tools into {HMMER_INSTALL_DIR}")
|
| 209 |
+
try:
|
| 210 |
+
subprocess.run(["./configure", f"--prefix={HMMER_INSTALL_DIR}"], cwd=HMMER_BUILD_DIR, check=True)
|
| 211 |
+
build_parallelism = min(os.cpu_count() or 8, 64)
|
| 212 |
+
subprocess.run([make_program, "-j", str(build_parallelism)], cwd=HMMER_BUILD_DIR, check=True)
|
| 213 |
+
subprocess.run([make_program, "install"], cwd=HMMER_BUILD_DIR, check=True)
|
| 214 |
+
subprocess.run([make_program, "install"], cwd=HMMER_BUILD_DIR / "easel", check=True)
|
| 215 |
+
except subprocess.CalledProcessError as exc:
|
| 216 |
+
raise AF3BuildError(
|
| 217 |
+
f"HMMER tools build failed with exit code {exc.returncode}. "
|
| 218 |
+
f"Check HMMER build logs under {HMMER_BUILD_DIR} for details."
|
| 219 |
+
) from exc
|
| 220 |
+
HMMER_BUILD_MARKER.write_text("built\n")
|
| 221 |
+
print(f"[AF3] HMMER tools ready at {HMMER_BIN_DIR}")
|
| 222 |
+
|
| 223 |
+
def ensure_hmmer_tools_ready() -> None:
|
| 224 |
+
if hmmer_binaries_exist():
|
| 225 |
+
return
|
| 226 |
+
if shutil.which("patch") is None:
|
| 227 |
+
raise AF3BuildError("patch is required to build HMMER tools.")
|
| 228 |
+
build_hmmer_tools()
|
| 229 |
+
|
| 230 |
+
|
| 231 |
+
def ensure_dependencies_ready() -> None:
|
| 232 |
+
dep_dir = resolve_dep_dir()
|
| 233 |
+
if dep_dir is None:
|
| 234 |
+
return
|
| 235 |
+
required = ("abseil-cpp", "pybind11", "pybind11_abseil", "libcifpp", "dssp")
|
| 236 |
+
missing = [name for name in required if not (dep_dir / name).exists()]
|
| 237 |
+
if missing:
|
| 238 |
+
raise AF3BuildError(
|
| 239 |
+
f"AlphaFold3 dependency directories are missing under {dep_dir}: {', '.join(missing)}"
|
| 240 |
+
)
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
def ensure_build_prerequisites() -> None:
|
| 244 |
+
if shutil.which("cmake") is None:
|
| 245 |
+
raise AF3BuildError("CMake is required to build AlphaFold3.")
|
| 246 |
+
if using_remote_dependencies() and shutil.which("git") is None:
|
| 247 |
+
raise AF3BuildError(
|
| 248 |
+
"Git is required for remote AlphaFold3 dependency fetching when no local dependency directory is configured."
|
| 249 |
+
)
|
| 250 |
+
ensure_dependencies_ready()
|
| 251 |
+
ensure_hmmer_tools_ready()
|
| 252 |
+
|
| 253 |
+
|
| 254 |
+
def resolve_fetch_base() -> str:
|
| 255 |
+
return os.environ.get("ALPHAFOLD3_FETCH_BASE", "https://gitee.com/zhang-yuqi-sudo").rstrip("/")
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def dependency_specs() -> dict[str, dict[str, str]]:
|
| 259 |
+
base = resolve_fetch_base()
|
| 260 |
+
return {
|
| 261 |
+
"ABSEIL": {"repo": f"{base}/abseil-cpp", "tag": "d7aaad83b488fd62bd51c81ecf16cd938532cc0a", "local_path": "abseil-cpp"},
|
| 262 |
+
"PYBIND11": {"repo": f"{base}/pybind11", "tag": "2e0815278cb899b20870a67ca8205996ef47e70f", "local_path": "pybind11"},
|
| 263 |
+
"PYBIND11_ABSEIL": {"repo": f"{base}/pybind11_abseil", "tag": "bddf30141f9fec8e577f515313caec45f559d319", "local_path": "pybind11_abseil"},
|
| 264 |
+
"CIFPP": {"repo": f"{base}/libcifpp", "tag": "ac98531a2fc8daf21131faa0c3d73766efa46180", "local_path": "libcifpp"},
|
| 265 |
+
"DSSP": {"repo": f"{base}/dssp", "tag": "57560472b4260dc41f457706bc45fc6ef0bc0f10", "local_path": "dssp"},
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
|
| 269 |
+
def announce_build_mode() -> None:
|
| 270 |
+
if PREPARED_DEP_DIR is not None and PREPARED_REMOTE:
|
| 271 |
+
print(f"Using prepared mirrored dependencies from {PREPARED_DEP_DIR}.")
|
| 272 |
+
elif PREPARED_DEP_DIR is not None:
|
| 273 |
+
print(f"Using local AlphaFold3 dependencies from {PREPARED_DEP_DIR}.")
|
| 274 |
+
elif using_remote_dependencies():
|
| 275 |
+
print(f"Using remote AlphaFold3 dependencies from {resolve_fetch_base()}.")
|
| 276 |
+
else:
|
| 277 |
+
print(f"Using local AlphaFold3 dependencies from {resolve_dep_dir()}.")
|
| 278 |
+
|
| 279 |
+
|
| 280 |
+
def announce_install_destination() -> None:
|
| 281 |
+
print(f"Installing AlphaFold3 artifacts into {install_destination()}.")
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def announce_data_destination() -> None:
|
| 285 |
+
print(f"Writing AlphaFold3 data files into {build_data_output_dir()}.")
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
def announce_cifpp_data_location() -> None:
|
| 289 |
+
data_dir = cifpp_data_dir()
|
| 290 |
+
if data_dir is not None:
|
| 291 |
+
print(f"Using libcifpp data directory {data_dir}.")
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def announce_mirror_overrides() -> None:
|
| 295 |
+
config = load_mirror_config()
|
| 296 |
+
active = []
|
| 297 |
+
for name, entry in config.items():
|
| 298 |
+
mirror = entry.get("mirror")
|
| 299 |
+
if isinstance(mirror, str) and mirror.strip() and "<your-org>" not in mirror:
|
| 300 |
+
active.append(f"{name} -> {mirror}")
|
| 301 |
+
if active:
|
| 302 |
+
print("Using dependency mirror config:")
|
| 303 |
+
for item in active:
|
| 304 |
+
print(f" {item}")
|
| 305 |
+
|
| 306 |
+
|
| 307 |
+
def announce_hmmer_location() -> None:
|
| 308 |
+
print(f"Using HMMER tool directory {HMMER_BIN_DIR}.")
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
def ensure_install_dirs() -> None:
|
| 312 |
+
install_destination().mkdir(parents=True, exist_ok=True)
|
| 313 |
+
build_data_output_dir().mkdir(parents=True, exist_ok=True)
|
| 314 |
+
|
| 315 |
+
|
| 316 |
+
def prepare_install_layout() -> None:
|
| 317 |
+
ensure_install_dirs()
|
| 318 |
+
announce_build_mode()
|
| 319 |
+
announce_install_destination()
|
| 320 |
+
announce_data_destination()
|
| 321 |
+
announce_cifpp_data_location()
|
| 322 |
+
announce_hmmer_location()
|
| 323 |
+
announce_mirror_overrides()
|
| 324 |
+
|
| 325 |
+
|
| 326 |
+
def ensure_local_components_file() -> None:
|
| 327 |
+
components_path = cifpp_components_path()
|
| 328 |
+
if components_path is None or components_path.exists():
|
| 329 |
+
return
|
| 330 |
+
if shutil.which("wget") is None:
|
| 331 |
+
return
|
| 332 |
+
components_path.parent.mkdir(parents=True, exist_ok=True)
|
| 333 |
+
try:
|
| 334 |
+
subprocess.run(
|
| 335 |
+
[
|
| 336 |
+
"wget",
|
| 337 |
+
"-O",
|
| 338 |
+
str(components_path),
|
| 339 |
+
"https://files.wwpdb.org/pub/pdb/data/monomers/components.cif",
|
| 340 |
+
],
|
| 341 |
+
check=True,
|
| 342 |
+
)
|
| 343 |
+
except subprocess.CalledProcessError as exc:
|
| 344 |
+
raise AF3BuildError(f"Failed to download components.cif with wget: {exc}") from exc
|
| 345 |
+
|
| 346 |
+
|
| 347 |
+
def ensure_components_file_available() -> None:
|
| 348 |
+
components_path = cifpp_components_path()
|
| 349 |
+
if components_path is None:
|
| 350 |
+
return
|
| 351 |
+
if components_path.exists():
|
| 352 |
+
return
|
| 353 |
+
raise AF3BuildError(
|
| 354 |
+
f"Expected libcifpp components file at {components_path}, but it was not created during dependency install."
|
| 355 |
+
)
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def finalise_install_layout() -> None:
|
| 359 |
+
ensure_components_file_available()
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
def patch_text(path: Path, old: str, new: str) -> None:
|
| 363 |
+
if not path.exists() or not new:
|
| 364 |
+
return
|
| 365 |
+
text = path.read_text()
|
| 366 |
+
if old in text:
|
| 367 |
+
path.write_text(text.replace(old, new))
|
| 368 |
+
|
| 369 |
+
|
| 370 |
+
def clone_or_update_repo(dep_name: str, repo: str, tag: str) -> Path:
|
| 371 |
+
target = REMOTE_DEPS_DIR / dep_name
|
| 372 |
+
if target.exists():
|
| 373 |
+
shutil.rmtree(target, ignore_errors=True)
|
| 374 |
+
target.parent.mkdir(parents=True, exist_ok=True)
|
| 375 |
+
subprocess.run(["git", "clone", repo, str(target)], check=True)
|
| 376 |
+
subprocess.run(["git", "-C", str(target), "checkout", tag], check=True)
|
| 377 |
+
return target
|
| 378 |
+
|
| 379 |
+
|
| 380 |
+
def disable_tests(source_dir: Path) -> None:
|
| 381 |
+
patch_text(
|
| 382 |
+
source_dir / "CMakeLists.txt",
|
| 383 |
+
"if(BUILD_TESTING AND PROJECT_IS_TOP_LEVEL)",
|
| 384 |
+
"if(FALSE AND BUILD_TESTING AND PROJECT_IS_TOP_LEVEL)",
|
| 385 |
+
)
|
| 386 |
+
patch_text(
|
| 387 |
+
source_dir / "CMakeLists.txt",
|
| 388 |
+
"if(BUILD_PYTHON_MODULE)",
|
| 389 |
+
"if(FALSE AND BUILD_PYTHON_MODULE)",
|
| 390 |
+
)
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def patch_catch2_sources(test_cmake: Path, env: dict[str, str]) -> None:
|
| 394 |
+
patch_text(test_cmake, "https://github.com/catchorg/Catch2.git", env.get("ALPHAFOLD3_CATCH2_REPO", ""))
|
| 395 |
+
patch_text(test_cmake, "v3.4.0", env.get("ALPHAFOLD3_CATCH2_TAG", ""))
|
| 396 |
+
|
| 397 |
+
|
| 398 |
+
def patch_regex_sources(source_dir: Path, env: dict[str, str]) -> None:
|
| 399 |
+
patch_text(source_dir / "CMakeLists.txt", "https://github.com/boostorg/regex", env.get("ALPHAFOLD3_BOOST_REGEX_REPO", ""))
|
| 400 |
+
patch_text(source_dir / "CMakeLists.txt", "boost-1.87.0", env.get("ALPHAFOLD3_BOOST_REGEX_TAG", ""))
|
| 401 |
+
|
| 402 |
+
|
| 403 |
+
# def patch_archive_urls(source_dir: Path, env: dict[str, str]) -> None:
|
| 404 |
+
# patch_text(
|
| 405 |
+
# source_dir / "pcre2-simple" / "CMakeLists.txt",
|
| 406 |
+
# "https://github.com/PCRE2Project/pcre2/releases/download/pcre2-10.46/pcre2-10.46.tar.gz",
|
| 407 |
+
# env.get("ALPHAFOLD3_PCRE2_URL", ""),
|
| 408 |
+
# )
|
| 409 |
+
|
| 410 |
+
|
| 411 |
+
def patch_eigen_sources(source_dir: Path, env: dict[str, str]) -> None:
|
| 412 |
+
cmake_path = source_dir / "CMakeLists.txt"
|
| 413 |
+
patch_text(
|
| 414 |
+
cmake_path,
|
| 415 |
+
"https://gitlab.com/libeigen/eigen.git",
|
| 416 |
+
env.get("ALPHAFOLD3_EIGEN_REPO", ""),
|
| 417 |
+
)
|
| 418 |
+
patch_text(
|
| 419 |
+
cmake_path,
|
| 420 |
+
"GIT_TAG 3.4.0",
|
| 421 |
+
f"GIT_TAG {env.get('ALPHAFOLD3_EIGEN_TAG', '')}",
|
| 422 |
+
)
|
| 423 |
+
patch_text(
|
| 424 |
+
cmake_path,
|
| 425 |
+
"\t# Create a private copy of eigen3 and populate it only, no need to build\n",
|
| 426 |
+
"\t# Create a private copy of eigen3 and populate it only, no need to build\n\tmessage(STATUS \"AF3 libcifpp: Eigen3 not found locally, populating my-eigen3 from GIT repository\")\n\tmessage(STATUS \"AF3 libcifpp: my-eigen3 repo=$ENV{ALPHAFOLD3_EIGEN_REPO} tag=$ENV{ALPHAFOLD3_EIGEN_TAG}\")\n",
|
| 427 |
+
)
|
| 428 |
+
patch_text(
|
| 429 |
+
cmake_path,
|
| 430 |
+
"\tFetchContent_GetProperties(my-eigen3)\n",
|
| 431 |
+
"\tFetchContent_GetProperties(my-eigen3)\n\tmessage(STATUS \"AF3 libcifpp: my-eigen3 populated=${my-eigen3_POPULATED}\")\n",
|
| 432 |
+
)
|
| 433 |
+
patch_text(
|
| 434 |
+
cmake_path,
|
| 435 |
+
"\tif(NOT my-eigen3_POPULATED)\n\t\tFetchContent_Populate(my-eigen3)\n\tendif()\n",
|
| 436 |
+
"\tif(NOT my-eigen3_POPULATED)\n\t\tmessage(STATUS \"AF3 libcifpp: starting FetchContent_Populate(my-eigen3)\")\n\t\tFetchContent_Populate(my-eigen3)\n\t\tmessage(STATUS \"AF3 libcifpp: finished FetchContent_Populate(my-eigen3), source=${my-eigen3_SOURCE_DIR}\")\n\tendif()\n",
|
| 437 |
+
)
|
| 438 |
+
patch_text(
|
| 439 |
+
cmake_path,
|
| 440 |
+
"\tset(EIGEN_INCLUDE_DIR ${my-eigen3_SOURCE_DIR})\n",
|
| 441 |
+
"\tset(EIGEN_INCLUDE_DIR ${my-eigen3_SOURCE_DIR})\n\tmessage(STATUS \"AF3 libcifpp: EIGEN_INCLUDE_DIR=${EIGEN_INCLUDE_DIR}\")\n",
|
| 442 |
+
)
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
def patch_all_known_downstream_sources(source_dir: Path, env: dict[str, str]) -> None:
|
| 446 |
+
disable_tests(source_dir)
|
| 447 |
+
patch_regex_sources(source_dir, env)
|
| 448 |
+
# patch_archive_urls(source_dir, env)
|
| 449 |
+
patch_eigen_sources(source_dir, env)
|
| 450 |
+
test_cmake = source_dir / "test" / "CMakeLists.txt"
|
| 451 |
+
if test_cmake.exists():
|
| 452 |
+
patch_catch2_sources(test_cmake, env)
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
def patch_libcifpp_sources(source_dir: Path, env: dict[str, str]) -> None:
|
| 456 |
+
patch_all_known_downstream_sources(source_dir, env)
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
def patch_dssp_sources(source_dir: Path, env: dict[str, str]) -> None:
|
| 460 |
+
patch_all_known_downstream_sources(source_dir, env)
|
| 461 |
+
patch_text(source_dir / "CMakeLists.txt", "https://github.com/mhekkel/libmcfp", env.get("ALPHAFOLD3_LIBMCFP_REPO", ""))
|
| 462 |
+
patch_text(source_dir / "CMakeLists.txt", "v1.4.2", env.get("ALPHAFOLD3_LIBMCFP_TAG", ""))
|
| 463 |
+
patch_text(source_dir / "CMakeLists.txt", "https://github.com/PDB-REDO/libcifpp", env.get("CIFPP_REPO", ""))
|
| 464 |
+
patch_text(source_dir / "CMakeLists.txt", "v10.0.1", env.get("CIFPP_TAG", ""))
|
| 465 |
+
|
| 466 |
+
|
| 467 |
+
def prepare_remote_dependency_sources(env: dict[str, str]) -> Path:
|
| 468 |
+
if REMOTE_DEPS_DIR.exists():
|
| 469 |
+
shutil.rmtree(REMOTE_DEPS_DIR, ignore_errors=True)
|
| 470 |
+
REMOTE_DEPS_DIR.mkdir(parents=True, exist_ok=True)
|
| 471 |
+
|
| 472 |
+
specs = dependency_specs()
|
| 473 |
+
prepared = {}
|
| 474 |
+
clone_order = ["ABSEIL", "PYBIND11", "PYBIND11_ABSEIL", "CIFPP", "DSSP"]
|
| 475 |
+
for key_prefix in clone_order:
|
| 476 |
+
spec = specs[key_prefix]
|
| 477 |
+
dep_name = spec["local_path"]
|
| 478 |
+
repo = env[f"{key_prefix}_REPO"]
|
| 479 |
+
tag = env[f"{key_prefix}_TAG"]
|
| 480 |
+
prepared[dep_name] = clone_or_update_repo(dep_name, repo, tag)
|
| 481 |
+
if dep_name == "libcifpp":
|
| 482 |
+
patch_libcifpp_sources(prepared[dep_name], env)
|
| 483 |
+
elif dep_name == "dssp":
|
| 484 |
+
patch_dssp_sources(prepared[dep_name], env)
|
| 485 |
+
|
| 486 |
+
return REMOTE_DEPS_DIR
|
| 487 |
+
|
| 488 |
+
|
| 489 |
+
def prepare_build_env_once() -> dict[str, str]:
|
| 490 |
+
global PREPARED_ENV, PREPARED_DEP_DIR, PREPARED_REMOTE
|
| 491 |
+
if PREPARED_ENV is not None:
|
| 492 |
+
return PREPARED_ENV
|
| 493 |
+
|
| 494 |
+
env = os.environ.copy()
|
| 495 |
+
env["PATH"] = str(HMMER_BIN_DIR) + os.pathsep + env.get("PATH", "")
|
| 496 |
+
specs = dependency_specs()
|
| 497 |
+
for prefix, spec in specs.items():
|
| 498 |
+
env[f"{prefix}_REPO"] = mirror_value(spec["local_path"], "mirror", spec["repo"]) or spec["repo"]
|
| 499 |
+
env[f"{prefix}_TAG"] = mirror_value(spec["local_path"], "tag", spec["tag"]) or spec["tag"]
|
| 500 |
+
|
| 501 |
+
env["ALPHAFOLD3_BOOST_REGEX_REPO"] = mirror_value("boost-regex", "mirror", "https://github.com/boostorg/regex") or "https://github.com/boostorg/regex"
|
| 502 |
+
env["ALPHAFOLD3_BOOST_REGEX_TAG"] = mirror_value("boost-regex", "tag", DEFAULT_DOWNSTREAM_TAGS["boost-regex"]) or DEFAULT_DOWNSTREAM_TAGS["boost-regex"]
|
| 503 |
+
env["ALPHAFOLD3_LIBMCFP_REPO"] = mirror_value("libmcfp", "mirror", "https://github.com/mhekkel/libmcfp") or "https://github.com/mhekkel/libmcfp"
|
| 504 |
+
env["ALPHAFOLD3_LIBMCFP_TAG"] = mirror_value("libmcfp", "tag", DEFAULT_DOWNSTREAM_TAGS["libmcfp"]) or DEFAULT_DOWNSTREAM_TAGS["libmcfp"]
|
| 505 |
+
env["ALPHAFOLD3_CATCH2_REPO"] = mirror_value("catch2", "mirror", "https://github.com/catchorg/Catch2.git") or "https://github.com/catchorg/Catch2.git"
|
| 506 |
+
env["ALPHAFOLD3_CATCH2_TAG"] = mirror_value("catch2", "tag", DEFAULT_DOWNSTREAM_TAGS["catch2"]) or DEFAULT_DOWNSTREAM_TAGS["catch2"]
|
| 507 |
+
pcre2_url = mirror_value("pcre2", "mirror")
|
| 508 |
+
if pcre2_url:
|
| 509 |
+
env["ALPHAFOLD3_PCRE2_URL"] = pcre2_url
|
| 510 |
+
eigen_repo = mirror_value("eigen", "mirror", "https://gitlab.com/libeigen/eigen.git") or "https://gitlab.com/libeigen/eigen.git"
|
| 511 |
+
eigen_tag = mirror_value("eigen", "tag", "3.4.0") or "3.4.0"
|
| 512 |
+
env["ALPHAFOLD3_EIGEN_REPO"] = eigen_repo
|
| 513 |
+
env["ALPHAFOLD3_EIGEN_TAG"] = eigen_tag
|
| 514 |
+
dep_dir = resolve_dep_dir()
|
| 515 |
+
if dep_dir is None and using_remote_dependencies():
|
| 516 |
+
dep_dir = prepare_remote_dependency_sources(env)
|
| 517 |
+
PREPARED_REMOTE = True
|
| 518 |
+
if dep_dir is not None:
|
| 519 |
+
PREPARED_DEP_DIR = dep_dir
|
| 520 |
+
env["ALPHAFOLD3_DEP_DIR"] = str(dep_dir)
|
| 521 |
+
for prefix, spec in specs.items():
|
| 522 |
+
env[f"{prefix}_LOCAL_PATH"] = str(dep_dir / spec["local_path"])
|
| 523 |
+
|
| 524 |
+
env["ALPHAFOLD3_INSTALL_PREFIX"] = str(install_destination())
|
| 525 |
+
env["ALPHAFOLD3_DATA_OUTPUT_DIR"] = str(build_data_output_dir())
|
| 526 |
+
data_dir = cifpp_data_dir()
|
| 527 |
+
components_path = cifpp_components_path()
|
| 528 |
+
if data_dir is not None:
|
| 529 |
+
env["ALPHAFOLD3_CIFPP_DATA_DIR"] = str(data_dir)
|
| 530 |
+
if components_path is not None:
|
| 531 |
+
env["ALPHAFOLD3_CIFPP_COMPONENTS"] = str(components_path)
|
| 532 |
+
env["ALPHAFOLD3_PYTHON_EXECUTABLE"] = sys.executable
|
| 533 |
+
python_include_dir = current_python_include_dir()
|
| 534 |
+
if python_include_dir:
|
| 535 |
+
env["ALPHAFOLD3_PYTHON_INCLUDE_DIR"] = python_include_dir
|
| 536 |
+
numpy_include_dir = current_numpy_include_dir()
|
| 537 |
+
if numpy_include_dir:
|
| 538 |
+
env["ALPHAFOLD3_NUMPY_INCLUDE_DIR"] = numpy_include_dir
|
| 539 |
+
pythonpath_entries = [str(ROOT)]
|
| 540 |
+
existing_pythonpath = env.get("PYTHONPATH")
|
| 541 |
+
if existing_pythonpath:
|
| 542 |
+
pythonpath_entries.append(existing_pythonpath)
|
| 543 |
+
env["PYTHONPATH"] = os.pathsep.join(pythonpath_entries)
|
| 544 |
+
|
| 545 |
+
PREPARED_ENV = env
|
| 546 |
+
return env
|
| 547 |
+
|
| 548 |
+
|
| 549 |
+
def _build_env() -> dict[str, str]:
|
| 550 |
+
return prepare_build_env_once().copy()
|
| 551 |
+
|
| 552 |
+
|
| 553 |
+
def _run(command: list[str], cwd: Path) -> None:
|
| 554 |
+
env = _build_env()
|
| 555 |
+
if command and command[0] == "cmake":
|
| 556 |
+
resolved_cmake = shutil.which("cmake", path=env.get("PATH"))
|
| 557 |
+
print(f"[AF3] build python executable: {sys.executable}")
|
| 558 |
+
print(f"[AF3] build cwd: {cwd}")
|
| 559 |
+
print(f"[AF3] build PATH: {env.get('PATH', '')}")
|
| 560 |
+
print(f"[AF3] resolved cmake: {resolved_cmake}")
|
| 561 |
+
print(f"[AF3] build PYTHONPATH: {env.get('PYTHONPATH', '')}")
|
| 562 |
+
print(f"[AF3] build CONDA_PREFIX: {env.get('CONDA_PREFIX', '')}")
|
| 563 |
+
print(f"[AF3] build VIRTUAL_ENV: {env.get('VIRTUAL_ENV', '')}")
|
| 564 |
+
print(f"[AF3] ALPHAFOLD3_PYTHON_EXECUTABLE: {env.get('ALPHAFOLD3_PYTHON_EXECUTABLE', '')}")
|
| 565 |
+
print(f"[AF3] ALPHAFOLD3_PYTHON_INCLUDE_DIR: {env.get('ALPHAFOLD3_PYTHON_INCLUDE_DIR', '')}")
|
| 566 |
+
print(f"[AF3] ALPHAFOLD3_NUMPY_INCLUDE_DIR: {env.get('ALPHAFOLD3_NUMPY_INCLUDE_DIR', '')}")
|
| 567 |
+
subprocess.run(command, cwd=cwd, env=env, check=True)
|
| 568 |
+
|
| 569 |
+
|
| 570 |
+
def build_cpp_extension() -> None:
|
| 571 |
+
BUILD_DIR.mkdir(exist_ok=True)
|
| 572 |
+
try:
|
| 573 |
+
cmake_configure_command = [
|
| 574 |
+
"cmake",
|
| 575 |
+
str(AF3_DIR),
|
| 576 |
+
"-DCMAKE_BUILD_TYPE=Release",
|
| 577 |
+
"-DCMAKE_CXX_STANDARD=20",
|
| 578 |
+
"-DCMAKE_POSITION_INDEPENDENT_CODE=ON",
|
| 579 |
+
"-DBUILD_TESTING=OFF",
|
| 580 |
+
"-DCMAKE_CXX_SCAN_FOR_MODULES=OFF",
|
| 581 |
+
"-DSKBUILD_PROJECT_NAME=cpp",
|
| 582 |
+
"-DSKBUILD_PROJECT_VERSION=0.3.0",
|
| 583 |
+
f"-DPython3_EXECUTABLE={sys.executable}",
|
| 584 |
+
"-DPython3_FIND_STRATEGY=LOCATION",
|
| 585 |
+
]
|
| 586 |
+
python_include_dir = current_python_include_dir()
|
| 587 |
+
if python_include_dir:
|
| 588 |
+
cmake_configure_command.append(f"-DPython3_INCLUDE_DIR={python_include_dir}")
|
| 589 |
+
numpy_include_dir = current_numpy_include_dir()
|
| 590 |
+
if numpy_include_dir:
|
| 591 |
+
cmake_configure_command.append(f"-DPython3_NumPy_INCLUDE_DIR={numpy_include_dir}")
|
| 592 |
+
_run(cmake_configure_command, cwd=BUILD_DIR)
|
| 593 |
+
build_parallelism = min(os.cpu_count() or 8, 64)
|
| 594 |
+
_run(["cmake", "--build", ".", "--parallel", str(build_parallelism)], cwd=BUILD_DIR)
|
| 595 |
+
_run(["cmake", "--install", ".", "--prefix", str(install_destination())], cwd=BUILD_DIR)
|
| 596 |
+
except FileNotFoundError as exc:
|
| 597 |
+
raise AF3BuildError(f"CMake not found: {exc}") from exc
|
| 598 |
+
except subprocess.CalledProcessError as exc:
|
| 599 |
+
raise AF3BuildError(f"Failed to build AlphaFold3 C++ extension: {exc}") from exc
|
| 600 |
+
finally:
|
| 601 |
+
cleanup_build_artifacts()
|
| 602 |
+
|
| 603 |
+
|
| 604 |
+
def build_data_files() -> None:
|
| 605 |
+
try:
|
| 606 |
+
from flax_model.alphafold3.build_data import build_data
|
| 607 |
+
build_data()
|
| 608 |
+
except Exception as exc:
|
| 609 |
+
raise AF3BuildError(f"Failed to build AlphaFold3 data files: {exc}") from exc
|
| 610 |
+
|
| 611 |
+
|
| 612 |
+
def cleanup_build_artifacts() -> None:
|
| 613 |
+
for path in (
|
| 614 |
+
BUILD_DIR,
|
| 615 |
+
AF3_DIR / "include",
|
| 616 |
+
AF3_DIR / "lib",
|
| 617 |
+
AF3_DIR / "lib64",
|
| 618 |
+
AF3_DIR / "var",
|
| 619 |
+
AF3_DIR / "etc",
|
| 620 |
+
):
|
| 621 |
+
if path.exists():
|
| 622 |
+
shutil.rmtree(path, ignore_errors=True)
|
| 623 |
+
|
| 624 |
+
|
| 625 |
+
def cleanup_prepared_remote_deps() -> None:
|
| 626 |
+
if PREPARED_REMOTE and REMOTE_DEPS_DIR.exists():
|
| 627 |
+
shutil.rmtree(REMOTE_DEPS_DIR, ignore_errors=True)
|
| 628 |
+
|
| 629 |
+
|
| 630 |
+
def build_all() -> None:
|
| 631 |
+
reset_prepared_state()
|
| 632 |
+
ensure_build_prerequisites()
|
| 633 |
+
prepare_build_env_once()
|
| 634 |
+
ensure_local_components_file()
|
| 635 |
+
prepare_install_layout()
|
| 636 |
+
print("Building AlphaFold3 C++ extension...")
|
| 637 |
+
build_cpp_extension()
|
| 638 |
+
finalise_install_layout()
|
| 639 |
+
print("Building AlphaFold3 data files...")
|
| 640 |
+
build_data_files()
|
| 641 |
+
cleanup_prepared_remote_deps()
|
| 642 |
+
|
| 643 |
+
|
| 644 |
+
def build_if_needed() -> None:
|
| 645 |
+
if not should_build():
|
| 646 |
+
return
|
| 647 |
+
if artifacts_exist() and not force_rebuild():
|
| 648 |
+
return
|
| 649 |
+
build_all()
|
flax_model/alphafold3/_data/libcifpp/components.cif
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:07589b2cff5cae2cc8847a03cf8354a80c3bbc618aedda80f4d05ccaf8b5a85c
|
| 3 |
+
size 508121501
|
flax_model/alphafold3/_data/libcifpp/mmcif_ddl.dic
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
flax_model/alphafold3/_data/libcifpp/mmcif_ma.dic
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
flax_model/alphafold3/_data/libcifpp/mmcif_pdbx.dic
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
flax_model/alphafold3/_tools/hmmer/.built
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
built
|
flax_model/alphafold3/_tools/hmmer/bin/alimask
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:3829f1617d978132264285088fa1876cc576e468586d8cf88660748ae2b13e34
|
| 3 |
+
size 472688
|
flax_model/alphafold3/_tools/hmmer/bin/easel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46ba04bd13c9931f11fa14a1f3f3fdc0c650c05aac20de74f6dcb0288fe4be2d
|
| 3 |
+
size 574504
|
flax_model/alphafold3/_tools/hmmer/bin/esl-afetch
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d770ea581ec2bd42c684837d5f8414b3e2f4f8e561c28ae594d35a8855510be0
|
| 3 |
+
size 366424
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alimanip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9e9639fa2303da69519e9b06f631850bb081a3bca0f457f05ae331f484f66057
|
| 3 |
+
size 601624
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alimap
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:303169914a002be9658a626a5767ac1e332a01f8497aafc2a0fb786d94bd1166
|
| 3 |
+
size 373920
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alimask
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8e3d36892dbce11b74cba9f7eec125b633ac3def9f3777ff52a712b2a13715ec
|
| 3 |
+
size 427360
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alimerge
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:74301a1a9a1e6d1be2b34ff85147f4609373922df4911d8fcd89af9d0f41e20a
|
| 3 |
+
size 421184
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alipid
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4fdb5baa1a9e5579f0e542a0eb006cc432181dcc12107c27c84cb2998e2ee66e
|
| 3 |
+
size 384080
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alirev
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b27dd80cb51b2aba859bdf162aeaddd32f61d340cdadc21ce14b93e31f37ca86
|
| 3 |
+
size 352920
|
flax_model/alphafold3/_tools/hmmer/bin/esl-alistat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f3d6c6cad3da0e37905979950871183d89bef3dc8fccd5c36a0722b34914659f
|
| 3 |
+
size 434608
|
flax_model/alphafold3/_tools/hmmer/bin/esl-compalign
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d5875b268e83742fb7accad9e44e57c6567285d874ec8574a6bb34e6401b8a9c
|
| 3 |
+
size 370608
|
flax_model/alphafold3/_tools/hmmer/bin/esl-compstruct
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:864b1fde43e2603340d666eb3b2e382b57556b65d68416ea8bec59888516f18a
|
| 3 |
+
size 357136
|
flax_model/alphafold3/_tools/hmmer/bin/esl-construct
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:016ef82d9c226ab2dfa96a6d34e45b903e5de66cf2055396f622f978d5c2255c
|
| 3 |
+
size 374472
|
flax_model/alphafold3/_tools/hmmer/bin/esl-histplot
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9f64c1da60a62e2cd4e6c09d89512e28a31b824115ff43c5f4ffdfb2b431f0e2
|
| 3 |
+
size 175248
|
flax_model/alphafold3/_tools/hmmer/bin/esl-mask
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:71aa5ec2f448fd03390551b56e0bec104294f96ebca830b71a5ad48a78a62c1b
|
| 3 |
+
size 466512
|
flax_model/alphafold3/_tools/hmmer/bin/esl-mixdchlet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:485ba00164847ae5b3c7b3d9252c893731d5457bd3b9a107bf8328a6dab7607a
|
| 3 |
+
size 166744
|
flax_model/alphafold3/_tools/hmmer/bin/esl-reformat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:04f041b4b5291ff000d1dd4ad36e291257fb1cc5ee87438c382a681805d4e871
|
| 3 |
+
size 480000
|
flax_model/alphafold3/_tools/hmmer/bin/esl-selectn
ADDED
|
Binary file (76.8 kB). View file
|
|
|
flax_model/alphafold3/_tools/hmmer/bin/esl-seqrange
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8c632736b7e228ff8b1dafd196a975699dc4fe3e328469eb7912adf5ab7b6407
|
| 3 |
+
size 457152
|
flax_model/alphafold3/_tools/hmmer/bin/esl-seqstat
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:a98388deebbaf07421a880ac69f3938101f241e471d5e53fb208b053f6820811
|
| 3 |
+
size 466104
|
flax_model/alphafold3/_tools/hmmer/bin/esl-sfetch
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:860fcf585ba9bccff9e77d23061a95d878e226b0013dc810d0dafb7716727a72
|
| 3 |
+
size 488216
|
flax_model/alphafold3/_tools/hmmer/bin/esl-shuffle
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:8769d54193fe004f33ec80f5cda4828760ed173fb4359b020997dd21ed8d2825
|
| 3 |
+
size 475808
|
flax_model/alphafold3/_tools/hmmer/bin/esl-ssdraw
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:683b7b21d1382a09ef0795e2ef06fb3dc0f2fab4503c032da79271771a2d5b1d
|
| 3 |
+
size 538912
|
flax_model/alphafold3/_tools/hmmer/bin/esl-translate
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:959313addd5ce794b977bfb03daafcc6c0f2974a5dec0f198f7a46822a3c483b
|
| 3 |
+
size 501024
|
flax_model/alphafold3/_tools/hmmer/bin/esl-weight
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:439fec1b9e7c3fda0d66e578f2edeae1b7d886693fe4d459588b2943e92f4b76
|
| 3 |
+
size 442000
|
flax_model/alphafold3/_tools/hmmer/bin/hmmalign
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:41d61aa0607f1276a60885aa7bf6211eeb82b0025af14fdc8e065603641822c4
|
| 3 |
+
size 825160
|
flax_model/alphafold3/_tools/hmmer/bin/hmmbuild
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0d77e1ec8f1cbbbd8f422e4c9086df14827c330571441a643b0e000dffdd3cfa
|
| 3 |
+
size 961776
|
flax_model/alphafold3/_tools/hmmer/bin/hmmconvert
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94492f28b9bd0bf189e8939250fd4e17334f438f1fbd5a28d7961c8372560964
|
| 3 |
+
size 522376
|
flax_model/alphafold3/_tools/hmmer/bin/hmmemit
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d95014dd6782eda7230deaa99ea69797b2d2f91974562490beb26435fcb342cc
|
| 3 |
+
size 825632
|
flax_model/alphafold3/_tools/hmmer/bin/hmmfetch
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:868bffcb8ae9da213e12e57848c0e1a33c8089b5c8e9a46be00ef94b5b96db90
|
| 3 |
+
size 531312
|
flax_model/alphafold3/_tools/hmmer/bin/hmmlogo
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bcfe77862766daec5dbe81fbf4c54a5fb143206de97c48f6f8e970e07ab09e9c
|
| 3 |
+
size 522504
|
flax_model/alphafold3/_tools/hmmer/bin/hmmpgmd
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:c1241da11803085fda21c80ec674d73f483e25e317248e0ac73210156ae500af
|
| 3 |
+
size 1218768
|
flax_model/alphafold3/_tools/hmmer/bin/hmmpgmd_shard
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:f1567ab0cc18dfe3018a7e6cd9c0cacc74ae7da0853f0dcec625b6df48dee7b9
|
| 3 |
+
size 1227248
|