> For the complete documentation index, see [llms.txt](https://docs.clore.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.clore.ai/guides/guides_v2-zh/ke-xue-yu-yan-jiu/alphafold2.md).

# AlphaFold2 蛋白质预测

> **借助诺奖级 AI 预测蛋白质结构——由 Clore.ai 上的 GPU 加速驱动**

由 DeepMind 开发的 AlphaFold2 通过以原子级精度预测蛋白质三维结构，彻底改变了结构生物学。它已应用于超过 2 亿条蛋白质序列，并获得了 2024 年诺贝尔化学奖。运行 AlphaFold2 需要大量 GPU 显存和算力——Clore.ai 为所需的高端 GPU 提供了经济实惠的访问方式。

**GitHub：** [google-deepmind/alphafold](https://github.com/google-deepmind/alphafold) — 13K+ ⭐

***

## 前提条件

* 一个余额充足的 Clore.ai 账户
* 对 Linux 命令行有基本了解
* 以 FASTA 格式提供你的目标蛋白序列
* 完整基因数据库约需 2.5TB 磁盘空间（或使用精简数据库进行测试）

***

## 为什么要在 Clore.ai 上运行 AlphaFold2？

AlphaFold2 从 GPU 加速中获益巨大：

| 硬件           | 预测时间（典型蛋白约 400aa） |
| ------------ | ----------------- |
| 仅 CPU        | 6–24+ 小时          |
| 单张 A100 80GB | 15–45 分钟          |
| 单张 RTX 4090  | 20–60 分钟          |
| 单张 RTX 3090  | 30–90 分钟          |

Clore.ai 以远低于云服务商的成本提供 A100、RTX 4090 和 RTX 3090 节点，使大规模蛋白质组学研究触手可及。

***

## 步骤 1 — 在 Clore.ai 上选择你的 GPU 租赁

{% hint style="info" %}
**AlphaFold2 推荐使用的 GPU：**

* **A100 80GB** — 最适合大型蛋白（>700 aa）和多聚体预测
* **RTX 4090 24GB** — 非常适合标准单体（<500 aa）
* **RTX 3090 24GB** — 适合更小的蛋白，性价比高

对于多聚体预测，强烈建议使用 40GB 以上显存。
{% endhint %}

1. 登录到 [clore.ai](https://clore.ai) 并前往 **市场**
2. 按 GPU 型号筛选（推荐 A100 或 RTX 4090）
3. 确保服务器具有 **至少 100GB 磁盘空间** （完整数据库则需 2.5TB）
4. 选择一台服务器并点击 **租用**

***

## 步骤 2 — 配置你的部署

设置租赁订单时，请使用以下配置：

**Docker 镜像：**

```
nvidia/cuda:11.8.0-cudnn8-runtime-ubuntu20.04
```

{% hint style="warning" %}
AlphaFold2 需要自定义 Docker 配置。我们将在容器内从源代码安装它。或者，也可以使用社区镜像 `catgumag/alphafold` 或 `merteroglu/alphafold2` ，它已预先打包好环境。
{% endhint %}

**要暴露的端口：**

```
22
```

**环境变量：**

```
NVIDIA_VISIBLE_DEVICES=all
NVIDIA_DRIVER_CAPABILITIES=compute,utility
```

**最低资源：**

* CPU：8 核
* RAM：32GB（大型蛋白推荐 64GB）
* 磁盘：至少 100GB（完整数据库需 2.5TB）

***

## 步骤 3 — 通过 SSH 连接

实例启动后：

```bash
ssh root@<server-ip> -p <ssh-port>
```

验证 GPU 是否可见：

```bash
nvidia-smi
```

预期输出应显示你的 GPU（例如 A100 80GB SXM4）。

***

## 步骤 4 — 安装 AlphaFold2

### 选项 A：使用官方安装脚本

```bash
# 更新系统包
apt-get update && apt-get install -y \
    wget \
    git \
    python3-pip \
    python3-dev \
    aria2 \
    hmmer \
    kalign \
    hhsuite

# 安装 Miniconda
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
bash miniconda.sh -b -p /opt/conda
export PATH="/opt/conda/bin:$PATH"

# 克隆 AlphaFold2
git clone https://github.com/google-deepmind/alphafold.git /opt/alphafold
cd /opt/alphafold

# 创建 conda 环境
conda env create -f environment.yml
conda activate alphafold
```

### 选项 B：使用 pip（更快的设置）

```bash
# 安装系统依赖
apt-get update && apt-get install -y \
    wget curl git aria2 hmmer kalign

# 安装 hhsuite
conda install -c bioconda hhsuite

# 克隆并安装 AlphaFold2
git clone https://github.com/google-deepmind/alphafold.git /opt/alphafold
cd /opt/alphafold

pip install -r requirements.txt
pip install --upgrade "jax[cuda11_pip]" -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html

# 安装 AlphaFold 本体
python3 setup.py install
```

***

## 步骤 5 — 下载基因数据库

{% hint style="warning" %}
**完整数据库下载需要约 2.5TB 磁盘空间，可能耗时 6–24 小时。** 首次测试时，请使用精简数据库（见下方精简数据库部分）。
{% endhint %}

### 完整数据库（生产用途）

```bash
cd /opt/alphafold

# 使用提供的脚本下载所有数据库
bash scripts/download_all_data.sh /data/alphafold_databases
```

这将下载：

* **BFD** （约 270GB）— Big Fantastic Database
* **UniRef90** （约 58GB）— UniProt 参考聚类
* **MGnify** （约 64GB）— 元基因组序列
* **PDB70** （约 56GB）— 蛋白质数据库代表性结构
* **PDB seqres** （约 0.2GB）
* **UniClust30** （约 86GB）
* **Small BFD** （约 17GB）— 精简版

### 精简数据库（测试/开发）

用于有限磁盘空间的测试：

```bash
# 仅下载 small_bfd 和必要数据库
bash scripts/download_small_bfd.sh /data/alphafold_databases
bash scripts/download_pdb70.sh /data/alphafold_databases
bash scripts/download_uniclust30.sh /data/alphafold_databases
bash scripts/download_uniref90.sh /data/alphafold_databases
bash scripts/download_mgnify.sh /data/alphafold_databases
bash scripts/download_pdb_seqres.sh /data/alphafold_databases
bash scripts/download_uniprot.sh /data/alphafold_databases
```

***

## 步骤 6 — 下载 AlphaFold 模型权重

```bash
# 为模型参数创建目录
mkdir -p /data/alphafold_databases/params

# 下载模型参数（约 3.5GB）
wget -q -P /data/alphafold_databases/params \
    https://storage.googleapis.com/alphafold/alphafold_params_2022-12-06.tar

# 解压
tar -xf /data/alphafold_databases/params/alphafold_params_2022-12-06.tar \
    -C /data/alphafold_databases/params
```

***

## 步骤 7 — 准备你的输入序列

创建一个包含目标蛋白序列的 FASTA 文件：

```bash
cat > /tmp/target_protein.fasta << 'EOF'
>my_protein
MKTLLLTLVVVTIVCLDLGAVGNGSGLKCRQTGSCVHFPKDLQALPKDDTASDLNRSLDAEAFKAFQRLAENFNATEYRDIQNFNNKIQHSLEELAKKLDEKLAKLKEKLKQLEN
EOF
```

{% hint style="info" %}
**FASTA 格式提示：**

* 标题行以 `>`
* 序列应只包含标准氨基酸字母（ACDEFGHIKLMNPQRSTVWY）
* 移除任何缺口或非标准字符
* 对于多聚体预测，请为每条链使用独立标题
  {% endhint %}

***

## 步骤 8 — 运行 AlphaFold2

### 单体预测（单链）

```bash
cd /opt/alphafold

python3 run_alphafold.py \
    --fasta_paths=/tmp/target_protein.fasta \
    --max_template_date=2022-01-01 \
    --model_preset=monomer \
    --db_preset=full_dbs \
    --data_dir=/data/alphafold_databases \
    --output_dir=/tmp/alphafold_output \
    --uniref90_database_path=/data/alphafold_databases/uniref90/uniref90.fasta \
    --mgnify_database_path=/data/alphafold_databases/mgnify/mgy_clusters_2022_05.fa \
    --template_mmcif_dir=/data/alphafold_databases/pdb_mmcif/mmcif_files \
    --obsolete_pdbs_path=/data/alphafold_databases/pdb_mmcif/obsolete.dat \
    --pdb70_database_path=/data/alphafold_databases/pdb70/pdb70 \
    --bfd_database_path=/data/alphafold_databases/bfd/bfd_metaclust_clu_complete_id30_c90_final_seq.sorted_opt \
    --uniclust30_database_path=/data/alphafold_databases/uniclust30/uniclust30_2018_08/uniclust30_2018_08 \
    --use_gpu_relax=True
```

### 多聚体预测（蛋白复合物）

```bash
python3 run_alphafold.py \
    --fasta_paths=/tmp/complex.fasta \
    --max_template_date=2022-01-01 \
    --model_preset=multimer \
    --db_preset=full_dbs \
    --data_dir=/data/alphafold_databases \
    --output_dir=/tmp/alphafold_output \
    --uniref90_database_path=/data/alphafold_databases/uniref90/uniref90.fasta \
    --mgnify_database_path=/data/alphafold_databases/mgnify/mgy_clusters_2022_05.fa \
    --template_mmcif_dir=/data/alphafold_databases/pdb_mmcif/mmcif_files \
    --obsolete_pdbs_path=/data/alphafold_databases/pdb_mmcif/obsolete.dat \
    --uniprot_database_path=/data/alphafold_databases/uniprot/uniprot.fasta \
    --pdb_seqres_database_path=/data/alphafold_databases/pdb_seqres/pdb_seqres.txt \
    --use_gpu_relax=True
```

***

## 步骤 9 — 理解输出文件

AlphaFold2 每次预测会生成多个输出文件：

```
/tmp/alphafold_output/my_protein/
├── ranked_0.pdb          # 最佳预测结构
├── ranked_1.pdb          # 第二佳预测
├── ranked_2.pdb
├── ranked_3.pdb
├── ranked_4.pdb
├── result_model_1.pkl    # 完整预测数据（pickle）
├── result_model_2.pkl
├── ...
├── msas/                 # 多序列比对
│   ├── bfd_uniclust_hits.a3m
│   ├── mgnify_hits.sto
│   └── uniref90_hits.sto
└── timings.json          # 运行时间分解
```

{% hint style="info" %}
**结果解读：**

* **ranked\_0.pdb** 是你的最佳结构——可在 PyMOL、ChimeraX 或 UCSF Chimera 中打开
* **pLDDT 分数** （0–100）：每个残基的置信度。>90 = 非常高，70–90 = 良好，50–70 = 较低，<50 = 无序
* **PAE（预测对齐误差）** 图展示域间置信度
  {% endhint %}

***

## 步骤 10 — 可视化结果

### 将 PDB 文件下载到本地电脑

```bash
# 在你的本地电脑上：
scp -P <ssh-port> root@<server-ip>:/tmp/alphafold_output/my_protein/ranked_0.pdb ./

# 或使用 rsync 下载完整输出目录：
rsync -avz -e "ssh -p <ssh-port>" \
    root@<server-ip>:/tmp/alphafold_output/ \
    ./alphafold_results/
```

### 在 PyMOL 中可视化（本地）

```python
# 在 PyMOL 中：
load ranked_0.pdb
spectrum b, blue_white_red, minimum=0, maximum=100
# 按 pLDDT 分数着色（存储在 B-factor 列）
```

### 快速 pLDDT 分析

```python
import numpy as np

# 从 PDB 解析 B-factor（pLDDT）
plddt_scores = []
with open('ranked_0.pdb', 'r') as f:
    for line in f:
        if line.startswith('ATOM'):
            plddt = float(line[60:66].strip())
            plddt_scores.append(plddt)

print(f"平均 pLDDT: {np.mean(plddt_scores):.1f}")
print(f"pLDDT >90 的残基：{sum(s > 90 for s in plddt_scores)}/{len(plddt_scores)}")
```

***

## 使用 ColabFold（更快的替代方案）

ColabFold 是 AlphaFold2 的更快实现，使用 MMseqs2 生成 MSA：

```bash
pip install colabfold[alphafold]

# 运行预测（MSA 步骤快得多）
colabfold_batch /tmp/target_protein.fasta /tmp/colabfold_output \
    --num-recycle 3 \
    --use-gpu-relax
```

{% hint style="success" %}
**由于 MMseqs2 MSA 服务器，ColabFold 通常比原始 AlphaFold2 流水线快 10–40 倍** 。非常适合迭代式研究工作流。
{% endhint %}

***

## 故障排查

### CUDA 显存不足

```bash
# 降低模型复杂度或使用统一内存
export XLA_PYTHON_CLIENT_ALLOCATOR=platform
export XLA_PYTHON_CLIENT_MEM_FRACTION=0.85

# 或以减少 recycling 次数运行
--num_multimer_predictions_per_model 1
```

### HHblits / Jackhmmer 错误

```bash
# 确保 hhsuite 已正确安装
which hhblits
hhblits --version

# 如有需要，重新安装
conda install -c bioconda hhsuite -y
```

### 数据库下载失败

```bash
# 使用 aria2 续传中断的下载
aria2c -c -x 16 -s 16 <database-url> -d /data/alphafold_databases/
```

### JAX/CUDA 兼容性问题

```bash
# 检查 JAX 是否能看到 GPU
python3 -c "import jax; print(jax.devices())"

# 使用正确的 CUDA 版本重新安装 JAX
pip install --upgrade "jax[cuda11_pip]" \
    -f https://storage.googleapis.com/jax-releases/jax_cuda_releases.html
```

***

## 性能提示

{% hint style="success" %}
**优化你的 AlphaFold2 运行：**

1. **使用 ColabFold** 以更快生成 MSA（提速 10–40 倍）
2. **设置 `--num-recycle 1`** 用于快速筛选，最终预测使用 3
3. **使用 `--db_preset=reduced_dbs`** 用于探索性工作
4. **批量处理多个序列** 将它们放在一个 FASTA 文件中，以便高效运行流水线
5. **启用 GPU relax** (`--use_gpu_relax=True`）——比 CPU relax 快得多
   {% endhint %}

***

## Clore.ai 成本估算

| 场景             | GPU       | 估计时间     | 估计成本         |
| -------------- | --------- | -------- | ------------ |
| 单个蛋白（约 300aa）  | RTX 3090  | 1–2 小时   | 约 $0.30–0.60 |
| 单个蛋白（约 500aa）  | RTX 4090  | 45–90 分钟 | 约 $0.40–0.80 |
| 多聚体复合物         | A100 80GB | 2–4 小时   | 约 $1.50–3.00 |
| 蛋白组筛查（100 个蛋白） | A100 80GB | 8–12 小时  | 约 $6–10      |

*成本为近似值，取决于当前市场价格。*

***

## 其他资源

* [AlphaFold2 GitHub](https://github.com/google-deepmind/alphafold)
* [AlphaFold 数据库](https://alphafold.ebi.ac.uk/) — 2 亿+ 蛋白的预计算结构
* [ColabFold GitHub](https://github.com/sokrypton/ColabFold)
* [DeepMind AlphaFold 博客](https://www.deepmind.com/research/highlighted-research/alphafold)
* [OpenFold](https://github.com/aqlaboratory/openfold) — 可训练的 PyTorch 重实现
* [ESMFold](https://github.com/facebookresearch/esm) — Meta 更快的替代方案

***

*本指南涵盖在 Clore.ai GPU 租赁上部署 AlphaFold2。有关最新的 AlphaFold3，请参见单独的 AlphaFold3 指南。*

***

## Clore.ai GPU 推荐

| 使用场景      | 推荐 GPU         | Clore.ai 预计成本                     |
| --------- | -------------- | --------------------------------- |
| 开发/测试     | RTX 3090（24GB） | $0.07–0.21/gpu/hr                 |
| 标准蛋白      | RTX 4090（24GB） | $0.14–0.42/gpu/hr                 |
| 大分子 / 多聚体 | A100 80GB      | [裸机](https://clore.ai/bare-metal) |

> 💡 本指南中的所有示例都可以部署在 [Clore.ai](https://clore.ai/marketplace) GPU 服务器上。浏览可用 GPU 并按小时租用——无需承诺，拥有完整 root 访问权限。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.clore.ai/guides/guides_v2-zh/ke-xue-yu-yan-jiu/alphafold2.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
