mgbam commited on
Commit
563f401
·
verified ·
1 Parent(s): 3ef2946

Create ensembl.py

Browse files
Files changed (1) hide show
  1. mcp/ensembl.py +11 -0
mcp/ensembl.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### `ensembl.py` – species-agnostic xref
2
+ ```python
3
+ import httpx, asyncio
4
+ from functools import lru_cache
5
+ _URL="https://rest.ensembl.org/xrefs/symbol/homo_sapiens/{}?content-type=application/json"
6
+ @lru_cache(maxsize=512)
7
+ async def fetch_ensembl(sym:str):
8
+ async with httpx.AsyncClient(timeout=8) as c:
9
+ r=await c.get(_URL.format(sym));
10
+ return r.json()[0] if r.status_code==200 and r.json() else {}
11
+ ``` :contentReference[oaicite:8]{index=8}