mcpField
S
string-database-ppi

string-database-ppi

github.com/jaechang-hitsデータ・データベース38477 回インストール6 日前に更新
リポジトリ

string-database-ppi について

string-database-ppiは、REST API経由でSTRINGタンパク質間相互作用データベースを照会するスキルです。タンパク質ネットワーク、機能エンリッチメント、相互作用相手、種をまたぐ相同性を分析する研究者向けです。

主な機能

  1. 01遺伝子名をSTRING IDに対応付け
  2. 02機能ネットワークまたは物理ネットワークの取得
  3. 03相互作用相手の検索とネットワーク拡張
  4. 04GO、KEGGなどのエンリッチメント解析
  5. 05PPIエンリッチメント検定と相同性取得

活用シーン

  1. 01タンパク質リストから相互作用ネットワークを作成
  2. 02タンパク質集合の機能エンリッチメントを特定
  3. 03シードタンパク質からネットワークを拡張
  4. 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 elegansC. elegans6239
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_scorenetwork, partners, ppi_enrichment400信頼度のしきい値(0~1000)
network_typenetworkfunctionalfunctional(すべてのエビデンス)または physical(直接結合)
add_nodesnetwork, image0追加で含める接続タンパク質の数(0~10)
limitget_string_ids, partners1/10クエリあたりの最大結果数
network_flavorimageevidenceevidence、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 への代替アクセス

参考資料

同梱リソース

メインの 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 行)。

コメント