mcpField
S
string-database

string-database

github.com/leonchaox数据与数据库99470 次安装15 周前更新
代码仓库

关于 string-database

STRING Database 技能通过 REST API 查询蛋白质相互作用网络,并支持功能富集、网络扩展和同源分析。它面向系统生物学及通路分析,可处理多种生物的蛋白质列表。

主要功能

  1. 01映射基因名和蛋白质标识符
  2. 02获取带置信度分数的相互作用网络
  3. 03查找相互作用伙伴并扩展网络
  4. 04执行 GO、KEGG 等功能富集分析
  5. 05生成网络图像并查询同源信息

适用场景

  1. 01分析实验得到的蛋白质列表
  2. 02发现单个蛋白质的相互作用伙伴
  3. 03比较不同物种的蛋白质网络
  4. 04检验蛋白质是否构成功能模块

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/leonchaox/qinyan-academic-skills --skill string-database

安装后在 Claude Code 中输入/string-database确认已加载。

附带文件references/string_reference.mdscripts/string_api.py

详细介绍

STRING 数据库

概述

STRING 是一个综合性数据库,涵盖 5000 多种生物体中的 5900 万个蛋白质和 200 多亿种已知及预测的蛋白质-蛋白质相互作用。通过 REST API 查询相互作用网络、进行功能富集分析、发现相互作用对象,适用于系统生物学和通路分析。

何时使用此技能

在以下情况下应使用此技能:

  • 获取单个或多个蛋白质的蛋白质-蛋白质相互作用网络
  • 对蛋白质列表进行功能富集分析(GO、KEGG、Pfam)
  • 发现相互作用对象并扩展蛋白质网络
  • 检验蛋白质是否构成功能显著富集的模块
  • 使用基于证据的配色生成网络可视化
  • 分析同源性和蛋白质家族关系
  • 开展跨物种蛋白质相互作用比较
  • 识别枢纽蛋白和网络连接模式

快速入门

此技能提供:

  1. 用于所有 STRING REST API 操作的 Python 辅助函数(scripts/string_api.py)
  2. 包含详细 API 规范的全面参考文档(references/string_reference.md)

当用户请求 STRING 数据时,请确定所需的操作,并使用 scripts/string_api.py 中相应的函数。

核心操作

1. 标识符映射(string_map_ids)

将基因名称、蛋白质名称和外部 ID 转换为 STRING 标识符。

使用时机:开始任何 STRING 分析、验证蛋白质名称、查找规范标识符。

用法:

from scripts.string_api import string_map_ids

# Map single protein
result = string_map_ids('TP53', species=9606)

# Map multiple proteins
result = string_map_ids(['TP53', 'BRCA1', 'EGFR', 'MDM2'], species=9606)

# Map with multiple matches per query
result = string_map_ids('p53', species=9606, limit=5)

参数:

  • species:NCBI 分类群 ID(9606 = 人类,10090 = 小鼠,7227 = 果蝇)
  • limit:每个标识符的匹配数量(默认值:1)
  • echo_query:在输出中包含查询词(默认值:1)

最佳实践:始终先映射标识符,以加快后续查询。

2. 网络检索(string_network)

以表格格式获取蛋白质-蛋白质相互作用网络数据。

使用时机:构建相互作用网络、分析连接性、检索相互作用证据。

用法:

from scripts.string_api import string_network

# Get network for single protein
network = string_network('9606.ENSP00000269305', species=9606)

# Get network with multiple proteins
proteins = ['9606.ENSP00000269305', '9606.ENSP00000275493']
network = string_network(proteins, required_score=700)

# Expand network with additional interactors
network = string_network('TP53', species=9606, add_nodes=10, required_score=400)

# Physical interactions only
network = string_network('TP53', species=9606, network_type='physical')

参数:

  • required_score:置信度阈值(0-1000)
    • 150:低置信度(探索性)
    • 400:中等置信度(默认值,标准分析)
    • 700:高置信度(保守)
    • 900:最高置信度(非常严格)
  • network_type:'functional'(所有证据,默认值)或 'physical'(仅直接结合)
  • add_nodes:添加连接数最多的 N 个蛋白质(0-10)

输出列:相互作用对、置信度分数以及各项证据分数(邻域、融合、共表达、实验、数据库、文本挖掘)。

3. 网络可视化(string_network_image)

生成 PNG 格式的网络可视化图像。

使用时机:制作图表、进行可视化探索、准备演示材料。

用法:

from scripts.string_api import string_network_image

# Get network image
proteins = ['TP53', 'MDM2', 'ATM', 'CHEK2', 'BRCA1']
img_data = string_network_image(proteins, species=9606, required_score=700)

# Save image
with open('network.png', 'wb') as f:
    f.write(img_data)

# Evidence-colored network
img = string_network_image(proteins, species=9606, network_flavor='evidence')

# Confidence-based visualization
img = string_network_image(proteins, species=9606, network_flavor='confidence')

# Actions network (activation/inhibition)
img = string_network_image(proteins, species=9606, network_flavor='actions')

网络样式:

  • 'evidence':用不同颜色的线条表示证据类型(默认值)
  • 'confidence':线条粗细表示置信度
  • 'actions':显示激活/抑制关系
4. 相互作用对象(string_interaction_partners)

查找与给定蛋白质相互作用的所有蛋白质。

使用时机:发现新的相互作用、查找枢纽蛋白、扩展网络。

用法:

from scripts.string_api import string_interaction_partners

# Get top 10 interactors of TP53
partners = string_interaction_partners('TP53', species=9606, limit=10)

# Get high-confidence interactors
partners = string_interaction_partners('TP53', species=9606,
                                      limit=20, required_score=700)

# Find interactors for multiple proteins
partners = string_interaction_partners(['TP53', 'MDM2'],
                                      species=9606, limit=15)

参数:

  • limit:要返回的相互作用对象数量上限(默认值:10)
  • required_score:置信度阈值(0-1000)

用例:

  • 识别枢纽蛋白
  • 从种子蛋白扩展网络
  • 发现间接连接
5. 功能富集(string_enrichment)

对 Gene Ontology、KEGG 通路、Pfam 结构域等进行富集分析。

适用场景:解读蛋白质列表、通路分析、功能表征、了解生物过程。

用法:

from scripts.string_enrichment import string_enrichment

# Enrichment for a protein list
proteins = ['TP53', 'MDM2', 'ATM', 'CHEK2', 'BRCA1', 'ATR', 'TP73']
enrichment = string_enrichment(proteins, species=9606)

# Parse results to find significant terms
import pandas as pd
df = pd.read_csv(io.StringIO(enrichment), sep='\t')
significant = df[df['fdr'] < 0.05]

富集类别:

  • Gene Ontology:生物过程、分子功能、细胞组分
  • KEGG Pathways:代谢和信号通路
  • Pfam:蛋白质结构域
  • InterPro:蛋白质家族和结构域
  • SMART:结构域架构
  • UniProt Keywords:人工整理的功能关键词

输出列:

  • category:注释数据库(例如,“KEGG Pathways”、“GO Biological Process”)
  • term:术语标识符
  • description:易于理解的术语描述
  • number_of_genes:具有此注释的输入蛋白质数量
  • p_value:未校正的富集 p 值
  • fdr:错误发现率(校正后的 p 值)

统计方法:Fisher 精确检验,并使用 Benjamini-Hochberg 方法校正 FDR。

结果解读:FDR < 0.05 表示富集具有统计显著性。

6. PPI 富集(string_ppi_enrichment)

检验蛋白质网络中的相互作用是否显著多于随机情况下的预期值。

适用场景:验证蛋白质是否构成功能模块、检验网络连通性。

用法:

from scripts.string_api import string_ppi_enrichment
import json

# Test network connectivity
proteins = ['TP53', 'MDM2', 'ATM', 'CHEK2', 'BRCA1']
result = string_ppi_enrichment(proteins, species=9606, required_score=400)

# Parse JSON result
data = json.loads(result)
print(f"Observed edges: {data['number_of_edges']}")
print(f"Expected edges: {data['expected_number_of_edges']}")
print(f"P-value: {data['p_value']}")

输出字段:

  • number_of_nodes:网络中的蛋白质数量
  • number_of_edges:观察到的相互作用数量
  • expected_number_of_edges:随机网络中的预期相互作用数量
  • p_value:统计显著性

结果解读:

  • p 值 < 0.05:网络富集具有显著性(蛋白质可能构成功能模块)
  • p 值 ≥ 0.05:富集不显著(蛋白质之间可能无关)
7. 同源性评分(string_homology)

获取蛋白质相似性和同源性信息。

适用场景:识别蛋白质家族、分析旁系同源物、进行跨物种比较。

用法:

from scripts.string_api import string_homology

# Get homology between proteins
proteins = ['TP53', 'TP63', 'TP73']  # p53 family
homology = string_homology(proteins, species=9606)

适用场景:

  • 蛋白质家族识别
  • 旁系同源物发现
  • 演化分析
8. 版本信息(string_version)

获取当前 STRING 数据库版本。

适用场景:确保结果可复现、记录方法。

用法:

from scripts.string_api import string_version

version = string_version()
print(f"STRING version: {version}")

常见分析工作流

工作流 1:蛋白质列表分析(标准工作流)

适用场景:分析实验所得的蛋白质列表(例如,差异表达分析、蛋白质组学)。

from scripts.string_api import (string_map_ids, string_network,
                                string_enrichment, string_ppi_enrichment,
                                string_network_image)

# Step 1: Map gene names to STRING IDs
gene_list = ['TP53', 'BRCA1', 'ATM', 'CHEK2', 'MDM2', 'ATR', 'BRCA2']
mapping = string_map_ids(gene_list, species=9606)

# Step 2: Get interaction network
network = string_network(gene_list, species=9606, required_score=400)

# Step 3: Test if network is enriched
ppi_result = string_ppi_enrichment(gene_list, species=9606)

# Step 4: Perform functional enrichment
enrichment = string_enrichment(gene_list, species=9606)

# Step 5: Generate network visualization
img = string_network_image(gene_list, species=9606,
                          network_flavor='evidence', required_score=400)
with open('protein_network.png', 'wb') as f:
    f.write(img)

# Step 6: Parse and interpret results
工作流 2:单个蛋白质研究

适用场景:深入研究一种蛋白质的相互作用及其互作伙伴。

from scripts.string_api import (string_map_ids, string_interaction_partners,
                                string_network_image)

# Step 1: Map protein name
protein = 'TP53'
mapping = string_map_ids(protein, species=9606)

# Step 2: Get all interaction partners
partners = string_interaction_partners(protein, species=9606,
                                      limit=20, required_score=700)

# Step 3: Visualize expanded network
img = string_network_image(protein, species=9606, add_nodes=15,
                          network_flavor='confidence', required_score=700)
with open('tp53_network.png', 'wb') as f:
    f.write(img)
工作流 3:以通路为中心的分析

适用场景:识别并可视化特定生物通路中的蛋白质。

from scripts.string_api import string_enrichment, string_network

# Step 1: Start with known pathway proteins
dna_repair_proteins = ['TP53', 'ATM', 'ATR', 'CHEK1', 'CHEK2',
                       'BRCA1', 'BRCA2', 'RAD51', 'XRCC1']

# Step 2: Get network
network = string_network(dna_repair_proteins, species=9606,
                        required_score=700, add_nodes=5)

# Step 3: Enrichment to confirm pathway annotation
enrichment = string_enrichment(dna_repair_proteins, species=9606)

# Step 4: Parse enrichment for DNA repair pathways
import pandas as pd
import io
df = pd.read_csv(io.StringIO(enrichment), sep='\t')
dna_repair = df[df['description'].str.contains('DNA repair', case=False)]
工作流 4:跨物种分析

适用场景:比较不同生物体中的蛋白质相互作用。

from scripts.string_api import string_network

# Human network
human_network = string_network('TP53', species=9606, required_score=700)

# Mouse network
mouse_network = string_network('Trp53', species=10090, required_score=700)

# Yeast network (if ortholog exists)
yeast_network = string_network('gene_name', species=4932, required_score=700)
工作流 5:网络扩展与发现

适用场景:从种子蛋白质出发,发现相关的功能模块。

from scripts.string_api import (string_interaction_partners, string_network,
                                string_enrichment)

# Step 1: Start with seed protein(s)
seed_proteins = ['TP53']

# Step 2: Get first-degree interactors
partners = string_interaction_partners(seed_proteins, species=9606,
                                      limit=30, required_score=700)

# Step 3: Parse partners to get protein list
import pandas as pd
import io
df = pd.read_csv(io.StringIO(partners), sep='\t')
all_proteins = list(set(df['preferredName_A'].tolist() +
                       df['preferredName_B'].tolist()))

# Step 4: Perform enrichment on expanded network
enrichment = string_enrichment(all_proteins[:50], species=9606)

# Step 5: Filter for interesting functional modules
enrichment_df = pd.read_csv(io.StringIO(enrichment), sep='\t')
modules = enrichment_df[enrichment_df['fdr'] < 0.001]

常见物种

指定物种时,请使用 NCBI 分类群 ID:

生物体常用名分类群 ID
Homo sapiens人9606
Mus musculus小鼠10090
Rattus norvegicus大鼠10116
Drosophila melanogaster果蝇7227
Caenorhabditis elegans秀丽隐杆线虫6239
Saccharomyces cerevisiae酵母4932
Arabidopsis thaliana拟南芥3702
Escherichia coli大肠杆菌511145
Danio rerio斑马鱼7955

完整列表请访问:https://string-db.org/cgi/input?input_page_active_form=organisms

了解置信度评分

STRING 提供综合置信度评分(0-1000),整合了多种证据类型:

证据渠道
  1. Neighborhood(nscore):跨物种保守的基因组邻域
  2. Fusion(fscore):基因融合事件
  3. Phylogenetic Profile(pscore):跨物种共现模式
  4. Coexpression(ascore):相关的 RNA 表达
  5. Experimental(escore):生化和遗传实验
  6. Database(dscore):人工整理的通路和复合物数据库
  7. Text-mining(tscore):文献共现和 NLP 提取
推荐阈值

根据分析目标选择阈值:

  • 150(低置信度):探索性分析、生成假设
  • 400(中等置信度):标准分析,在敏感度和特异度之间取得平衡
  • 700(高置信度):保守分析,筛选高置信度的相互作用
  • 900(最高置信度):非常严格,优先考虑实验性证据

权衡:

  • 较低的阈值:相互作用更多(召回率更高,假阳性更多)
  • 较高的阈值:相互作用更少(精确率更高,假阴性更多)

网络类型

功能网络(默认)

包含所有类型的证据(实验、计算、文本挖掘)。表示在功能上存在关联的蛋白质,即使它们之间没有直接的物理结合。

适用场景:

  • 通路分析
  • 功能富集研究
  • 系统生物学
  • 大多数常规分析
物理网络

仅包含直接物理结合的证据(物理相互作用的实验数据和数据库注释)。

适用场景:

  • 结构生物学研究
  • 蛋白质复合物分析
  • 直接结合验证
  • 需要物理接触的场景

API 最佳实践

  1. 始终先映射标识符:在其他操作前使用 string_map_ids(),以加快查询速度
  2. 尽可能使用 STRING ID:使用格式 9606.ENSP00000269305,而不是基因名称
  3. 网络包含超过 10 个蛋白质时指定物种:这是获得准确结果的必要条件
  4. 遵守速率限制:API 调用之间等待 1 秒
  5. 使用带版本号的 URL 以确保可复现性:可在参考文档中找到
  6. 妥善处理错误:检查返回字符串是否以 "Error:" 开头
  7. 选择合适的置信度阈值:根据分析目标选择阈值

详细参考

如需完整的 API 文档、完整参数列表、输出格式和高级用法,请参阅 references/string_reference.md。其中包括:

  • 完整的 API 端点规范
  • 所有支持的输出格式(TSV、JSON、XML、PSI-MI)
  • 高级功能(批量上传、values/ranks 富集)
  • 错误处理和故障排除
  • 与其他工具的集成(Cytoscape、R、Python 库)
  • 数据许可和引用信息

故障排除

未找到蛋白质:

  • 确认物种参数与标识符匹配
  • 先使用 string_map_ids() 尝试映射标识符
  • 检查蛋白质名称是否有拼写错误

网络结果为空:

  • 降低置信度阈值(required_score)
  • 检查蛋白质之间是否确实存在相互作用
  • 确认物种是否正确

查询超时或速度缓慢:

  • 减少输入蛋白质的数量
  • 使用 STRING ID,而不是基因名称
  • 将大型查询拆分为多个批次

“Species required” 错误:

  • 网络包含超过 10 个蛋白质时添加 species 参数
  • 为保持一致性,始终包含物种信息

结果看起来不符合预期:

  • 使用 string_version() 检查 STRING 版本
  • 确认 network_type 是否合适(功能或物理)
  • 重新检查置信度阈值的选择

其他资源

如需进行蛋白质组规模分析或上传完整物种网络:

  • 访问 https://string-db.org
  • 使用“Upload proteome”功能
  • STRING 将生成完整的相互作用网络并预测功能

如需批量下载完整数据集:

数据许可

STRING 数据可依据 Creative Commons BY 4.0 许可免费使用:

  • 可免费用于学术和商业用途
  • 发布时必须注明出处
  • 引用 STRING 的最新出版物

引用

在出版物中使用 STRING 时,请引用以下页面中的最新出版物:https://string-db.org/cgi/about

评论

支持 Markdown