|
|
|
""" |
|
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] |
|
|