mgbam commited on
Commit
12a672d
·
verified ·
1 Parent(s): e83c230

Create multi_enrich.py

Browse files
Files changed (1) hide show
  1. mcp/multi_enrich.py +23 -0
mcp/multi_enrich.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Convenience orchestrator that fans‑out to MyGene, CT.gov v2, and Open Targets.
2
+ Used by downstream modules when they need a single call for full enrichment.
3
+ """
4
+
5
+ import asyncio
6
+ from typing import Dict, Any, List
7
+
8
+ from mcp.mygene import fetch_gene_info
9
+ from mcp.ctgov import search_trials_v2
10
+ from mcp.targets import fetch_ot_associations
11
+
12
+ async def enrich(query: str, keywords: List[str]) -> Dict[str, Any]:
13
+ gene_task = asyncio.create_task(fetch_gene_info(query))
14
+ trials_task = asyncio.create_task(search_trials_v2(query))
15
+
16
+ # Use first keyword for Open Targets association if plausible gene symbol
17
+ ot_task = asyncio.create_task(fetch_ot_associations(keywords[0])) if keywords else None
18
+
19
+ gene = await gene_task
20
+ trials = await trials_task
21
+ ot = await ot_task if ot_task else []
22
+
23
+ return {"gene": gene, "clinical_trials": trials, "ot_associations": ot}