mgbam commited on
Commit
f446b40
·
verified ·
1 Parent(s): 830595a

Create gene_hub.py

Browse files
Files changed (1) hide show
  1. mcp/gene_hub.py +18 -0
mcp/gene_hub.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Unified gene resolver: MyGene ➜ Ensembl ➜ OpenTargets"""
2
+ from mcp.mygene import fetch_gene_info # MyGene.info – 500 QPS tier :contentReference[oaicite:3]{index=3}
3
+ from mcp.ensembl import fetch_ensembl # Ensembl REST xrefs endpoint :contentReference[oaicite:4]{index=4}
4
+ from mcp.opentargets import fetch_ot # OT GraphQL v4 API :contentReference[oaicite:5]{index=5}
5
+
6
+ async def resolve_gene(symbol: str) -> dict:
7
+ """
8
+ Return the first non-empty gene record.
9
+ The order is chosen for speed & richness.
10
+ """
11
+ for fn in (fetch_gene_info, fetch_ensembl, fetch_ot):
12
+ try:
13
+ data = await fn(symbol)
14
+ if data: # truthy dict / list
15
+ return data
16
+ except Exception:
17
+ pass # mute network hiccups
18
+ return {}