repaircase 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
repaircase/__init__.py ADDED
File without changes
@@ -0,0 +1,16 @@
1
+ agent,approved,approved_source,advised_against,tolerability,tolerability_source,checked_on
2
+ metformin + clemastine,yes,"Drugs@FDA (api.fda.gov/drug/drugsfda): metformin 214 applications incl. NDA216778; clemastine fumarate 15 applications incl. ANDA074075",no,limited,"RepairMap row metformin-clemastine-ccmr2 (conference report): more fatigue and gut side effects on treatment; the report does not state it was well tolerated",2026-11-23
3
+ clemastine,yes,"Drugs@FDA: clemastine fumarate, 15 applications incl. ANDA074075",no,well,"PMID 29029896 abstract: no serious adverse events; fatigue more common on clemastine",2026-11-23
4
+ metformin,yes,"Drugs@FDA: metformin hydrochloride, 214 applications",no,na,no positive trial,2026-11-23
5
+ phenytoin,yes,"Drugs@FDA: phenytoin, 43 applications incl. NDA008762",no,well,"PMID 26822749 abstract: 'Treatment was well tolerated'; one attributable serious event (severe rash)",2026-11-23
6
+ bexarotene,yes,"Drugs@FDA: bexarotene, 11 applications incl. ANDA203174",yes,limited,"PMID 34418398 abstract: central hypothyroidism 26 of 26, hypertriglyceridaemia 24 of 26; authors advise against use",2026-11-23
7
+ bazedoxifene,yes,"Drugs@FDA: bazedoxifene acetate, NDA022247 (with conjugated oestrogens)",no,na,no positive trial,2026-11-23
8
+ domperidone,yes,"EMA referral page 'Domperidone-containing medicines': authorised nationally in EU member states for nausea and vomiting; no Drugs@FDA record",no,na,no positive trial,2026-11-23
9
+ high-dose biotin (MD1003),yes,"Drugs@FDA lists biotin only as a vitamin ingredient (15 applications); the 300 mg/day product itself was not found there",no,na,"tolerability of the positive trial not sourced; cannot change the ranking",2026-11-23
10
+ opicinumab,no,"no Drugs@FDA record on 2026-11-23; EMA not checked",no,na,no positive trial,2026-11-23
11
+ elezanumab,no,"no Drugs@FDA record on 2026-11-23; EMA not checked",no,na,no positive trial,2026-11-23
12
+ GSK239512,no,"no Drugs@FDA record on 2026-11-23; EMA not checked",no,na,no positive trial,2026-11-23
13
+ PIPE-307,no,"no Drugs@FDA record on 2026-11-23; EMA not checked",no,na,no positive trial,2026-11-23
14
+ PIPE-791,no,"no Drugs@FDA record on 2026-11-23; EMA not checked",no,na,no positive trial,2026-11-23
15
+ CNM-Au8,no,"no Drugs@FDA record on 2026-11-23; EMA not checked",no,na,no positive trial,2026-11-23
16
+ autologous MSC-derived neural progenitors,no,"cell therapy; no approval found, FDA and EMA product lists not checked",no,na,no positive trial,2026-11-23
repaircase/score.py ADDED
@@ -0,0 +1,165 @@
1
+ """Score repair-trial candidates against docs/RUBRIC.md.
2
+
3
+ Reads the RepairMap trial table and a small sheet of sourced judgements
4
+ (approval, tolerability). Prints the ranking and writes results/scores.csv.
5
+
6
+ Run: repaircase (or, in a checkout: python -m repaircase.score --trials ../repairmap/data/trials.csv)
7
+ """
8
+
9
+ from __future__ import annotations
10
+
11
+ import argparse
12
+ import csv
13
+ from dataclasses import dataclass, field
14
+ from pathlib import Path
15
+
16
+ ROOT = Path(__file__).resolve().parent.parent
17
+ CHECKOUT = (ROOT / "pyproject.toml").exists() # run from the repository, not an installed wheel
18
+
19
+
20
+ def _packaged(package: str, name: str) -> Path:
21
+ from importlib.resources import files
22
+
23
+ return Path(str(files(package) / name))
24
+
25
+
26
+ def _default_trials() -> Path:
27
+ """The sibling RepairMap checkout when there is one, else the table in the installed repairmap."""
28
+ sibling = ROOT.parent / "repairmap" / "data" / "trials.csv"
29
+ return sibling if CHECKOUT and sibling.exists() else _packaged("repairmap.data", "trials.csv")
30
+
31
+
32
+ JUDGEMENTS = ROOT / "data" / "judgements.csv" if CHECKOUT else _packaged("repaircase.data", "judgements.csv")
33
+ BAR = 4
34
+ DECIDED = {"positive", "mixed", "negative", "harm"}
35
+
36
+
37
+ @dataclass
38
+ class Score:
39
+ agent: str
40
+ e1: int = 0
41
+ e2: int = 0
42
+ e3: int = 0
43
+ e4: int = 0
44
+ e5: int = 0
45
+ e6: int = 0
46
+ gates_failed: list[str] = field(default_factory=list)
47
+ missing: list[str] = field(default_factory=list)
48
+ ongoing: list[str] = field(default_factory=list)
49
+
50
+ @property
51
+ def total(self) -> int:
52
+ return self.e1 + self.e2 + self.e3 + self.e4 + self.e5 + self.e6
53
+
54
+ @property
55
+ def status(self) -> str:
56
+ if self.gates_failed:
57
+ return "gate failed"
58
+ if self.missing:
59
+ return "incomplete"
60
+ return "clears the bar" if self.total >= BAR else "below the bar"
61
+
62
+
63
+ def read_csv(path: Path) -> list[dict[str, str]]:
64
+ with path.open(newline="") as fh:
65
+ return list(csv.DictReader(fh))
66
+
67
+
68
+ def parts(agent: str) -> list[str]:
69
+ return [p.strip() for p in agent.split("+")]
70
+
71
+
72
+ def _positive_biomarker(rows: list[dict[str, str]]) -> int:
73
+ return sum(r["outcome_class"] == "biomarker" and r["result"] == "positive" for r in rows)
74
+
75
+
76
+ def score_agent(agent: str, trials: list[dict[str, str]], judgement: dict[str, str] | None) -> Score:
77
+ s = Score(agent)
78
+ own = [r for r in trials if r["agent"] == agent]
79
+ decided = [r for r in own if r["result"] in DECIDED]
80
+ s.ongoing = [r["id"] for r in own if r["result"] == "ongoing"]
81
+
82
+ # Related rows: combinations that contain this agent, or the parts of this combination.
83
+ mine = set(parts(agent))
84
+ related = [
85
+ r for r in trials
86
+ if r["agent"] != agent and r["result"] in DECIDED
87
+ and (mine < set(parts(r["agent"])) or set(parts(r["agent"])) < mine)
88
+ ]
89
+
90
+ pos_bio = _positive_biomarker(decided)
91
+ if pos_bio:
92
+ s.e1 = 2
93
+ elif any(r["outcome_class"] == "biomarker" and r["result"] == "mixed" for r in decided):
94
+ s.e1 = 1
95
+
96
+ if pos_bio >= 2:
97
+ s.e2 = 2
98
+ elif pos_bio == 1 and _positive_biomarker(related):
99
+ s.e2 = 1
100
+
101
+ functional = [r for r in decided if r["outcome_class"] == "functional"]
102
+ if any(r["result"] == "positive" for r in functional):
103
+ s.e3 = 2
104
+ elif any(r["result"] == "mixed" for r in functional):
105
+ s.e3 = 1
106
+
107
+ s.e4 = -min(2, sum(r["result"] == "negative" for r in decided))
108
+ s.e5 = -2 if any(r["result"] == "harm" for r in decided) else 0
109
+
110
+ if not decided:
111
+ s.gates_failed.append("G2 no trial with a result")
112
+ if judgement is None:
113
+ s.missing.append("no judgement row (approval, tolerability)")
114
+ return s
115
+ if judgement["approved"] == "no":
116
+ s.gates_failed.append("G1 not approved for any use")
117
+ elif judgement["approved"] != "yes":
118
+ s.missing.append("approval not sourced")
119
+ if judgement["advised_against"] == "yes":
120
+ s.gates_failed.append("G3 trial authors advised against use")
121
+ if judgement["tolerability"] == "well":
122
+ s.e6 = 1
123
+ elif judgement["tolerability"] not in {"limited", "na"}:
124
+ s.missing.append("tolerability not sourced")
125
+ return s
126
+
127
+
128
+ def score_all(trials: list[dict[str, str]], judgements: list[dict[str, str]]) -> list[Score]:
129
+ by_agent = {j["agent"]: j for j in judgements}
130
+ agents = sorted({r["agent"] for r in trials if r["result"] in DECIDED})
131
+ scores = [score_agent(a, trials, by_agent.get(a)) for a in agents]
132
+ return sorted(scores, key=lambda s: (bool(s.gates_failed), -s.total, s.agent))
133
+
134
+
135
+ def write(scores: list[Score], out: Path) -> None:
136
+ out.parent.mkdir(parents=True, exist_ok=True)
137
+ with out.open("w", newline="") as fh:
138
+ w = csv.writer(fh)
139
+ w.writerow(["agent", "total", "status", "e1", "e2", "e3", "e4", "e5", "e6",
140
+ "gates_failed", "missing", "ongoing_trials"])
141
+ for s in scores:
142
+ w.writerow([s.agent, s.total, s.status, s.e1, s.e2, s.e3, s.e4, s.e5, s.e6,
143
+ "; ".join(s.gates_failed), "; ".join(s.missing), "; ".join(s.ongoing)])
144
+
145
+
146
+ def main() -> int:
147
+ ap = argparse.ArgumentParser(description="Score repair-trial candidates against docs/RUBRIC.md.")
148
+ ap.add_argument("--trials", type=Path, default=None,
149
+ help="RepairMap trials.csv (default: the installed repairmap's table)")
150
+ ap.add_argument("--judgements", type=Path, default=JUDGEMENTS)
151
+ ap.add_argument("--out", type=Path, default=ROOT / "results" / "scores.csv" if CHECKOUT else Path("scores.csv"))
152
+ a = ap.parse_args()
153
+
154
+ judgements = read_csv(a.judgements) if a.judgements.exists() else []
155
+ scores = score_all(read_csv(a.trials or _default_trials()), judgements)
156
+ write(scores, a.out)
157
+ for s in scores:
158
+ print(f"{s.total:>3} {s.status:<15} {s.agent} "
159
+ f"[E1 {s.e1} E2 {s.e2} E3 {s.e3} E4 {s.e4} E5 {s.e5} E6 {s.e6}]"
160
+ + (f" ({'; '.join(s.gates_failed + s.missing)})" if s.gates_failed or s.missing else ""))
161
+ return 0
162
+
163
+
164
+ if __name__ == "__main__":
165
+ raise SystemExit(main())
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.4
2
+ Name: repaircase
3
+ Version: 0.1.0
4
+ Summary: Scores approved drugs for a myelin repair trial in multiple sclerosis against a pre-registered rubric
5
+ Author: Cedric Conday
6
+ License: MIT
7
+ Requires-Python: >=3.10
8
+ Description-Content-Type: text/markdown
9
+ License-File: LICENSE
10
+ Requires-Dist: repairmap>=0.1.0
11
+ Provides-Extra: dev
12
+ Requires-Dist: pytest; extra == "dev"
13
+ Requires-Dist: ruff; extra == "dev"
14
+ Dynamic: license-file
15
+
16
+ # RepairCase
17
+
18
+ Working name. The written case for one already-approved drug as the candidate for a myelin repair trial in multiple sclerosis, scored against a rubric that was fixed before the scoring.
19
+
20
+ Started 2026-11-23. Part of RepairStack. Nothing here is medical advice.
21
+
22
+ ## How it works
23
+
24
+ 1. `docs/RUBRIC.md` sets the gates, the points and the bar. It was committed before any candidate was scored.
25
+ 2. `repaircase/score.py` reads the RepairMap trial table and scores every candidate.
26
+ 3. `docs/CASE.md` is the result: the ranking, and the case for and against the top candidate.
27
+
28
+ ## Result on 2026-11-23
29
+
30
+ No approved drug clears the bar of 4 points. The best available candidate is metformin plus clemastine at 3 points. Read `docs/CASE.md` for the ranking, the case for and against, and what result would change it.
31
+
32
+ Scored on RepairMap v0.1.0 (64 trials).
33
+
34
+ ## Run it
35
+
36
+ ```
37
+ pip install repaircase # pulls in repairmap and its trial table
38
+ repaircase # prints the ranking, writes scores.csv
39
+ ```
40
+
41
+ Approval and tolerability for each drug are in `data/judgements.csv`, each with its source. US approval records come from the FDA's public Drugs@FDA database.
@@ -0,0 +1,9 @@
1
+ repaircase/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ repaircase/score.py,sha256=R8HtOl3kbI1qmAdYFjGmakb5Foh9iZdvZpRu3ALSGZw,6079
3
+ repaircase/data/judgements.csv,sha256=gA87uzpIESUCr20vORzYL99yK3_2AK67GbDPyRe-wrY,2459
4
+ repaircase-0.1.0.dist-info/licenses/LICENSE,sha256=8lcLWeN_AyQyu7Rc59azPb8rsdho2H380fSv3nnRoII,1070
5
+ repaircase-0.1.0.dist-info/METADATA,sha256=Fc21XAWMwBoQKOXU3JJHJDTFEfkMRcrOpEu3uaS5oMo,1610
6
+ repaircase-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
7
+ repaircase-0.1.0.dist-info/entry_points.txt,sha256=hqtQFlDTuiZMikLFWMljG16vKUPKZHbdgvi4SQ3NbHM,53
8
+ repaircase-0.1.0.dist-info/top_level.txt,sha256=8DQBr45K9w64uPvG-yjRkcV4FEQx6JXPFPhZMy7wGNc,11
9
+ repaircase-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ repaircase = repaircase.score:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Cedric Conday
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ repaircase