mgbam commited on
Commit
3925910
·
verified ·
1 Parent(s): 758d4b9

Create disgenet.py

Browse files
Files changed (1) hide show
  1. mcp/disgenet.py +23 -0
mcp/disgenet.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # mcp/disgenet.py
2
+ """
3
+ DisGeNET disease–gene associations.
4
+ """
5
+
6
+ import os, httpx
7
+ from typing import List, Dict
8
+
9
+ DISGENET_KEY = os.getenv("DISGENET_KEY")
10
+ HEADERS = {"Authorization": f"Bearer {DISGENET_KEY}"} if DISGENET_KEY else {}
11
+
12
+ BASE = "https://www.disgenet.org/api"
13
+
14
+ async def disease_to_genes(disease_name: str, limit: int = 10) -> List[Dict]:
15
+ """
16
+ Return top gene associations for a disease.
17
+ """
18
+ url = f"{BASE}/gda/disease/{disease_name.lower()}"
19
+ async with httpx.AsyncClient(timeout=20, headers=HEADERS) as client:
20
+ r = await client.get(url, params={"source": "ALL", "format": "json"})
21
+ r.raise_for_status()
22
+ data = r.json()
23
+ return data[:limit]