Swiss-Model — 蛋白质同源建模在线服务器¶
一句话说明¶
Swiss-Model 是 SIB 提供的免费蛋白质同源建模服务器,输入氨基酸序列,自动搜索已知 PDB 结构作为模板,构建三维结构模型,适合有已知同源蛋白(序列相似度 >30%)时快速获得结构。白话理解:把已知蛋白质结构当"模子",把你的蛋白序列"套"进去,做出新的结构。
安装与配置¶
Swiss-Model 主要是在线服务器,无需安装:
如果需要本地化批量建模,可以用官方 API 或 ProMod3(本地版):
# 方法1:使用 Python 调用 Swiss-Model API
pip install requests # 只需 requests 库
# 方法2:安装 ProMod3(Swiss-Model 本地引擎,需编译)
# 访问:https://openstructure.org/promod3/
# 通常建议直接用在线版,本地版安装复杂
# 方法3:用 Biopython 处理结果
pip install biopython # 用于读写 PDB 文件和分析结果
核心用法¶
在线服务器建模流程¶
1. 访问 https://swissmodel.expasy.org/
2. 点击 "Start Modelling"
3. 输入:
- Target Sequence:粘贴氨基酸序列(FASTA 格式)
- Email:填邮箱接收结果通知
4. 点击 "Build Model"
5. 等待完成(通常几分钟到30分钟)
6. 下载结果(PDB 文件 + GMQE/QSQE 质量分数)
Python API 自动提交建模任务¶
import requests # HTTP 请求库
import time # 等待轮询
import json # 解析 JSON 响应
# Swiss-Model API URL
API_BASE = "https://swissmodel.expasy.org/automodel"
# 提交建模请求
def submit_modeling(sequence, project_title="MyModel"):
"""提交蛋白质序列到 Swiss-Model 进行同源建模"""
headers = {
"Authorization": "Token YOUR_API_TOKEN", # 注册后获取 API Token
"Content-Type": "application/json"
}
payload = {
"target_sequences": sequence, # 目标氨基酸序列
"project_title": project_title, # 项目名称
}
response = requests.post(
API_BASE, # 提交到 API 端点
json=payload, # JSON 格式数据
headers=headers # 认证头
)
if response.status_code == 201: # 201=创建成功
result = response.json()
project_id = result["project_id"] # 获取项目 ID
print(f"任务提交成功,项目 ID:{project_id}")
return project_id
else:
print(f"提交失败:{response.status_code}")
print(response.text)
return None
# 轮询查询建模状态
def wait_for_result(project_id, max_wait_minutes=30):
"""等待建模完成并返回结果"""
headers = {"Authorization": "Token YOUR_API_TOKEN"}
url = f"{API_BASE}/{project_id}/" # 查询特定项目的 URL
for attempt in range(max_wait_minutes * 2): # 每30秒查一次
response = requests.get(url, headers=headers)
data = response.json()
status = data.get("status") # 查询状态
print(f"状态:{status}")
if status == "COMPLETED": # 建模完成
return data
elif status in ["FAILED", "ERROR"]: # 建模失败
print(f"建模失败:{data}")
return None
time.sleep(30) # 等待30秒再查询
print("超时!请登录网站查看结果")
return None
# 使用示例
sequence = """MKTAYIAKQRQISFVKSHFSRQLEERLGLIEVQAPILSRVGDGTQDNLSG
AEKAVQVKVKALPDAQFEVVHSLAKWKRQTLGQHDFSAGEGLYTHMKALR""" # 目标序列
project_id = submit_modeling(sequence, "MyProtein") # 提交任务
if project_id:
result = wait_for_result(project_id) # 等待结果
if result:
# 下载第一个模型
models = result.get("models", [])
if models:
model_url = models[0]["coordinates_url"] # 坐标文件 URL
pdb_response = requests.get(model_url)
with open("model.pdb", "w") as f:
f.write(pdb_response.text) # 保存 PDB 文件
# 打印质量评估分数
gmqe = models[0].get("gmqe", "N/A") # 全局模型质量评估
qsqe = models[0].get("qsqe", "N/A") # 四聚体结构质量
print(f"GMQE 分数:{gmqe}(范围 0-1,越高越好)")
print(f"QSQE 分数:{qsqe}")
参数详解¶
质量评估分数¶
| 指标 | 全称 | 含义 | 阈值 |
|---|---|---|---|
| GMQE | Global Model Quality Estimation | 全局模型质量(综合序列相似度+模板覆盖度) | >0.6 = 好 |
| QSQE | Quaternary Structure Quality Estimate | 多聚体结构质量 | >0.6 = 可靠 |
| MolProbity | — | Ramachandran 图异常率 | >98% = 好 |
| QMEANDisCo | — | 每残基局部质量分数 | 0-1,1=最好 |
建模模式¶
| 模式 | 含义 | 适用场景 |
|---|---|---|
| Automated Mode | 自动选最佳模板 | 常规建模 |
| Template Selection | 手动选模板 | 知道具体模板时 |
| Oligomeric State | 构建多聚体 | 预测复合体结构 |
| User Template | 上传自定义模板 | 有自己的实验结构 |
实战案例¶
案例:评估建模质量并可视化¶
from Bio import PDB # Biopython 的 PDB 处理模块
import numpy as np
import matplotlib.pyplot as plt
# 读取 Swiss-Model 下载的 PDB 文件(含 BFACTOR = QMEANDisCo 分数)
parser = PDB.PDBParser(QUIET=True) # 创建 PDB 解析器
structure = parser.get_structure("model", "model.pdb") # 解析结构
# 提取每残基的质量分数(存储在 B-factor 列中)
residues = []
quality_scores = []
for model in structure:
for chain in model:
for residue in chain:
if PDB.is_aa(residue): # 只处理氨基酸残基
res_id = residue.get_id()[1] # 残基编号
# 取 CA 原子的 B factor 作为质量分数
if "CA" in residue:
bfactor = residue["CA"].get_bfactor()
residues.append(res_id)
quality_scores.append(bfactor)
# 绘制质量分数图
fig, ax = plt.subplots(figsize=(12, 4))
ax.bar(residues, quality_scores, # 柱状图
color=["green" if s > 0.6 else "orange" if s > 0.4 else "red"
for s in quality_scores], # 按分数着色
width=1, edgecolor="none")
ax.axhline(y=0.6, color="black", # 0.6 参考线
linestyle="--", label="Good (>0.6)")
ax.set_xlabel("Residue Number")
ax.set_ylabel("QMEANDisCo Local Score")
ax.set_title("Per-Residue Model Quality")
ax.legend()
plt.tight_layout()
plt.savefig("model_quality.pdf")
print(f"平均质量分数: {np.mean(quality_scores):.3f}")
常见报错与解决¶
| 问题 | 原因 | 解决方法 |
|---|---|---|
| GMQE < 0.4 | 序列相似度低(<30%)或无合适模板 | 改用 ColabFold / ESMFold 从头预测 |
| 模板覆盖率低 | 序列有大段无结构域相同的区域 | 分段建模或用 AlphaFold2 |
| API Token 无效 | Token 过期或输入有误 | 登录官网重新获取 Token |
| 建模结果全部 N/A | 提交序列太短(<30aa)或含非标准字符 | 检查序列,去掉非氨基酸字符 |
| 服务器超时 | 服务器负载高 | 等几小时后重试;或使用 ProMod3 本地版 |
速查表¶
# 在线服务
主站:https://swissmodel.expasy.org/
文档:https://swissmodel.expasy.org/docs/
API:https://swissmodel.expasy.org/docs/repository
# 关键质量指标
GMQE > 0.6 → 建模质量好(可信赖)
GMQE 0.4-0.6 → 中等质量(仅供参考)
GMQE < 0.4 → 质量差(不建议用,改用 AlphaFold2)
# 同源建模适用场景
- 序列相似度 > 50%:GMQE 通常很高,结果可靠
- 序列相似度 30-50%:需仔细评估 GMQE 和 MolProbity
- 序列相似度 < 30%:考虑 AlphaFold2/ColabFold/ESMFold
# 结果文件格式
model.pdb → 三维坐标(B-factor 存储质量分数)
report.html → 完整评估报告(Ramachandran 图等)