Download mcp/gene_hub.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 842 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/874a822366181ef5fee5870fc63da0cd490d39d3/mcp/gene_hub.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@874a822366181ef5fee5870fc63da0cd490d39d3/mcp/gene_hub.py
-
curl -L -o gene_hub.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/874a822366181ef5fee5870fc63da0cd490d39d3/mcp/gene_hub.py
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 {} | |