string-database-ppi について
string-database-ppiは、REST API経由でSTRINGタンパク質間相互作用データベースを照会するスキルです。タンパク質ネットワーク、機能エンリッチメント、相互作用相手、種をまたぐ相同性を分析する研究者向けです。
主な機能
- 01遺伝子名をSTRING IDに対応付け
- 02機能ネットワークまたは物理ネットワークの取得
- 03相互作用相手の検索とネットワーク拡張
- 04GO、KEGGなどのエンリッチメント解析
- 05PPIエンリッチメント検定と相同性取得
活用シーン
- 01タンパク質リストから相互作用ネットワークを作成
- 02タンパク質集合の機能エンリッチメントを特定
- 03シードタンパク質からネットワークを拡張
- 04種間でタンパク質相互作用を比較
インストール
コマンドをコピーしてターミナルで実行します。
npx skills add https:/ / github.com/ jaechang-hits/ sciagent-skills --skill string-database-ppiインストール後、Claude Code で/string-database-ppiを入力して読み込まれたか確認します。
同梱ファイルreferences/api_advanced.md
詳細
STRING Database — タンパク質間相互作用
概要
STRING タンパク質間相互作用データベース(5,900 万のタンパク質、200 億件以上の相互作用、5,000 種以上)を REST API 経由で検索します。ネットワークの取得、機能エンリッチメント(GO、KEGG、Pfam)、相互作用パートナーの探索、PPI エンリッチメント検定、ネットワークの可視化、相同性解析に対応しています。
使用する場面
- 1 つまたは複数のタンパク質について、タンパク質間相互作用ネットワークを取得する
- タンパク質リストに対して機能エンリッチメント解析(GO、KEGG、Pfam、InterPro)を実施する
- 相互作用パートナーを見つけ、シードタンパク質からタンパク質ネットワークを拡張する
- タンパク質の集合が有意にエンリッチされた機能モジュールを形成するかを検定する
- 根拠に基づく色付けでネットワークを可視化する
- 種をまたいで相同性やタンパク質ファミリーの関係を解析する
- ハブタンパク質やネットワークの接続パターンを特定する
- 化合物との相互作用には代わりに chembl-database-bioactivity を、経路中心の検索には kegg-database を使用する
前提条件
uv pip install requests pandas
レート制限:厳密なレート制限はありませんが、API 呼び出しの間隔を約 1 秒空けてください。プロテオーム規模の解析には、API の代わりに https://string-db.org/cgi/download から一括ダウンロードしてください。
クイックスタート
import requests
import time
STRING_API = "https://string-db.org/api"
def string_query(endpoint, params, fmt="tsv"):
"""Reusable helper for all STRING API calls."""
url = f"{STRING_API}/{fmt}/{endpoint}"
params.setdefault("caller_identity", "python_script")
response = requests.get(url, params=params)
response.raise_for_status()
return response.text
# Map gene names to STRING IDs (always do this first)
result = string_query("get_string_ids", {
"identifiers": "TP53\nBRCA1\nEGFR",
"species": 9606
})
print(result)
# Get interaction network
time.sleep(1)
network = string_query("network", {
"identifiers": "TP53%0dBRCA1%0dMDM2",
"species": 9606,
"required_score": 400
})
print(network[:500])
主な概念
よく使われる種の NCBI Taxon ID
| 生物種 | 一般名 | Taxon ID |
|---|---|---|
| Homo sapiens | ヒト | 9606 |
| Mus musculus | マウス | 10090 |
| Rattus norvegicus | ラット | 10116 |
| Drosophila melanogaster | ショウジョウバエ | 7227 |
| Caenorhabditis elegans | C. elegans | 6239 |
| Saccharomyces cerevisiae | 酵母 | 4932 |
| Arabidopsis thaliana | シロイヌナズナ | 3702 |
| Escherichia coli K-12 | 大腸菌 | 511145 |
| Danio rerio | ゼブラフィッシュ | 7955 |
| Gallus gallus | ニワトリ | 9031 |
全種の一覧:https://string-db.org/cgi/input?input_page_active_form=organisms
STRING 識別子の形式
STRING は、分類群の接頭辞が付いた Ensembl タンパク質 ID を使用します:{taxonId}.{ensemblProteinId}(例:ヒトの TP53 は 9606.ENSP00000269305)。後続の検索を高速化するため、まず get_string_ids で遺伝子名を STRING ID にマッピングしてください。
相互作用の信頼度スコア
7 つのエビデンスチャネルを統合した合計スコア(0~1000)です:
| チャネル | コード | 情報源 |
|---|---|---|
| 近傍 | nscore | 保存されたゲノム上の近傍関係 |
| 融合 | fscore | 遺伝子融合イベント |
| 系統プロファイル | pscore | 種をまたぐ共起 |
| 共発現 | ascore | 相関する RNA 発現 |
| 実験 | escore | 生化学・遺伝学的実験 |
| データベース | dscore | キュレーション済み経路・複合体データベース |
| テキストマイニング | tscore | 文献中の共起と NLP |
推奨しきい値:
- 150:低信頼度(探索的解析、仮説生成)
- 400:中信頼度(標準的な解析、デフォルト)
- 700:高信頼度(保守的な解析、偽陽性が少ない)
- 900:最高信頼度(非常に厳格、実験的エビデンスを優先)
ネットワークの種類
- 機能的(デフォルト):すべてのエビデンスタイプを使用します。直接結合がなくても、タンパク質同士が機能的に関連していることを示します。経路解析、エンリッチメント、システム生物学に使用します
- 物理的:直接結合のエビデンスのみを使用します。実験データとキュレーション済みの物理的相互作用が対象です。構造解析や複合体解析に使用します
出力形式
URL の /tsv/ を希望する形式に置き換えます:
- TSV:タブ区切り(デフォルト。データ処理に最適)
- JSON:構造化データ(
/json/) - PNG/SVG:ネットワーク画像(
/image/) - PSI-MI/PSI-MITAB:プロテオミクス標準形式
主要 API
1. 識別子のマッピング
# Map gene names to STRING IDs
result = string_query("get_string_ids", {
"identifiers": "TP53\nBRCA1\nEGFR",
"species": 9606,
"limit": 1, # matches per identifier
"echo_query": 1 # include query term in output
})
# Parse the mapping
import pandas as pd
import io
df = pd.read_csv(io.StringIO(result), sep='\t')
id_map = dict(zip(df['queryItem'], df['stringId']))
print(id_map)
# {'TP53': '9606.ENSP00000269305', 'BRCA1': '9606.ENSP00000...', ...}
2. ネットワークの取得
# Get PPI network with confidence scores
network = string_query("network", {
"identifiers": "TP53%0dBRCA1%0dMDM2%0dATM%0dCHEK2",
"species": 9606,
"required_score": 400,
"network_type": "functional" # or "physical"
})
# Parse network edges
time.sleep(1)
df = pd.read_csv(io.StringIO(network), sep='\t')
print(f"Found {len(df)} interactions")
print(df[['preferredName_A', 'preferredName_B', 'score']].head())
# Expand network with additional interactors
expanded = string_query("network", {
"identifiers": "TP53",
"species": 9606,
"add_nodes": 10, # add 10 most connected proteins
"required_score": 700
})
3. ネットワークの可視化
# Get PNG network image
url = f"{STRING_API}/image/network"
params = {
"identifiers": "TP53%0dMDM2%0dATM%0dCHEK2%0dBRCA1",
"species": 9606,
"required_score": 700,
"network_flavor": "evidence", # "evidence", "confidence", or "actions"
"caller_identity": "python_script"
}
response = requests.get(url, params=params)
with open("network.png", "wb") as f:
f.write(response.content)
4. 相互作用パートナー
# Discover top interaction partners
partners = string_query("interaction_partners", {
"identifiers": "TP53",
"species": 9606,
"limit": 20,
"required_score": 700
})
df = pd.read_csv(io.StringIO(partners), sep='\t')
print(f"Top 20 TP53 interactors:")
print(df[['preferredName_B', 'score']].head(10))
5. 機能エンリッチメント
# GO, KEGG, Pfam, InterPro, SMART, UniProt Keywords enrichment
# Statistical method: Fisher's exact test with Benjamini-Hochberg FDR correction
enrichment = string_query("enrichment", {
"identifiers": "TP53%0dMDM2%0dATM%0dCHEK2%0dBRCA1%0dATR%0dTP73",
"species": 9606
})
df = pd.read_csv(io.StringIO(enrichment), sep='\t')
significant = df[df['fdr'] < 0.05]
print(f"Significant terms: {len(significant)}")
# Group by annotation category
for cat, group in significant.groupby('category'):
print(f"\n{cat}: {len(group)} terms")
for _, row in group.head(3).iterrows():
print(f" {row['description']} (FDR={row['fdr']:.2e})")
6. PPI エンリッチメント検定
import json
# Test if proteins form a significant functional module
result = string_query("ppi_enrichment", {
"identifiers": "TP53%0dMDM2%0dATM%0dCHEK2%0dBRCA1",
"species": 9606,
"required_score": 400
}, fmt="json")
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']}")
# p < 0.05 → proteins form a significantly enriched network
7. 相同性スコア
# Get homology/similarity between proteins
homology = string_query("homology", {
"identifiers": "TP53%0dTP63%0dTP73",
"species": 9606
})
print(homology)
よくあるワークフロー
ワークフロー 1:タンパク質リストの解析(標準)
import requests, pandas as pd, io, json, time
STRING_API = "https://string-db.org/api"
def string_query(endpoint, params, fmt="tsv"):
url = f"{STRING_API}/{fmt}/{endpoint}"
params.setdefault("caller_identity", "python_script")
response = requests.get(url, params=params)
response.raise_for_status()
time.sleep(1)
return response.text
genes = "TP53%0dBRCA1%0dATM%0dCHEK2%0dMDM2%0dATR%0dBRCA2"
# Step 1: Map identifiers
mapping = string_query("get_string_ids", {"identifiers": genes.replace("%0d", "\n"), "species": 9606})
# Step 2: Get interaction network
network = string_query("network", {"identifiers": genes, "species": 9606, "required_score": 400})
net_df = pd.read_csv(io.StringIO(network), sep='\t')
print(f"Network: {len(net_df)} interactions")
# Step 3: Test PPI enrichment
ppi = json.loads(string_query("ppi_enrichment", {"identifiers": genes, "species": 9606}, fmt="json"))
print(f"PPI enrichment p-value: {ppi['p_value']}")
# Step 4: Functional enrichment
enrich = string_query("enrichment", {"identifiers": genes, "species": 9606})
enrich_df = pd.read_csv(io.StringIO(enrich), sep='\t')
sig = enrich_df[enrich_df['fdr'] < 0.05]
print(f"Significant GO/KEGG terms: {len(sig)}")
# Step 5: Save network image
img_resp = requests.get(f"{STRING_API}/image/network", params={
"identifiers": genes, "species": 9606, "required_score": 400,
"network_flavor": "evidence", "caller_identity": "python_script"
})
with open("protein_network.png", "wb") as f:
f.write(img_resp.content)
ワークフロー 2:シードタンパク質からのネットワーク拡張
# Start with seed proteins, discover connected functional modules
seed = "TP53"
# Step 1: Get high-confidence interaction partners
partners = string_query("interaction_partners", {
"identifiers": seed, "species": 9606, "limit": 30, "required_score": 700
})
df = pd.read_csv(io.StringIO(partners), sep='\t')
all_proteins = list(set(df['preferredName_A'].tolist() + df['preferredName_B'].tolist()))
print(f"Expanded network: {len(all_proteins)} proteins")
# Step 2: Enrichment on expanded set
expanded_ids = "%0d".join(all_proteins[:50])
enrichment = string_query("enrichment", {"identifiers": expanded_ids, "species": 9606})
enrich_df = pd.read_csv(io.StringIO(enrichment), sep='\t')
modules = enrich_df[enrich_df['fdr'] < 0.001]
print(f"Highly significant terms: {len(modules)}")
ワークフロー 3:種間比較
# Compare protein interactions across species
for species, name, gene in [(9606, "Human", "TP53"), (10090, "Mouse", "Trp53")]:
network = string_query("network", {
"identifiers": gene, "species": species,
"required_score": 700, "add_nodes": 5
})
df = pd.read_csv(io.StringIO(network), sep='\t')
print(f"{name} ({gene}): {len(df)} interactions at score >= 700")
よく使うレシピ
レシピ:エンリッチメント結果を DataFrame に解析する
import pandas as pd, io
enrichment_tsv = string_query("enrichment", {
"identifiers": "TP53%0dBRCA1%0dATM", "species": 9606
})
df = pd.read_csv(io.StringIO(enrichment_tsv), sep='\t')
# Columns: category, term, description, number_of_genes, p_value, fdr
kegg = df[df['category'] == 'KEGG'].sort_values('fdr')
print(kegg[['description', 'fdr']].head(5))
レシピ:レート制限を適用したタンパク質の一括クエリ
import time
protein_lists = [["TP53", "MDM2"], ["EGFR", "ERBB2"], ["BRCA1", "BRCA2"]]
results = []
for proteins in protein_lists:
ids = "%0d".join(proteins)
network = string_query("network", {"identifiers": ids, "species": 9606})
results.append(network)
time.sleep(1) # respect rate limits
レシピ:再現性のためのバージョン確認
version = string_query("version", {})
print(f"STRING version: {version.strip()}")
# Include in methods section: "STRING v{version}, accessed {date}"
主なパラメーター
| パラメーター | エンドポイント | デフォルト | 説明 |
|---|---|---|---|
identifiers | すべて | — | タンパク質 ID。URL では %0d 区切り、POST では \n 区切り |
species | すべて | — | NCBI 分類群 ID(9606=ヒト、10090=マウス) |
required_score | network, partners, ppi_enrichment | 400 | 信頼度のしきい値(0~1000) |
network_type | network | functional | functional(すべてのエビデンス)または physical(直接結合) |
add_nodes | network, image | 0 | 追加で含める接続タンパク質の数(0~10) |
limit | get_string_ids, partners | 1/10 | クエリあたりの最大結果数 |
network_flavor | image | evidence | evidence、confidence、または actions |
トラブルシューティング
| 問題 | 原因 | 解決策 |
|---|---|---|
| タンパク質が見つからない | 種が間違っている、または識別子の入力ミス | 種の分類群 ID を確認します。get_string_ids を使って識別子の対応を確認します |
| ネットワークが空 | 信頼度のしきい値が厳しすぎる | required_score を下げます。タンパク質が STRING 上で実際に相互作用しているか確認します |
| 大規模なクエリでタイムアウトする | 1 回のリクエストに含めるタンパク質が多すぎる | 50~100 個ずつのバッチに分割します。プロテオーム規模の場合は一括ダウンロードを使用します |
| 「Species required」エラー | 10 個を超えるタンパク質のネットワークで種が指定されていない | species パラメーターを必ず指定します |
| 予期しない結果 | ネットワークタイプまたは STRING のバージョンが間違っている | network_type(functional または physical)を確認します。/version でバージョンを確認します |
| 400 Bad Request | 識別子の形式が不正 | URL では %0d、POST 本文では \n を区切り文字として使用します。特殊文字は URL エンコードします |
| エンリッチメントで用語が返されない | 入力タンパク質が少なすぎる | 意味のある結果を得るには、エンリッチメントに 5 個以上のタンパク質が必要です |
ベストプラクティス
- 必ず最初に識別子をマッピングする — ほかの操作の前に
get_string_ids()を使います。STRING ID(例:9606.ENSP00000269305)は遺伝子名より高速です - すべてのリクエストにレート制限を適用する — API 呼び出しの間に
time.sleep(1)を追加します - 適切なしきい値を選択する — 探索的解析には 400、論文には 700、高信頼度の結果だけを得るには 900 を使用します
- 種を明示的に指定する — 10 個を超えるタンパク質のネットワークでは必須であり、常に指定することを推奨します
- 経路解析とエンリッチメントには機能ネットワークを、構造生物学と直接結合の解析には物理ネットワークを使用します
- 手法の説明にバージョンを含める — 再現性のために
string_version()を確認します
関連スキル
networkx-graph-analysis— STRING 相互作用ネットワークのグラフ解析と可視化kegg-database— STRING エンリッチメントを補完する経路中心のクエリbioservices-multi-database— PSICQUIC インターフェースを介した STRING への代替アクセス
参考資料
- STRING のウェブサイト:https://string-db.org
- API ドキュメント:https://string-db.org/help/api/
- ダウンロードページ:https://string-db.org/cgi/download
- 論文:https://string-db.org/cgi/about
同梱リソース
メインの SKILL.md + 参照ファイル 1 件。元の合計:990 行(SKILL.md 534 行 + string_reference.md 456 行)。スクリプト:370 行(string_api.py)。
references/api_advanced.md:高度な API 機能(values/ranks による拡充、一括アップロード、R/Cytoscape との統合)、出力形式の詳細、HTTP エラーコード、データライセンス — Core API の範囲を超える元の string_reference.md の内容です。
元ファイルの扱い:
SKILL.md(534 行)→ Core API モジュール 1~7、ワークフロー 1~3、クイックスタートのヘルパー関数、主要な概念(種の表、スコアのしきい値、ネットワークの種類)。「一般的なユースケース」の操作ごとのサブセクションは、Core API モジュールの説明に統合(ルール 7b):各操作の「使用する場面」と「ユースケース」→ Core API の導入文。「詳細リファレンス」の仮セクション → 削除し、内容をインラインに統合references/string_reference.md(456 行)→ 一部をインラインに統合:API エンドポイント → コードブロックとともに Core API モジュールへ、種の表 → 主要な概念へ、信頼度スコア → 主要な概念へ、識別子の形式 → 主要な概念へ。高度な機能(values/ranks による拡充、一括アップロード)、統合例(R STRINGdb、Cytoscape)、出力形式の詳細、HTTP エラーコード、データライセンス →references/api_advanced.mdに移行scripts/string_api.py(370 行)→ ヘルパー関数のパターンをクイックスタートの再利用可能なstring_query関数に取り込み。関数ごとの扱い:string_map_ids→ Core API モジュール 1、string_network→ モジュール 2、string_network_image→ モジュール 3、string_interaction_partners→ モジュール 4、string_enrichment→ モジュール 5、string_ppi_enrichment→ モジュール 6、string_homology→ モジュール 7、string_version→ レシピ。いずれも urllib を使用する薄いラッパーでしたが、requests ベースのstring_queryヘルパーに置き換えました
保持率:約 460 行(SKILL.md)+約 180 行(参照)=元の 990 行の約 65%(約 640 行)。