关于 alterlab-interpro
alterlab-interpro 是面向蛋白质研究者的技能,通过 InterPro REST API 查询蛋白质家族、结构域及功能注释,并支持批量查找与结构域架构分析。
主要功能
- 01查询 UniProt 蛋白质的 InterPro 条目
- 02获取条目详情及匹配位置
- 03按条目查找蛋白质
- 04映射 GO 术语
- 05搜索条目及分类群数据
适用场景
- 01推断未知蛋白质的功能
- 02比较蛋白质的结构域组成
- 03查找某蛋白家族的成员
- 04为蛋白质映射 GO 术语
安装
复制下面的命令,在终端中运行。
npx skills add https:/ / github.com/ alterlab-ieu/ alterlab-academic-skills --skill alterlab-interpro安装后在 Claude Code 中输入/alterlab-interpro确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
evals/evals.jsonreferences/domain_analysis.mdscripts/query_interpro.py详细介绍
InterPro 数据库
概述
InterPro(https://www.ebi.ac.uk/interpro/)是 EMBL-EBI 维护的蛋白质家族和结构域分类综合资源。它整合了其成员数据库的预测特征——包括 Pfam、PANTHER、PRINTS、ProSite、SMART、NCBIfam、SUPERFAMILY、CDD、Gene3D 等(见下方成员数据库表)——形成统一的条目集合,从而统一展示 UniProtKB 中的功能注释。(旧版 TIGRFAMs 已并入 NCBIfam。)
InterPro 将蛋白质分类为:
- 家族:具有共同祖先和功能的蛋白质群组
- 结构域:可独立折叠的结构或功能单元
- 同源超家族:结构相似的蛋白质区域
- 重复序列:短串联序列
- 位点:功能位点(活性、结合、PTM)
主要资源:
- InterPro 网站:https://www.ebi.ac.uk/interpro/
- REST API:https://www.ebi.ac.uk/interpro/api/
- API 文档:https://github.com/ProteinsWebTeam/interpro7-api/blob/master/docs/
- Python 客户端:通过
requests
脚本
scripts/query_interpro.py — 查询 InterPro REST API(仅使用标准库,向 stdout 输出 JSON):
python scripts/query_interpro.py protein P04637 # InterPro entries for a UniProt protein
python scripts/query_interpro.py entry IPR000719 # entry details
python scripts/query_interpro.py entry-proteins IPR000719 --page-size 25 # proteins with an entry
何时使用此技能
在以下场景中使用 InterPro:
- 蛋白质功能预测:未表征的蛋白质可能具有什么功能?
- 结构域架构:蛋白质由哪些结构域组成,排列顺序如何?
- 蛋白质家族分类:蛋白质属于哪个家族或超家族?
- GO 术语注释:通过 InterPro 将蛋白质序列映射到 Gene Ontology 术语
- 进化分析:两个蛋白质是否属于同一同源超家族?
- 结构预测背景:新的蛋白质结构应与哪些结构域进行比较?
- 流水线注释:批量注释蛋白质组或新序列
不适用场景
| 场景 | 改用 |
|---|---|
| 检索 UniProt 条目、FASTA 序列或 ID 映射 | alterlab-uniprot |
| 预测的 3D 模型和 pLDDT 置信度 | alterlab-alphafold-db |
| 实验结构、配体、分辨率 | alterlab-pdb |
| 蛋白质-蛋白质相互作用网络和富集分析 | alterlab-string-db |
| 在数据库中进行序列相似性搜索 | alterlab-blast |
核心能力
1. InterPro REST API
基础 URL:https://www.ebi.ac.uk/interpro/api/
import requests
BASE_URL = "https://www.ebi.ac.uk/interpro/api"
def interpro_get(endpoint, params=None):
url = f"{BASE_URL}/{endpoint}"
headers = {"Accept": "application/json"}
response = requests.get(url, params=params, headers=headers)
response.raise_for_status()
return response.json()
端点方向注意事项(请先阅读)。 在 InterPro API 中,路径的第一个片段表示返回的资源类型。要列出某个蛋白质的条目,蛋白质筛选条件要放在最后:entry/InterPro/protein/UniProt/{id}/。要列出某个条目对应的蛋白质,则要将蛋白质资源放在最前面:protein/UniProt/entry/InterPro/{id}/。反向形式(protein/UniProt/{id}/entry/InterPro/、entry/InterPro/{id}/protein/UniProt/)只会返回一个 *_url 包装对象,其中没有 results,且 count: null——这是静默的空结果,并非错误。
2. 查询蛋白质
def get_protein_entries(uniprot_id):
"""Get all InterPro entries that match a UniProt protein."""
# Resource (entry) first, protein filter last — see direction gotcha above.
data = interpro_get(f"entry/InterPro/protein/UniProt/{uniprot_id}/")
return data
# Example: Human p53 (TP53)
result = get_protein_entries("P04637")
entries = result.get("results", [])
for entry in entries:
meta = entry["metadata"] # `name` is a string on this grouped endpoint
print(f" {meta['accession']} ({meta['type']}): {meta['name']}")
# e.g., IPR002117 (family): p53 tumour suppressor family
# IPR011615 (domain): p53, DNA-binding domain
# IPR010991 (domain): p53, tetramerisation domain
3. 获取特定 InterPro 条目
def get_entry(interpro_id):
"""Fetch details for an InterPro entry."""
return interpro_get(f"entry/InterPro/{interpro_id}/")
# Example: Get the InterPro entry the WW domain maps to
ww_entry = get_entry("IPR001202")
# On the single-entry detail endpoint, `name` is a dict {"name", "short"};
# on list/grouped endpoints it is a plain string. Handle both:
name = ww_entry["metadata"]["name"]
print(f"Name: {name['name'] if isinstance(name, dict) else name}")
print(f"Type: {ww_entry['metadata']['type']}") # -> domain
# Member-database accessions resolve through the same endpoint shape.
# Use lowercase db names (entry/pfam/...); the response carries the
# integrated InterPro accession under metadata['integrated'].
def get_pfam_entry(pfam_id):
return interpro_get(f"entry/pfam/{pfam_id}/")
pfam = get_pfam_entry("PF00397") # metadata['integrated'] == 'IPR001202'
4. 按 InterPro 条目搜索蛋白质
def get_proteins_for_entry(interpro_id, database="UniProt", page_size=25):
"""Get all proteins annotated with an InterPro entry."""
params = {"page_size": page_size}
# Resource (protein) first, entry filter last — see direction gotcha above.
data = interpro_get(f"protein/{database}/entry/InterPro/{interpro_id}/", params)
return data
# Example: count proteins carrying the protein kinase domain
kinase_proteins = get_proteins_for_entry("IPR000719") # Protein kinase domain
print(f"Total proteins: {kinase_proteins['count']}") # response has count/next/results
5. 结构域架构
每个残基的匹配位置位于按条目/蛋白质分组的端点中,而不在 protein/UniProt/{id}/ 单独记录中(该记录仅包含 metadata,没有 entries 键)。每个条目的匹配结果位于 results[].proteins[].entry_protein_locations[].fragments[] 下:
def get_domain_architecture(uniprot_id):
"""Get the domain architecture of a protein with sequence positions."""
data = interpro_get(f"entry/InterPro/protein/UniProt/{uniprot_id}/")
arch = []
for result in data.get("results", []):
meta = result["metadata"]
for prot in result.get("proteins", []):
for loc in prot.get("entry_protein_locations", []):
for frag in loc.get("fragments", []):
arch.append({
"accession": meta["accession"],
"type": meta["type"],
"name": meta["name"],
"start": frag["start"],
"end": frag["end"],
})
# Order along the sequence to read off the architecture N->C terminus
arch.sort(key=lambda d: d["start"])
return arch
# Example: full domain architecture for EGFR, ordered along the sequence
for d in get_domain_architecture("P00533"):
print(f" {d['start']:>5}-{d['end']:<5} {d['accession']} ({d['type']}): {d['name']}")
6. GO 术语映射
蛋白质记录会在 metadata.go_terms 下汇总其所有 InterPro 特征的 GO 术语(已去重),因此无需逐个遍历条目:
def get_go_terms_for_protein(uniprot_id):
"""Get GO terms associated with a protein via InterPro."""
data = interpro_get(f"protein/UniProt/{uniprot_id}/")
# NB: go_terms can be present but null for proteins with no GO mapping,
# so coalesce to [] rather than relying on the dict default.
return data.get("metadata", {}).get("go_terms") or []
# GO terms look like:
# {"identifier": "GO:0004672", "name": "protein kinase activity",
# "category": {"code": "F", "name": "molecular_function"}}
# category.code is one of F (molecular_function), P (biological_process),
# C (cellular_component).
若要将 GO 术语归属到特定特征,而不是整个蛋白质,请读取 entry/InterPro/protein/UniProt/{id}/ 返回的每个条目中的 metadata.go_terms(每个条目都有自己的 go_terms)。
7. 批量查询蛋白质
def batch_lookup_proteins(uniprot_ids, database="UniProt"):
"""Look up multiple proteins and collect their InterPro entries."""
import time
results = {}
for uid in uniprot_ids:
try:
data = interpro_get(f"entry/InterPro/protein/{database}/{uid}/")
entries = data.get("results", [])
results[uid] = [
{
"accession": e["metadata"]["accession"],
"name": e["metadata"]["name"],
"type": e["metadata"]["type"]
}
for e in entries
]
except Exception as e:
results[uid] = {"error": str(e)}
time.sleep(0.3) # Rate limiting
return results
# Example
proteins = ["P04637", "P00533", "P38398", "Q9Y6I9"]
domain_info = batch_lookup_proteins(proteins)
for uid, entries in domain_info.items():
print(f"\n{uid}:")
for e in entries[:3]:
print(f" - {e['accession']} ({e['type']}): {e['name']}")
8. 按文本或分类群搜索
def search_entries(query, entry_type=None, taxonomy_id=None):
"""Search InterPro entries by text."""
params = {"search": query, "page_size": 20}
if entry_type:
params["type"] = entry_type # family, domain, homologous_superfamily, etc.
endpoint = "entry/InterPro/"
if taxonomy_id:
# taxonomy is a filter, not the returned resource, so it can follow
# the entry resource directly (lowercase 'uniprot' in the path).
endpoint = f"entry/InterPro/taxonomy/uniprot/{taxonomy_id}/"
return interpro_get(endpoint, params)
# Search for kinase-related entries
kinase_entries = search_entries("kinase", entry_type="domain")
查询工作流
工作流 1:表征未知蛋白质
- 运行 InterProScan:在本地运行或通过网页(https://www.ebi.ac.uk/interpro/search/sequence/)扫描蛋白质序列
- 解析结果,确定结构域架构
- 查询每个 InterPro 条目,了解其生物学背景
- 从关联的 InterPro 条目中获取 GO 术语,以推断功能
# After running InterProScan and getting a UniProt ID:
def characterize_protein(uniprot_id):
"""Complete characterization workflow."""
# 1. Get all annotations
entries = get_protein_entries(uniprot_id)
# 2. Group by type
by_type = {}
for e in entries.get("results", []):
t = e["metadata"]["type"]
by_type.setdefault(t, []).append({
"accession": e["metadata"]["accession"],
"name": e["metadata"]["name"]
})
# 3. Get GO terms
go_terms = get_go_terms_for_protein(uniprot_id)
return {
"families": by_type.get("family", []),
"domains": by_type.get("domain", []),
"superfamilies": by_type.get("homologous_superfamily", []),
"go_terms": go_terms
}
工作流 2:查找蛋白质家族的所有成员
- 确定 InterPro 家族条目 ID(例如,蛋白激酶的 IPR000719)
- 查询所有注释了该条目的 UniProt 蛋白质
- 按需根据物种/分类群进行筛选
- 下载 FASTA 序列,用于系统发育分析
工作流 3:比较结构域分析
- 收集感兴趣的蛋白质(例如,所有旁系同源蛋白)
- 获取每种蛋白质的结构域架构
- 比较结构域组成和顺序
- 确定结构域获得/丢失事件
API 端点摘要
返回的资源类型由路径中最先出现的部分决定;后面的筛选条件会缩小范围。交换两部分的顺序会得到一个仅包含 *_url 的包装对象。
| 端点 | 描述 |
|---|---|
/protein/UniProt/{id}/ | 蛋白质的完整注释(包括 metadata.go_terms) |
/entry/InterPro/protein/UniProt/{id}/ | 蛋白质的 InterPro 条目(含匹配位置) |
/entry/InterPro/{id}/ | InterPro 条目的详细信息(name 是一个 {name,short} 字典) |
/entry/pfam/{id}/ | Pfam 成员数据库条目的详细信息(metadata.integrated = InterPro id) |
/protein/UniProt/entry/InterPro/{id}/ | 携带某条目的蛋白质(分页,含 count) |
/entry/InterPro/?search=... | 搜索/列出 InterPro 条目(此处的 name 是字符串) |
/entry/InterPro/taxonomy/uniprot/{tax_id}/ | 在某个分类群中发现的 InterPro 条目(分页) |
/structure/PDB/entry/InterPro/{id}/ | 映射到某个条目的结构 |
成员数据库
API 返回的源数据库名称(source_database 字段/entry/{db}/... 路径部分)与显示名称不同时,会在括号中注明。
| 数据库 | 侧重点 |
|---|---|
Pfam(pfam) | 蛋白质结构域(HMM 模型) |
PANTHER(panther) | 蛋白质家族和亚家族 |
PRINTS(prints) | 蛋白质指纹 |
ProSite patterns(prosite) | 氨基酸模式 |
ProSite profiles(profile) | 蛋白质模型模式 |
SMART(smart) | 可移动信号/细胞外结构域 |
NCBIfam(ncbifam) | NCBI 整理的家族(已吸收原 TIGRFAMs) |
SUPERFAMILY(ssf) | SCOP 结构分类 |
CDD(cdd) | 保守结构域数据库(NCBI) |
HAMAP(hamap) | 微生物蛋白质家族 |
Gene3D(cathgene3d) | CATH 结构分类 |
PIRSF(pirsf) | PIR 全蛋白质家族 |
SFLD(sfld) | 结构—功能关联数据库(酶) |
AntiFam(antifam) | 可疑 ORF 过滤器(去除假阳性) |
最佳实践
- 使用 UniProt 登录号(而非基因名称),以获得最可靠的查询结果
- 区分类型:
family提供广义分类;domain提供特定的结构/功能单元 - 对于新序列,InterProScan 速度更快:对于 UniProt 中没有的序列,请提交至网络服务
- 处理分页:大型结果集需要逐页遍历
- 结合 UniProt 数据使用:InterPro 条目通常包含指向 UniProt、PDB 和 GO 的链接
更多资源
- InterPro 网站:https://www.ebi.ac.uk/interpro/
- InterProScan(本地运行):https://github.com/ebi-pf-team/interproscan
- API 文档:https://github.com/ProteinsWebTeam/interpro7-api/blob/master/docs/
- Pfam:https://www.ebi.ac.uk/interpro/entry/pfam/
- 引用文献:Blum M 等(2025)InterPro:2025 年蛋白质序列分类资源。Nucleic Acids Research 53(D1):D444–D456。PMID:39565202。DOI:10.1093/nar/gkae1082