mgbam commited on
Commit
4b619d6
Β·
verified Β·
1 Parent(s): 36986a7

Update mcp/gene_hub.py

Browse files
Files changed (1) hide show
  1. mcp/gene_hub.py +15 -11
mcp/gene_hub.py CHANGED
@@ -1,18 +1,22 @@
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 {}
 
1
+ """
2
+ gene_hub – resolve_gene() tries three sources in order of speed & richness.
3
+
4
+ 1. MyGene.info (v3) – 500 QPS key tier :contentReference[oaicite:3]{index=3}
5
+ 2. Ensembl REST – key-less, species-agnostic :contentReference[oaicite:4]{index=4}
6
+ 3. Open Targets GQL – tractability & constraint :contentReference[oaicite:5]{index=5}
7
+ """
8
+
9
+ from mcp.mygene import fetch_gene_info
10
+ from mcp.ensembl import fetch_ensembl
11
+ from mcp.opentargets import fetch_ot
12
 
13
  async def resolve_gene(symbol: str) -> dict:
14
+ """Return first non-empty gene record; never raises."""
 
 
 
15
  for fn in (fetch_gene_info, fetch_ensembl, fetch_ot):
16
  try:
17
  data = await fn(symbol)
18
+ if data:
19
  return data
20
+ except Exception: # network hiccup / 429 etc.
21
+ pass
22
  return {}