Download mcp/disgenet.py from mgbam/MCP_Res: direct link, hf CLI and curl.
- Browser
- Download file 701 Bytes
-
https://huggingface.co/spaces/mgbam/MCP_Res/resolve/e173f9508a599cff8c181f2e3d684dbf0fd3529d/mcp/disgenet.py
- Command line
-
hf download hf://spaces/mgbam/MCP_Res@e173f9508a599cff8c181f2e3d684dbf0fd3529d/mcp/disgenet.py
-
curl -L -o disgenet.py https://huggingface.co/spaces/mgbam/MCP_Res/resolve/e173f9508a599cff8c181f2e3d684dbf0fd3529d/mcp/disgenet.py
701 Bytes
| # mcp/disgenet.py | |
| """ | |
| DisGeNET disease–gene associations. | |
| """ | |
| import os, httpx | |
| from typing import List, Dict | |
| DISGENET_KEY = os.getenv("DISGENET_KEY") | |
| HEADERS = {"Authorization": f"Bearer {DISGENET_KEY}"} if DISGENET_KEY else {} | |
| BASE = "https://www.disgenet.org/api" | |
| async def disease_to_genes(disease_name: str, limit: int = 10) -> List[Dict]: | |
| """ | |
| Return top gene associations for a disease. | |
| """ | |
| url = f"{BASE}/gda/disease/{disease_name.lower()}" | |
| async with httpx.AsyncClient(timeout=20, headers=HEADERS) as client: | |
| r = await client.get(url, params={"source": "ALL", "format": "json"}) | |
| r.raise_for_status() | |
| data = r.json() | |
| return data[:limit] | |