# AlphaFold2 蛋白质预测

> **使用诺贝尔奖级别的人工智能预测蛋白质结构 — 在 Clore.ai 上由 GPU 加速提供支持**

AlphaFold2 由 DeepMind 开发，通过以原子级精度预测蛋白质三维结构，彻底改变了结构生物学。它已应用于超过 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 加速中获得巨大收益：

| 硬件           | 预测时间（典型蛋白 \~400 aa） |
| ------------ | ------------------- |
| 仅 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：**

* **💡 本指南中的所有示例均可部署在** — 最适合大型蛋白（>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 核
* 内存：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）— 大型精彩数据库
* **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"Mean pLDDT: {np.mean(plddt_scores):.1f}")
print(f"Residues >90 pLDDT: {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" %}
**ColabFold 通常比原始 AlphaFold2 流水线快 10–40 倍，** 这要归功于 MMseqs2 的 MSA 服务。非常适合迭代研究工作流程。
{% endhint %}

***

## 故障排除

### CUDA 内存不足（Out of Memory）

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

# 或使用减少的回收次数运行
--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
```

***

## 1. 使用 SDXL-Turbo 或 SDXL-Lightning 以实现快速生成

{% 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 放松快得多
   {% endhint %}

***

## Clore.ai 上的成本估算

| 场景             | GPU               | 预计时间     | 预计成本         |
| -------------- | ----------------- | -------- | ------------ |
| 单个蛋白（\~300 aa） | RTX 3090          | 1–2 小时   | \~$0.30–0.60 |
| 单个蛋白（\~500 aa） | RTX 4090          | 45–90 分钟 | \~$0.40–0.80 |
| 多聚体复合体         | 💡 本指南中的所有示例均可部署在 | 2–4 小时   | \~$1.50–3.00 |
| 蛋白组筛查（100 个蛋白） | 💡 本指南中的所有示例均可部署在 | 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 建议

| 在 Clore.ai 上的预估费用 | 开发/测试             | RTX 3090（24GB） |
| ----------------- | ----------------- | -------------- |
| \~$0.12/每 GPU/每小时 | 生产                | RTX 4090（24GB） |
| 标准蛋白              | 大规模               | A100 80GB      |
| 大分子 / 多聚体         | 💡 本指南中的所有示例均可部署在 | Clore.ai       |

> GPU 服务器上。浏览可用 GPU 并按小时租用 — 无需承诺，提供完整的 root 访问权限。 [Clore.ai](https://clore.ai/marketplace) GPU 服务器。浏览可用 GPU 并按小时租用 — 无需承诺，提供完整的 root 访问权限。


---

# Agent Instructions: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
