Download mcp/gene_hub.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 837 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/7186f2cee4b0cd1ff11b5142acc03f7578ddcbc4/mcp/gene_hub.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@7186f2cee4b0cd1ff11b5142acc03f7578ddcbc4/mcp/gene_hub.py
-
curl -L -o gene_hub.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/7186f2cee4b0cd1ff11b5142acc03f7578ddcbc4/mcp/gene_hub.py
837 Bytes
| """ | |
| gene_hub β resolve_gene() tries three sources in order of speed & richness. | |
| 1. MyGene.info (v3) β 500 QPS key tier :contentReference[oaicite:3]{index=3} | |
| 2. Ensembl REST β key-less, species-agnostic :contentReference[oaicite:4]{index=4} | |
| 3. Open Targets GQL β tractability & constraint :contentReference[oaicite:5]{index=5} | |
| """ | |
| from mcp.mygene import fetch_gene_info | |
| from mcp.ensembl import fetch_ensembl | |
| from mcp.opentargets import fetch_ot | |
| async def resolve_gene(symbol: str) -> dict: | |
| """Return first non-empty gene record; never raises.""" | |
| for fn in (fetch_gene_info, fetch_ensembl, fetch_ot): | |
| try: | |
| data = await fn(symbol) | |
| if data: | |
| return data | |
| except Exception: # network hiccup / 429 etc. | |
| pass | |
| return {} | |