r/madeinpython • u/Snoo_74391 • 3m ago
Sorting rare-disease medicines into approved, in trials and worth-reading-about with plain Python rules over Open Targets data
In a lot of the world, a family facing a rare diagnosis has no easy way to see which medicines are licensed for it, which are in trials, and where those trials are. The records exist, but they sit in regulator labels, trial registries and research portals written for specialists. Moonlight is our attempt to put them on one page: type a condition, get medicine cards, each linked to the record it came from.
The reason we keep going: someone in Kochi, in southern India, living with limb-girdle muscular dystrophy, used it to find a trial recruiting in the US (they are happy for us to say so). If you already see a specialist at a big research hospital, this adds little. Where specialists are thin on the ground, it can be the first time someone sees the options laid out.
How it is put together
It is a small Python package, moonlight/, served by FastAPI and Uvicorn, with a single static HTML/JS page in front.
translate.pyturns an everyday or misspelt name into a disease Open Targets knows (MONDO, EFO or HP IDs). Gemini proposes up to three candidate names, each is looked up in Open Targets, and only Open Targets' own name and ID are used. Gemini's text is never shown, and the page only offers "Did you mean"; it never picks a disease for you.fetch.pycalls the Open Targets Platform GraphQL API for the disease's linked protein targets and the drugs acting on them. Open Targets is the only source of record; there is no private database behind it.filter.py,engine.pyandrank.pydo the sorting with ordinary rules, not a model: approved for this disease goes to Approved, in a trial for it goes to Being studied, approved for something else but acting on a linked protein goes to New clues, and unapproved compounds go to Left out. Salt forms collapse into one card, and the ranking is deterministic (linked-protein score, then number of reports, then alphabetical).protein.pyandexplain.pyadd a UniProt function line and a plain-English sentence per card.cache.pykeeps three layers: in memory,/tmpon the container, and Firestore for raw Open Targets responses, so a cold Cloud Run instance (asia-south1, Docker) does not hammer the upstream API.- Hand-checked fixes live in versioned JSON next to the code (
corrections.json,approvals.json,withdrawals.json,left_out.jsonand a few more), each pinned by a pytest test that runs against saved Open Targets fixtures, so a fix cannot quietly regress after an upstream release.
Where else AI comes in: never to decide what a card says. Offline batch scripts use model calls to read FDA, EMA, DailyMed and PMDA labels and flag cards whose "approved" status has no matching label. A human decides each fix. Corrections people post on Reddit become numbered tickets, get checked against a regulator label, and land in those JSON files with a test.
What has worked so far
- Besides the Kochi trial find, Open Targets confirmed seven wrong approval records we reported and has scheduled the fix for release 26.12 (thread 2105 on their community forum).
- 17 tickets so far have come straight from patient communities pointing out mistakes, and a 124-disease audit found 724 of 2,096 "approved" entries had no DailyMed, FDA or EMA report attached. Those cards are now marked as weakly proven rather than hidden.
What is hard
- One upstream source means its gaps are ours. Medicines licensed in the UK, EU or India but not by the FDA can show up as "in trials" only, and fixing that properly means pulling more regulators in.
- Label checking across thousands of drug-disease pairs costs model API money, which we pay ourselves. There are no ads and no data selling, and we want to keep it that way.
Live site: https://www.moonlightclues.com Code (MIT): https://github.com/Moonlight-Clues/moonlight. A star helps if you find it useful.
The ask: the thing that would move us fastest is AI model credits, or a pointer to a credit programme (or a person) that backs open-source public-interest work. Separately, if you have worked with regulator data in Python, especially CDSCO or EMA, I would be glad of advice on parsing it, or a pull request.