File size: 701 Bytes
3925910
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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]