MCP_Res / mcp /gene_hub.py
mgbam's picture
Create gene_hub.py
f446b40 verified
Raw History Blame
842 Bytes
"""Unified gene resolver: MyGene ➜ Ensembl ➜ OpenTargets"""
from mcp.mygene import fetch_gene_info # MyGene.info – 500 QPS tier :contentReference[oaicite:3]{index=3}
from mcp.ensembl import fetch_ensembl # Ensembl REST xrefs endpoint :contentReference[oaicite:4]{index=4}
from mcp.opentargets import fetch_ot # OT GraphQL v4 API :contentReference[oaicite:5]{index=5}
async def resolve_gene(symbol: str) -> dict:
"""
Return the first non-empty gene record.
The order is chosen for speed & richness.
"""
for fn in (fetch_gene_info, fetch_ensembl, fetch_ot):
try:
data = await fn(symbol)
if data: # truthy dict / list
return data
except Exception:
pass # mute network hiccups
return {}