@nahisaho/satori 0.18.0 → 0.19.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,280 @@
1
+ ---
2
+ name: scientific-rcsb-pdb-search
3
+ description: |
4
+ RCSB PDB 構造検索スキル。RCSB PDB Search API および
5
+ Data API によるタンパク質立体構造検索・メタデータ取得・
6
+ リガンド情報・解像度フィルタリング。ToolUniverse 連携:
7
+ rcsb_pdb, rcsb_search。
8
+ tu_tools:
9
+ - key: rcsb_pdb
10
+ name: RCSB PDB Data
11
+ description: PDB エントリデータ取得・構造メタデータ
12
+ - key: rcsb_search
13
+ name: RCSB PDB Search
14
+ description: PDB 構造検索・テキスト/配列/構造類似検索
15
+ ---
16
+
17
+ # Scientific RCSB PDB Search
18
+
19
+ RCSB PDB Search API および Data API を活用したタンパク質立体構造
20
+ 検索・メタデータ取得・リガンド情報パイプラインを提供する。
21
+
22
+ ## When to Use
23
+
24
+ - PDB のタンパク質立体構造をテキスト検索するとき
25
+ - 解像度・実験手法でフィルタリングするとき
26
+ - リガンド結合構造を検索するとき
27
+ - 構造のメタデータ (著者・引用・解像度) を取得するとき
28
+ - 配列類似性で構造を検索するとき
29
+ - PDB エントリからリガンド・結合サイト情報を取得するとき
30
+
31
+ ---
32
+
33
+ ## Quick Start
34
+
35
+ ## 1. テキスト検索・構造メタデータ
36
+
37
+ ```python
38
+ import requests
39
+ import pandas as pd
40
+
41
+ RCSB_SEARCH = "https://search.rcsb.org/rcsbsearch/v2/query"
42
+ RCSB_DATA = "https://data.rcsb.org/rest/v1/core"
43
+
44
+
45
+ def rcsb_text_search(query, method=None,
46
+ resolution_max=None, limit=50):
47
+ """
48
+ RCSB PDB — テキスト検索。
49
+
50
+ Parameters:
51
+ query: str — 検索クエリ (例: "BRCA1", "kinase")
52
+ method: str — 実験手法フィルタ
53
+ (例: "X-RAY DIFFRACTION", "ELECTRON MICROSCOPY")
54
+ resolution_max: float — 最大解像度 (Å)
55
+ limit: int — 最大結果数
56
+ """
57
+ search_query = {
58
+ "query": {
59
+ "type": "group",
60
+ "logical_operator": "and",
61
+ "nodes": [
62
+ {
63
+ "type": "terminal",
64
+ "service": "full_text",
65
+ "parameters": {"value": query},
66
+ }
67
+ ],
68
+ },
69
+ "return_type": "entry",
70
+ "request_options": {
71
+ "paginate": {"start": 0, "rows": limit},
72
+ "sort": [{"sort_by": "score", "direction": "desc"}],
73
+ },
74
+ }
75
+
76
+ if method:
77
+ search_query["query"]["nodes"].append({
78
+ "type": "terminal",
79
+ "service": "text",
80
+ "parameters": {
81
+ "attribute": "exptl.method",
82
+ "operator": "exact_match",
83
+ "value": method,
84
+ },
85
+ })
86
+
87
+ if resolution_max:
88
+ search_query["query"]["nodes"].append({
89
+ "type": "terminal",
90
+ "service": "text",
91
+ "parameters": {
92
+ "attribute": "rcsb_entry_info."
93
+ "resolution_combined",
94
+ "operator": "less_or_equal",
95
+ "value": resolution_max,
96
+ },
97
+ })
98
+
99
+ resp = requests.post(RCSB_SEARCH, json=search_query,
100
+ timeout=30)
101
+ resp.raise_for_status()
102
+ data = resp.json()
103
+
104
+ pdb_ids = [r["identifier"]
105
+ for r in data.get("result_set", [])]
106
+ total = data.get("total_count", 0)
107
+ print(f"RCSB PDB search: {len(pdb_ids)}/{total} "
108
+ f"(query='{query}')")
109
+ return pdb_ids
110
+
111
+
112
+ def rcsb_get_entry(pdb_id):
113
+ """
114
+ RCSB PDB — エントリメタデータ取得。
115
+
116
+ Parameters:
117
+ pdb_id: str — PDB ID (例: "1BRS", "7S4O")
118
+ """
119
+ url = f"{RCSB_DATA}/entry/{pdb_id}"
120
+ resp = requests.get(url, timeout=30)
121
+ resp.raise_for_status()
122
+ data = resp.json()
123
+
124
+ info = data.get("rcsb_entry_info", {})
125
+ citation = (data.get("rcsb_primary_citation") or {})
126
+
127
+ result = {
128
+ "pdb_id": pdb_id,
129
+ "title": data.get("struct", {}).get("title", ""),
130
+ "method": info.get("experimental_method", ""),
131
+ "resolution": info.get("resolution_combined", [None])[0],
132
+ "deposition_date": info.get("deposition_date", ""),
133
+ "polymer_count": info.get(
134
+ "deposited_polymer_entity_count", 0),
135
+ "nonpolymer_count": info.get(
136
+ "deposited_nonpolymer_entity_count", 0),
137
+ "citation_title": citation.get("title", ""),
138
+ "citation_doi": citation.get(
139
+ "pdbx_database_id_doi", ""),
140
+ }
141
+ return result
142
+ ```
143
+
144
+ ## 2. 構造バッチ取得・比較
145
+
146
+ ```python
147
+ def rcsb_batch_metadata(pdb_ids):
148
+ """
149
+ RCSB PDB — バッチメタデータ取得。
150
+
151
+ Parameters:
152
+ pdb_ids: list[str] — PDB ID リスト
153
+ """
154
+ results = []
155
+ for pid in pdb_ids:
156
+ try:
157
+ meta = rcsb_get_entry(pid)
158
+ results.append(meta)
159
+ except Exception as e:
160
+ print(f" Warning: {pid} — {e}")
161
+ continue
162
+
163
+ df = pd.DataFrame(results)
164
+ if not df.empty:
165
+ df = df.sort_values("resolution")
166
+ print(f"RCSB batch: {len(df)} entries")
167
+ return df
168
+ ```
169
+
170
+ ## 3. リガンド・結合サイト情報
171
+
172
+ ```python
173
+ def rcsb_get_ligands(pdb_id):
174
+ """
175
+ RCSB PDB — リガンド情報取得。
176
+
177
+ Parameters:
178
+ pdb_id: str — PDB ID
179
+ """
180
+ url = (f"https://data.rcsb.org/rest/v1/core/"
181
+ f"nonpolymer_entity/{pdb_id}")
182
+ # まずエントリのnonpolymerエンティティを取得
183
+ entry = rcsb_get_entry(pdb_id)
184
+ n_ligands = entry.get("nonpolymer_count", 0)
185
+
186
+ ligands = []
187
+ for i in range(1, n_ligands + 1):
188
+ try:
189
+ lig_url = (f"https://data.rcsb.org/rest/v1/core/"
190
+ f"nonpolymer_entity/{pdb_id}/{i}")
191
+ r = requests.get(lig_url, timeout=15)
192
+ if r.status_code == 200:
193
+ ld = r.json()
194
+ comp_id = ld.get(
195
+ "pdbx_entity_nonpoly", {}).get(
196
+ "comp_id", "")
197
+ ligands.append({
198
+ "pdb_id": pdb_id,
199
+ "entity_id": i,
200
+ "comp_id": comp_id,
201
+ "name": ld.get(
202
+ "rcsb_nonpolymer_entity", {}).get(
203
+ "pdbx_description", ""),
204
+ "formula": ld.get(
205
+ "rcsb_nonpolymer_entity", {}).get(
206
+ "formula_weight", ""),
207
+ })
208
+ except Exception:
209
+ continue
210
+
211
+ df = pd.DataFrame(ligands)
212
+ print(f"RCSB ligands: {pdb_id} → {len(df)} ligands")
213
+ return df
214
+ ```
215
+
216
+ ## 4. RCSB PDB 統合パイプライン
217
+
218
+ ```python
219
+ def rcsb_pipeline(query, resolution_max=3.0,
220
+ output_dir="results"):
221
+ """
222
+ RCSB PDB 統合パイプライン。
223
+
224
+ Parameters:
225
+ query: str — 検索クエリ
226
+ resolution_max: float — 最大解像度
227
+ output_dir: str — 出力ディレクトリ
228
+ """
229
+ from pathlib import Path
230
+ output_dir = Path(output_dir)
231
+ output_dir.mkdir(parents=True, exist_ok=True)
232
+
233
+ # 1) テキスト検索
234
+ pdb_ids = rcsb_text_search(
235
+ query, resolution_max=resolution_max)
236
+
237
+ # 2) バッチメタデータ
238
+ metadata = rcsb_batch_metadata(pdb_ids[:20])
239
+ metadata.to_csv(output_dir / "pdb_entries.csv",
240
+ index=False)
241
+
242
+ # 3) トップ構造のリガンド
243
+ if not metadata.empty:
244
+ top = metadata.iloc[0]["pdb_id"]
245
+ ligands = rcsb_get_ligands(top)
246
+ ligands.to_csv(output_dir / "ligands.csv",
247
+ index=False)
248
+
249
+ print(f"RCSB pipeline: {output_dir}")
250
+ return {"entries": metadata}
251
+ ```
252
+
253
+ ---
254
+
255
+ ## ToolUniverse 連携
256
+
257
+ | TU Key | ツール名 | 連携内容 |
258
+ |--------|---------|---------|
259
+ | `rcsb_pdb` | RCSB PDB Data | エントリデータ・構造メタデータ |
260
+ | `rcsb_search` | RCSB PDB Search | テキスト/配列/構造類似検索 |
261
+
262
+ ## パイプライン統合
263
+
264
+ ```
265
+ protein-structure-analysis → rcsb-pdb-search → molecular-docking
266
+ (PDB/AlphaFold 構造) (RCSB Search API) (Vina/DiffDock)
267
+ │ │ ↓
268
+ uniprot-proteome ──────────────┘ drug-target-profiling
269
+ (UniProt配列) │ (標的プロファイリング)
270
+
271
+ alphafold-structures
272
+ (AlphaFold DB)
273
+ ```
274
+
275
+ ## パイプライン出力
276
+
277
+ | ファイル | 説明 | 次スキル |
278
+ |---------|------|---------|
279
+ | `results/pdb_entries.csv` | 構造メタデータ | → protein-structure-analysis |
280
+ | `results/ligands.csv` | リガンド情報 | → molecular-docking |
@@ -0,0 +1,242 @@
1
+ ---
2
+ name: scientific-reactome-pathways
3
+ description: |
4
+ Reactome パスウェイスキル。Reactome Content Service
5
+ REST API によるパスウェイ検索・階層取得・UniProt マッピング・
6
+ パスウェイ図データ取得。ToolUniverse 連携: reactome。
7
+ tu_tools:
8
+ - key: reactome
9
+ name: Reactome
10
+ description: パスウェイデータベース REST API
11
+ ---
12
+
13
+ # Scientific Reactome Pathways
14
+
15
+ Reactome Content Service REST API を活用したパスウェイ検索・
16
+ 階層構造取得・UniProt アクセッション→パスウェイマッピング・
17
+ パスウェイ図データ取得パイプラインを提供する。
18
+
19
+ ## When to Use
20
+
21
+ - 生物学パスウェイを名前やキーワードで検索するとき
22
+ - パスウェイ階層ツリーを取得するとき
23
+ - UniProt アクセッションからパスウェイをマッピングするとき
24
+ - パスウェイの参加者 (タンパク質/化合物) を列挙するとき
25
+ - パスウェイ図のレイアウトデータを取得するとき
26
+
27
+ ---
28
+
29
+ ## Quick Start
30
+
31
+ ## 1. パスウェイ検索・詳細取得
32
+
33
+ ```python
34
+ import requests
35
+ import pandas as pd
36
+
37
+ REACTOME = "https://reactome.org/ContentService"
38
+
39
+
40
+ def reactome_search(query, species="Homo sapiens",
41
+ limit=25):
42
+ """
43
+ Reactome — パスウェイ検索。
44
+
45
+ Parameters:
46
+ query: str — 検索クエリ (例: "apoptosis", "MAPK")
47
+ species: str — 種名 (例: "Homo sapiens")
48
+ limit: int — 最大結果数
49
+ """
50
+ url = f"{REACTOME}/search/query"
51
+ params = {
52
+ "query": query,
53
+ "species": species,
54
+ "types": "Pathway",
55
+ "cluster": "true",
56
+ }
57
+ resp = requests.get(url, params=params, timeout=30)
58
+ resp.raise_for_status()
59
+ data = resp.json()
60
+
61
+ rows = []
62
+ for group in data.get("results", []):
63
+ for entry in group.get("entries", [])[:limit]:
64
+ rows.append({
65
+ "stId": entry.get("stId", ""),
66
+ "name": entry.get("name", ""),
67
+ "species": entry.get("species", ""),
68
+ "exact_type": entry.get(
69
+ "exactType", ""),
70
+ "compartments": "; ".join(
71
+ entry.get("compartmentNames", [])),
72
+ })
73
+
74
+ df = pd.DataFrame(rows[:limit])
75
+ print(f"Reactome search: '{query}' → {len(df)} "
76
+ f"pathways")
77
+ return df
78
+
79
+
80
+ def reactome_pathway_detail(pathway_id):
81
+ """
82
+ Reactome — パスウェイ詳細取得。
83
+
84
+ Parameters:
85
+ pathway_id: str — Reactome Stable ID
86
+ (例: "R-HSA-109581")
87
+ """
88
+ url = f"{REACTOME}/data/pathway/{pathway_id}"
89
+ resp = requests.get(url, timeout=30)
90
+ resp.raise_for_status()
91
+ data = resp.json()
92
+
93
+ result = {
94
+ "stId": data.get("stId", ""),
95
+ "name": data.get("displayName", ""),
96
+ "species": data.get("speciesName", ""),
97
+ "is_inferred": data.get("isInferred", False),
98
+ "has_diagram": data.get("hasDiagram", False),
99
+ "n_sub_events": len(
100
+ data.get("hasEvent", [])),
101
+ "n_compartments": len(
102
+ data.get("compartment", [])),
103
+ "release_date": data.get("releaseDate", ""),
104
+ }
105
+ return result
106
+ ```
107
+
108
+ ## 2. UniProt→パスウェイ マッピング
109
+
110
+ ```python
111
+ def reactome_uniprot_pathways(uniprot_id,
112
+ species="Homo sapiens"):
113
+ """
114
+ Reactome — UniProt → パスウェイマッピング。
115
+
116
+ Parameters:
117
+ uniprot_id: str — UniProt アクセッション
118
+ (例: "P38398" = BRCA1)
119
+ species: str — 種名
120
+ """
121
+ url = f"{REACTOME}/data/pathways/low/entity/{uniprot_id}"
122
+ params = {"species": species}
123
+ resp = requests.get(url, params=params, timeout=30)
124
+ resp.raise_for_status()
125
+ data = resp.json()
126
+
127
+ rows = []
128
+ for pw in data:
129
+ rows.append({
130
+ "pathway_id": pw.get("stId", ""),
131
+ "pathway_name": pw.get("displayName", ""),
132
+ "species": pw.get("speciesName", ""),
133
+ "has_diagram": pw.get("hasDiagram", False),
134
+ })
135
+
136
+ df = pd.DataFrame(rows)
137
+ print(f"Reactome UniProt→pathway: {uniprot_id} "
138
+ f"→ {len(df)} pathways")
139
+ return df
140
+ ```
141
+
142
+ ## 3. パスウェイ参加者取得
143
+
144
+ ```python
145
+ def reactome_participants(pathway_id):
146
+ """
147
+ Reactome — パスウェイ参加者一覧。
148
+
149
+ Parameters:
150
+ pathway_id: str — Reactome Stable ID
151
+ """
152
+ url = (f"{REACTOME}/data/participants/"
153
+ f"{pathway_id}")
154
+ resp = requests.get(url, timeout=30)
155
+ resp.raise_for_status()
156
+ data = resp.json()
157
+
158
+ rows = []
159
+ for item in data:
160
+ pe_name = item.get("displayName", "")
161
+ for ref in item.get("refEntities", []):
162
+ rows.append({
163
+ "pathway_id": pathway_id,
164
+ "participant": pe_name,
165
+ "db_name": ref.get("databaseName", ""),
166
+ "identifier": ref.get("identifier", ""),
167
+ "name": ref.get("displayName", ""),
168
+ })
169
+
170
+ df = pd.DataFrame(rows)
171
+ print(f"Reactome participants: {pathway_id} "
172
+ f"→ {len(df)} entities")
173
+ return df
174
+ ```
175
+
176
+ ## 4. Reactome 統合パイプライン
177
+
178
+ ```python
179
+ def reactome_pipeline(query_or_uniprot,
180
+ output_dir="results"):
181
+ """
182
+ Reactome 統合パイプライン。
183
+
184
+ Parameters:
185
+ query_or_uniprot: str — 検索クエリ or UniProt ID
186
+ output_dir: str — 出力ディレクトリ
187
+ """
188
+ from pathlib import Path
189
+ output_dir = Path(output_dir)
190
+ output_dir.mkdir(parents=True, exist_ok=True)
191
+
192
+ is_uniprot = (len(query_or_uniprot) == 6
193
+ and query_or_uniprot[0].isalpha())
194
+
195
+ if is_uniprot:
196
+ # UniProt → パスウェイ
197
+ pathways = reactome_uniprot_pathways(
198
+ query_or_uniprot)
199
+ else:
200
+ # テキスト検索
201
+ pathways = reactome_search(query_or_uniprot)
202
+
203
+ pathways.to_csv(output_dir / "reactome_pathways.csv",
204
+ index=False)
205
+
206
+ # トップパスウェイの参加者
207
+ if not pathways.empty:
208
+ top_id = (pathways.iloc[0].get("pathway_id")
209
+ or pathways.iloc[0].get("stId"))
210
+ parts = reactome_participants(top_id)
211
+ parts.to_csv(
212
+ output_dir / "reactome_participants.csv",
213
+ index=False)
214
+
215
+ print(f"Reactome pipeline: {output_dir}")
216
+ return {"pathways": pathways}
217
+ ```
218
+
219
+ ---
220
+
221
+ ## ToolUniverse 連携
222
+
223
+ | TU Key | ツール名 | 連携内容 |
224
+ |--------|---------|---------|
225
+ | `reactome` | Reactome | パスウェイデータベース REST API |
226
+
227
+ ## パイプライン統合
228
+
229
+ ```
230
+ pathway-enrichment → reactome-pathways → systems-biology
231
+ (GO/パスウェイ) (Reactome API) (ネットワーク解析)
232
+ │ │ ↓
233
+ uniprot-proteome ──────────┘ metabolomics-databases
234
+ (UniProt ID) (MetaCyc 代謝)
235
+ ```
236
+
237
+ ## パイプライン出力
238
+
239
+ | ファイル | 説明 | 次スキル |
240
+ |---------|------|---------|
241
+ | `results/reactome_pathways.csv` | パスウェイ一覧 | → pathway-enrichment |
242
+ | `results/reactome_participants.csv` | 参加者 | → protein-interaction-network |