用途
UniProt 技能用于访问 UniProt 数据库,检索蛋白质序列与注释信息。该技能直接使用 UniProt REST API,无需 Modal 部署,所有操作均通过本地 HTTP 请求完成。
主要能力
- 按登录号获取蛋白质序列(FASTA 格式或带注释的 JSON 格式)。
- 获取完整 UniProt 条目,包括蛋白质名称等描述信息。
- 提取结构域注释,包括结构域名称、起始和结束位置。
- 按基因名或关键词搜索 UniProt,可限定物种(如 organism_id:9606 表示人类)。
- 通过 UniProt BLAST 进行序列相似性搜索(链接至 https://www.uniprot.org/blast)。
- 获取交叉引用,例如 PDB 结构,包括 PDB ID、方法和链信息。
- 获取自然变异信息,包括位置、原始序列、变异序列和描述。
使用方式
获取序列
按登录号获取 FASTA 格式:
curl "https://rest.uniprot.org/uniprotkb/P00533.fasta"
获取带注释的 JSON 格式:
curl "https://rest.uniprot.org/uniprotkb/P00533.json"
使用 Python:
import requests
def get_uniprot_sequence(accession):
"""Fetch sequence from UniProt."""
url = f"https://rest.uniprot.org/uniprotkb/{accession}.fasta"
response = requests.get(url)
if response.ok:
lines = response.text.strip().split('\n')
header = lines[0]
sequence = ''.join(lines[1:])
return header, sequence
return None, None
获取注释
获取完整条目:
def get_uniprot_entry(accession):
"""Fetch full UniProt entry as JSON."""
url = f"https://rest.uniprot.org/uniprotkb/{accession}.json"
response = requests.get(url)
return response.json() if response.ok else None
entry = get_uniprot_entry("P00533")
print(f"Protein: {entry['proteinDescription']['recommendedName']['fullName']['value']}")
提取结构域边界:
def get_domains(accession):
"""Extract domain annotations."""
entry = get_uniprot_entry(accession)
domains = []
for feature in entry.get('features', []):
if feature['type'] == 'Domain':
domains.append({
'name': feature.get('description', ''),
'start': feature['location']['start']['value'],
'end': feature['location']['end']['value']
})
return domains
# Example: EGFR domains
domains = get_domains("P00533")
# [{'name': 'Kinase', 'start': 712, 'end': 979}, ...]
搜索 UniProt
按基因名搜索:
def search_uniprot(query, organism=None, limit=10):
"""Search UniProt by query."""
url = "https://rest.uniprot.org/uniprotkb/search"
params = {
"query": query,
"format": "json",
"size": limit
}
if organism:
params["query"] += f" AND organism_id:{organism}"
response = requests.get(url, params=params)
return response.json()['results']
# Search for human EGFR
results = search_uniprot("EGFR", organism=9606)
按序列相似性搜索(BLAST):
# Use UniProt BLAST
# https://www.uniprot.org/blast
交叉引用
获取 PDB 结构:
def get_pdb_references(accession):
"""Get PDB structures for UniProt entry."""
entry = get_uniprot_entry(accession)
pdbs = []
for xref in entry.get('uniProtKBCrossReferences', []):
if xref['database'] == 'PDB':
pdbs.append({
'pdb_id': xref['id'],
'method': xref.get('properties', [{}])[0].get('value', ''),
'chains': xref.get('properties', [{}])[1].get('value', '')
})
return pdbs
# Example: PDB structures for EGFR
pdbs = get_pdb_references("P00533")
常见使用场景
靶点选择:
# 1. Find protein by name
results = search_uniprot("insulin receptor", organism=9606)
# 2. Get accession
accession = results[0]['primaryAccession'] # e.g., P06213
# 3. Get domains
domains = get_domains(accession)
# 4. Find PDB structure
pdbs = get_pdb_references(accession)
# 5. Download best structure for design
序列比对信息:
def get_sequence_variants(accession):
"""Get natural variants from UniProt."""
entry = get_uniprot_entry(accession)
variants = []
for feature in entry.get('features', []):
if feature['type'] == 'Natural variant':
variants.append({
'position': feature['location']['start']['value'],
'original': feature.get('alternativeSequence', {}).get('originalSequence', ''),
'variant': feature.get('alternativeSequence', {}).get('alternativeSequences', [''])[0],
'description': feature.get('description', '')
})
return variants
API 参考
| 端点 | 描述 |
|---|---|
| /uniprotkb/{id}.fasta | FASTA 序列 |
| /uniprotkb/{id}.json | 完整条目 JSON |
| /uniprotkb/search | 搜索条目 |
| /uniprotkb/stream | 批量下载 |
适用场景
- 按登录号查找蛋白质序列。
- 查找蛋白质功能注释、结构域边界和自然变异。
- 按基因名或关键词搜索蛋白质,并限定物种。
- 获取与 UniProt 条目关联的 PDB 结构,用于后续蛋白质设计。
- 为下游任务准备序列,例如使用 esm 生成嵌入,或使用 chai / boltz 进行结构预测。
限制与故障排除
- 条目未找到:检查登录号格式(例如 P00533)。
- 速率限制:在请求之间添加延迟。
- 大型下载:使用 stream 端点并配合分页。
- 该技能依赖 UniProt REST API 的可用性,未提供离线或本地数据库方案。
- 未提供关于收费、价格或平台支持的说明。