@nahisaho/satori 0.19.0 → 0.20.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,318 @@
1
+ ---
2
+ name: scientific-stitch-chemical-network
3
+ description: |
4
+ STITCH 化学-タンパク質相互作用ネットワークスキル。STITCH
5
+ REST API を用いた化学物質-タンパク質インタラクション検索・
6
+ 信頼度スコアリング・ネットワーク薬理学・ポリファーマコロジー解析。
7
+ ToolUniverse 連携: stitch。
8
+ tu_tools:
9
+ - key: stitch
10
+ name: STITCH
11
+ description: 化学物質-タンパク質相互作用ネットワーク (EMBL)
12
+ ---
13
+
14
+ # Scientific STITCH Chemical Network
15
+
16
+ STITCH (Search Tool for Interactions of Chemicals) REST API
17
+ を活用した化学物質-タンパク質相互作用検索・信頼度スコアリング・
18
+ ネットワーク薬理学・ポリファーマコロジー解析パイプラインを提供する。
19
+
20
+ ## When to Use
21
+
22
+ - 化学物質とタンパク質の相互作用エビデンスを検索するとき
23
+ - 薬物の標的タンパク質ネットワークを構築するとき
24
+ - ポリファーマコロジー (多標的薬理作用) を解析するとき
25
+ - 化学物質間の類似ネットワークを構築するとき
26
+ - ネットワーク薬理学 (Network Pharmacology) を実施するとき
27
+
28
+ ---
29
+
30
+ ## Quick Start
31
+
32
+ ## 1. 化学物質-タンパク質相互作用検索
33
+
34
+ ```python
35
+ import requests
36
+ import pandas as pd
37
+
38
+ STITCH_API = "http://stitch.embl.de/api"
39
+
40
+
41
+ def stitch_interactions(chemical, species=9606,
42
+ required_score=400, limit=50):
43
+ """
44
+ STITCH — 化学物質-タンパク質相互作用検索。
45
+
46
+ Parameters:
47
+ chemical: str — 化学物質名または CID
48
+ (例: "aspirin", "CIDm00002244")
49
+ species: int — NCBI Taxonomy ID
50
+ (9606=ヒト)
51
+ required_score: int — 最低信頼度スコア
52
+ (0-1000, 400=medium)
53
+ limit: int — 最大結果数
54
+ """
55
+ url = f"{STITCH_API}/tsv/interactionsList"
56
+ params = {
57
+ "identifiers": chemical,
58
+ "species": species,
59
+ "required_score": required_score,
60
+ "limit": limit,
61
+ }
62
+ resp = requests.get(url, params=params, timeout=30)
63
+ resp.raise_for_status()
64
+
65
+ lines = resp.text.strip().split("\n")
66
+ if len(lines) < 2:
67
+ return pd.DataFrame()
68
+
69
+ header = lines[0].split("\t")
70
+ rows = [line.split("\t") for line in lines[1:]]
71
+ df = pd.DataFrame(rows, columns=header)
72
+
73
+ if "score" in df.columns:
74
+ df["score"] = pd.to_numeric(
75
+ df["score"], errors="coerce")
76
+
77
+ print(f"STITCH: {chemical} → {len(df)} interactions")
78
+ return df
79
+
80
+
81
+ def stitch_resolve(identifiers, species=9606):
82
+ """
83
+ STITCH — 化学物質/タンパク質 ID 解決。
84
+
85
+ Parameters:
86
+ identifiers: list[str] — 化学物質/タンパク質名リスト
87
+ species: int — NCBI Taxonomy ID
88
+ """
89
+ url = f"{STITCH_API}/tsv/resolveList"
90
+ params = {
91
+ "identifiers": "\r".join(identifiers),
92
+ "species": species,
93
+ }
94
+ resp = requests.get(url, params=params, timeout=30)
95
+ resp.raise_for_status()
96
+
97
+ lines = resp.text.strip().split("\n")
98
+ if len(lines) < 2:
99
+ return pd.DataFrame()
100
+
101
+ header = lines[0].split("\t")
102
+ rows = [line.split("\t") for line in lines[1:]]
103
+ df = pd.DataFrame(rows, columns=header)
104
+
105
+ print(f"STITCH resolve: {len(identifiers)} queries → "
106
+ f"{len(df)} results")
107
+ return df
108
+ ```
109
+
110
+ ## 2. ネットワーク薬理学
111
+
112
+ ```python
113
+ def stitch_network(chemicals, species=9606,
114
+ required_score=400):
115
+ """
116
+ STITCH — 多化学物質ネットワーク構築。
117
+
118
+ Parameters:
119
+ chemicals: list[str] — 化学物質名リスト
120
+ species: int — NCBI Taxonomy ID
121
+ required_score: int — 最低信頼度スコア
122
+ """
123
+ url = f"{STITCH_API}/tsv/network"
124
+ params = {
125
+ "identifiers": "\r".join(chemicals),
126
+ "species": species,
127
+ "required_score": required_score,
128
+ }
129
+ resp = requests.get(url, params=params, timeout=30)
130
+ resp.raise_for_status()
131
+
132
+ lines = resp.text.strip().split("\n")
133
+ if len(lines) < 2:
134
+ return pd.DataFrame()
135
+
136
+ header = lines[0].split("\t")
137
+ rows = [line.split("\t") for line in lines[1:]]
138
+ df = pd.DataFrame(rows, columns=header)
139
+
140
+ nodes = set()
141
+ if "stringId_A" in df.columns:
142
+ nodes.update(df["stringId_A"].unique())
143
+ if "stringId_B" in df.columns:
144
+ nodes.update(df["stringId_B"].unique())
145
+
146
+ print(f"STITCH network: {len(nodes)} nodes, "
147
+ f"{len(df)} edges")
148
+ return df
149
+
150
+
151
+ def polypharmacology_analysis(drug_list, species=9606,
152
+ required_score=700):
153
+ """
154
+ ポリファーマコロジー解析。
155
+
156
+ Parameters:
157
+ drug_list: list[str] — 薬物名リスト
158
+ species: int — NCBI Taxonomy ID
159
+ required_score: int — 高信頼度スコア閾値
160
+ """
161
+ all_targets = {}
162
+ for drug in drug_list:
163
+ interactions = stitch_interactions(
164
+ drug, species, required_score)
165
+ if interactions.empty:
166
+ continue
167
+
168
+ targets = set()
169
+ for col in ["stringId_A", "stringId_B"]:
170
+ if col in interactions.columns:
171
+ targets.update(
172
+ interactions[col].unique())
173
+ # 化学物質自身を除外
174
+ targets = {t for t in targets
175
+ if not t.startswith("CID")}
176
+ all_targets[drug] = targets
177
+
178
+ # 共通標的計算
179
+ if len(all_targets) < 2:
180
+ return pd.DataFrame()
181
+
182
+ pairs = []
183
+ drugs = list(all_targets.keys())
184
+ for i in range(len(drugs)):
185
+ for j in range(i + 1, len(drugs)):
186
+ shared = (all_targets[drugs[i]]
187
+ & all_targets[drugs[j]])
188
+ union = (all_targets[drugs[i]]
189
+ | all_targets[drugs[j]])
190
+ jaccard = (len(shared) / len(union)
191
+ if union else 0)
192
+ pairs.append({
193
+ "drug_a": drugs[i],
194
+ "drug_b": drugs[j],
195
+ "shared_targets": len(shared),
196
+ "jaccard_index": jaccard,
197
+ "shared_list": "; ".join(
198
+ sorted(shared)),
199
+ })
200
+
201
+ df = pd.DataFrame(pairs)
202
+ df.sort_values("jaccard_index", ascending=False,
203
+ inplace=True)
204
+ print(f"Polypharmacology: {len(drugs)} drugs, "
205
+ f"{len(df)} pairs")
206
+ return df
207
+ ```
208
+
209
+ ## 3. エンリッチメント解析
210
+
211
+ ```python
212
+ def stitch_enrichment(identifiers, species=9606):
213
+ """
214
+ STITCH — 機能エンリッチメント解析。
215
+
216
+ Parameters:
217
+ identifiers: list[str] — タンパク質/化学物質リスト
218
+ species: int — NCBI Taxonomy ID
219
+ """
220
+ url = f"{STITCH_API}/tsv/enrichment"
221
+ params = {
222
+ "identifiers": "\r".join(identifiers),
223
+ "species": species,
224
+ }
225
+ resp = requests.get(url, params=params, timeout=30)
226
+ resp.raise_for_status()
227
+
228
+ lines = resp.text.strip().split("\n")
229
+ if len(lines) < 2:
230
+ return pd.DataFrame()
231
+
232
+ header = lines[0].split("\t")
233
+ rows = [line.split("\t") for line in lines[1:]]
234
+ df = pd.DataFrame(rows, columns=header)
235
+
236
+ if "p_value" in df.columns:
237
+ df["p_value"] = pd.to_numeric(
238
+ df["p_value"], errors="coerce")
239
+ df.sort_values("p_value", inplace=True)
240
+
241
+ print(f"STITCH enrichment: {len(df)} terms")
242
+ return df
243
+ ```
244
+
245
+ ## 4. STITCH 統合パイプライン
246
+
247
+ ```python
248
+ def stitch_pipeline(chemicals, species=9606,
249
+ output_dir="results"):
250
+ """
251
+ STITCH 統合パイプライン。
252
+
253
+ Parameters:
254
+ chemicals: list[str] — 化学物質名リスト
255
+ species: int — NCBI Taxonomy ID
256
+ output_dir: str — 出力ディレクトリ
257
+ """
258
+ from pathlib import Path
259
+ output_dir = Path(output_dir)
260
+ output_dir.mkdir(parents=True, exist_ok=True)
261
+
262
+ # 1) 個別相互作用
263
+ all_interactions = []
264
+ for chem in chemicals:
265
+ ixns = stitch_interactions(chem, species)
266
+ ixns["query_chemical"] = chem
267
+ all_interactions.append(ixns)
268
+ ixn_df = pd.concat(all_interactions, ignore_index=True)
269
+ ixn_df.to_csv(
270
+ output_dir / "stitch_interactions.csv",
271
+ index=False)
272
+
273
+ # 2) ネットワーク
274
+ network = stitch_network(chemicals, species)
275
+ network.to_csv(
276
+ output_dir / "stitch_network.csv",
277
+ index=False)
278
+
279
+ # 3) ポリファーマコロジー
280
+ polypharm = polypharmacology_analysis(
281
+ chemicals, species)
282
+ polypharm.to_csv(
283
+ output_dir / "polypharmacology.csv",
284
+ index=False)
285
+
286
+ print(f"STITCH pipeline → {output_dir}")
287
+ return {
288
+ "interactions": ixn_df,
289
+ "network": network,
290
+ "polypharmacology": polypharm,
291
+ }
292
+ ```
293
+
294
+ ---
295
+
296
+ ## ToolUniverse 連携
297
+
298
+ | TU Key | ツール名 | 連携内容 |
299
+ |--------|---------|---------|
300
+ | `stitch` | STITCH | 化学物質-タンパク質相互作用 (EMBL) |
301
+
302
+ ## パイプライン統合
303
+
304
+ ```
305
+ cheminformatics → stitch-chemical-network → drug-target-profiling
306
+ (化合物記述子) (STITCH 相互作用) (DGIdb 標的)
307
+ │ │ ↓
308
+ string-network-api ────────┘ pharmacology-targets
309
+ (STRING PPI) (BindingDB/GtoPdb)
310
+ ```
311
+
312
+ ## パイプライン出力
313
+
314
+ | ファイル | 説明 | 次スキル |
315
+ |---------|------|---------|
316
+ | `results/stitch_interactions.csv` | 化学物質-標的 | → drug-target-profiling |
317
+ | `results/stitch_network.csv` | ネットワーク | → string-network-api |
318
+ | `results/polypharmacology.csv` | 多標的解析 | → pharmacology-targets |
@@ -4,6 +4,10 @@ description: |
4
4
  STRING/BioGRID/STITCH ネットワーク解析スキル。STRING タンパク質相互作用
5
5
  ネットワーク直接 API、BioGRID 実験的 PPI、STITCH 化学-タンパク質ネットワーク、
6
6
  ネットワークトポロジー解析・コミュニティ検出・機能濃縮統合パイプライン。
7
+ tu_tools:
8
+ - key: ppi
9
+ name: STRING/BioGRID PPI
10
+ description: タンパク質・化学物質相互作用ネットワーク
7
11
  ---
8
12
 
9
13
  # Scientific STRING Network API