Delete scripts/package_release.py
Browse files- scripts/package_release.py +0 -437
scripts/package_release.py
DELETED
|
@@ -1,437 +0,0 @@
|
|
| 1 |
-
import json, os, glob, hashlib, shutil, sys, textwrap
|
| 2 |
-
from pathlib import Path
|
| 3 |
-
from datetime import datetime
|
| 4 |
-
import pandas as pd
|
| 5 |
-
import numpy as np
|
| 6 |
-
|
| 7 |
-
ROOT = Path(".").resolve()
|
| 8 |
-
DATA = ROOT/"data"; PROC = DATA/"processed"
|
| 9 |
-
RES = ROOT/"results"; RES.mkdir(parents=True, exist_ok=True)
|
| 10 |
-
DOCS = ROOT/"docs"; DOCS.mkdir(parents=True, exist_ok=True)
|
| 11 |
-
PKG = ROOT/"package"; PKG.mkdir(parents=True, exist_ok=True)
|
| 12 |
-
|
| 13 |
-
def find_one(patterns):
|
| 14 |
-
if isinstance(patterns, (str, Path)): patterns=[patterns]
|
| 15 |
-
hits=[]
|
| 16 |
-
for p in patterns:
|
| 17 |
-
hits.extend(glob.glob(str(p)))
|
| 18 |
-
return Path(sorted(hits)[0]) if hits else None
|
| 19 |
-
|
| 20 |
-
def md5(p: Path, chunk=65536):
|
| 21 |
-
h=hashlib.md5()
|
| 22 |
-
with open(p,"rb") as f:
|
| 23 |
-
for b in iter(lambda: f.read(chunk), b""):
|
| 24 |
-
h.update(b)
|
| 25 |
-
return h.hexdigest()
|
| 26 |
-
|
| 27 |
-
snap2 = find_one([RES/"atlas_section2_snapshot*.json", RES/"section2_snapshot*.json", RES/"atlas_section2_baselines/section2_snapshot*.json"])
|
| 28 |
-
base2 = find_one([RES/"baseline_summary*.json", RES/"atlas_section2_baselines/baseline_summary*.json"])
|
| 29 |
-
snap3 = find_one([RES/"causal_section3_snapshot*.json"])
|
| 30 |
-
rob3 = find_one([RES/"causal_section3_robustness*.json"])
|
| 31 |
-
snap4 = find_one([RES/"al_section4_snapshot*.json", RES/"al_section4_snapshot (1).json"])
|
| 32 |
-
snap5 = find_one([RES/"section5_transfer_snapshot*.json"])
|
| 33 |
-
|
| 34 |
-
wow_pack = (RES/"wow_pack_manifest.json") if (RES/"wow_pack_manifest.json").exists() else None
|
| 35 |
-
|
| 36 |
-
lit_csv = (RES/"validation_lit_crosscheck.csv") if (RES/"validation_lit_crosscheck.csv").exists() else None
|
| 37 |
-
anchor_csv = (RES/"validation_anchor_per_stress.csv") if (RES/"validation_anchor_per_stress.csv").exists() else None
|
| 38 |
-
inter_csv = (RES/"validation_interactions.csv") if (RES/"validation_interactions.csv").exists() else None
|
| 39 |
-
ext_mat = (RES/"validation_external_matrix.csv") if (RES/"validation_external_matrix.csv").exists() else None
|
| 40 |
-
ext_conc = (RES/"validation_external_concordance.csv") if (RES/"validation_external_concordance.csv").exists() else None
|
| 41 |
-
|
| 42 |
-
found = {
|
| 43 |
-
"sec2_snapshot": str(snap2) if snap2 else None,
|
| 44 |
-
"sec2_baselines": str(base2) if base2 else None,
|
| 45 |
-
"sec3_snapshot": str(snap3) if snap3 else None,
|
| 46 |
-
"sec3_robust": str(rob3) if rob3 else None,
|
| 47 |
-
"sec4_snapshot": str(snap4) if snap4 else None,
|
| 48 |
-
"sec5_snapshot": str(snap5) if snap5 else None,
|
| 49 |
-
"wow_pack": str(wow_pack) if wow_pack else None,
|
| 50 |
-
"val_literature_csv": str(lit_csv) if lit_csv else None,
|
| 51 |
-
"val_anchor_csv": str(anchor_csv) if anchor_csv else None,
|
| 52 |
-
"val_interactions_csv": str(inter_csv) if inter_csv else None,
|
| 53 |
-
"val_external_matrix": str(ext_mat) if ext_mat else None,
|
| 54 |
-
"val_external_concordance": str(ext_conc) if ext_conc else None,
|
| 55 |
-
}
|
| 56 |
-
print(json.dumps(found, indent=2))
|
| 57 |
-
|
| 58 |
-
def add_fig(rows, path, desc):
|
| 59 |
-
p = Path(path)
|
| 60 |
-
if p.exists():
|
| 61 |
-
rows.append({"figure": p.name, "path": str(p), "description": desc, "md5": md5(p)})
|
| 62 |
-
|
| 63 |
-
fig_rows=[]
|
| 64 |
-
add_fig(fig_rows, RES/"pr_curves_random.png", "Sec2 PR curves (random)")
|
| 65 |
-
add_fig(fig_rows, RES/"calibration_curves.png", "Sec2 Calibration")
|
| 66 |
-
add_fig(fig_rows, RES/"causal_section3_waterfall.png", "Sec3 Causal waterfall")
|
| 67 |
-
add_fig(fig_rows, RES/"causal_section3_counterfactual_PDR5_expr.png", "Sec3 Counterfactual PDR5")
|
| 68 |
-
add_fig(fig_rows, RES/"causal_section3_stress_heatmap.png", "Sec3 Stress ATE heatmap")
|
| 69 |
-
add_fig(fig_rows, RES/"ED_Fig_trimmed_ATEs.png", "Extended trimmed ATEs")
|
| 70 |
-
add_fig(fig_rows, RES/"ED_Fig_placebo_hist.png", "Extended placebo ATEs")
|
| 71 |
-
add_fig(fig_rows, RES/"al_section4_efficiency_curve.png", "Sec4 AL efficiency curve")
|
| 72 |
-
add_fig(fig_rows, RES/"al_section4_gain_bars.png", "Sec4 AL gains vs random")
|
| 73 |
-
add_fig(fig_rows, RES/"transfer_train_ethanol_test_oxidative.png", "Sec5 transfer ethanol→oxidative")
|
| 74 |
-
add_fig(fig_rows, RES/"transfer_train_ethanol_test_osmotic.png", "Sec5 transfer ethanol→osmotic")
|
| 75 |
-
add_fig(fig_rows, RES/"fig_ct_map.png", "WOW Causal topology map")
|
| 76 |
-
add_fig(fig_rows, RES/"fig_SIMS_waterfall.png", "WOW SIMS waterfall")
|
| 77 |
-
add_fig(fig_rows, RES/"validation_external_heatmap.png", "Sec6 external benchmark heatmap")
|
| 78 |
-
|
| 79 |
-
mapped=set(r["path"] for r in fig_rows)
|
| 80 |
-
for f in sorted(glob.glob(str(RES/"*.png"))):
|
| 81 |
-
if f not in mapped:
|
| 82 |
-
add_fig(fig_rows, f, "Figure (auto)")
|
| 83 |
-
fig_map = pd.DataFrame(fig_rows).sort_values("figure")
|
| 84 |
-
fig_map.to_csv(RES/"figure_map.csv", index=False)
|
| 85 |
-
print("Wrote:", RES/"figure_map.csv")
|
| 86 |
-
|
| 87 |
-
def _load_json(p):
|
| 88 |
-
try:
|
| 89 |
-
return json.load(open(p,"r")) if p else {}
|
| 90 |
-
except Exception as e:
|
| 91 |
-
print("⚠️ load fail:", p, e); return {}
|
| 92 |
-
|
| 93 |
-
sec2 = _load_json(snap2); base=_load_json(base2)
|
| 94 |
-
sec3 = _load_json(snap3); rob=_load_json(rob3)
|
| 95 |
-
sec4 = _load_json(snap4); sec5=_load_json(snap5)
|
| 96 |
-
|
| 97 |
-
claims=[]
|
| 98 |
-
|
| 99 |
-
for mode in ("random","cold_protein","cold_ligand","cold_both"):
|
| 100 |
-
auprc=None; auroc=None
|
| 101 |
-
if isinstance(base.get(mode), dict):
|
| 102 |
-
auprc = base[mode].get("AUPRC", auprc)
|
| 103 |
-
auroc = base[mode].get("AUROC", auroc)
|
| 104 |
-
if isinstance(sec2.get("metrics"), dict) and isinstance(sec2["metrics"].get(mode), dict):
|
| 105 |
-
v=sec2["metrics"][mode]
|
| 106 |
-
auprc = v.get("AUPRC", auprc); auroc = v.get("AUROC", auroc)
|
| 107 |
-
if auprc is not None or auroc is not None:
|
| 108 |
-
claims.append({"section":"2","claim":"Atlas AUPRC/AUROC","split":mode,
|
| 109 |
-
"value_1":float(auprc) if auprc is not None else np.nan,
|
| 110 |
-
"value_2":float(auroc) if auroc is not None else np.nan,
|
| 111 |
-
"units":"AUPRC/AUROC"})
|
| 112 |
-
|
| 113 |
-
def _scalar(x):
|
| 114 |
-
try:
|
| 115 |
-
return float(x)
|
| 116 |
-
except:
|
| 117 |
-
pass
|
| 118 |
-
if isinstance(x, (list,tuple,np.ndarray)):
|
| 119 |
-
vals=[_scalar(v) for v in x]
|
| 120 |
-
vals=[v for v in vals if isinstance(v,(int,float)) and not np.isnan(v)]
|
| 121 |
-
return float(np.mean(vals)) if vals else np.nan
|
| 122 |
-
if isinstance(x, dict):
|
| 123 |
-
vals=[_scalar(v) for v in x.values()]
|
| 124 |
-
vals=[v for v in vals if isinstance(v,(int,float)) and not np.isnan(v)]
|
| 125 |
-
return float(np.mean(vals)) if vals else np.nan
|
| 126 |
-
return np.nan
|
| 127 |
-
|
| 128 |
-
ATE = None
|
| 129 |
-
for k in ("ATE_table","stress_ate","ate_table","ate","effects"):
|
| 130 |
-
if k in sec3: ATE = sec3[k]; break
|
| 131 |
-
|
| 132 |
-
ate_tab = []
|
| 133 |
-
if isinstance(ATE, dict):
|
| 134 |
-
for tr,v in ATE.items():
|
| 135 |
-
val=_scalar(v)
|
| 136 |
-
if not np.isnan(val):
|
| 137 |
-
ate_tab.append((tr,val))
|
| 138 |
-
elif isinstance(ATE, list):
|
| 139 |
-
for d in ATE:
|
| 140 |
-
if isinstance(d, dict):
|
| 141 |
-
tr=d.get("transporter") or d.get("gene") or d.get("name")
|
| 142 |
-
val=_scalar(d.get("ATE", d.get("value")))
|
| 143 |
-
if tr and not np.isnan(val): ate_tab.append((tr,val))
|
| 144 |
-
|
| 145 |
-
if ate_tab:
|
| 146 |
-
top = sorted(((tr,abs(v)) for tr,v in ate_tab), key=lambda x: x[1], reverse=True)[:10]
|
| 147 |
-
for tr,mag in top:
|
| 148 |
-
claims.append({"section":"3","claim":"Top |ATE|","split":tr,"value_1":float(mag),"units":"effect size"})
|
| 149 |
-
|
| 150 |
-
gains_csv = RES/"gains_table.csv"
|
| 151 |
-
if gains_csv.exists():
|
| 152 |
-
gdf=pd.read_csv(gains_csv)
|
| 153 |
-
for r in gdf.itertuples(index=False):
|
| 154 |
-
claims.append({"section":"4","claim":"AL gain vs random","split":r.strategy,
|
| 155 |
-
"value_1":float(r.mean_gain),
|
| 156 |
-
"value_2_low":float(getattr(r,"ci_low",np.nan)),
|
| 157 |
-
"value_2_high":float(getattr(r,"ci_high",np.nan)),
|
| 158 |
-
"units":"×"})
|
| 159 |
-
|
| 160 |
-
if isinstance(sec5.get("transfer"), dict):
|
| 161 |
-
for k,v in sec5["transfer"].items():
|
| 162 |
-
if isinstance(v, dict):
|
| 163 |
-
auprc=v.get("auprc"); auroc=v.get("auroc")
|
| 164 |
-
if auprc is not None or auroc is not None:
|
| 165 |
-
claims.append({"section":"5","claim":"Stress transfer","split":k,
|
| 166 |
-
"value_1":float(auprc) if auprc is not None else np.nan,
|
| 167 |
-
"value_2":float(auroc) if auroc is not None else np.nan,
|
| 168 |
-
"units":"AUPRC/AUROC"})
|
| 169 |
-
|
| 170 |
-
claims_df = pd.DataFrame(claims)
|
| 171 |
-
claims_df.to_csv(RES/"claims_table.csv", index=False)
|
| 172 |
-
print("Wrote:", RES/"claims_table.csv")
|
| 173 |
-
|
| 174 |
-
readme_txt = textwrap.dedent("""
|
| 175 |
-
# ABC-Atlas: Protein–Ligand Prediction, Causal Ranking, and Active Learning
|
| 176 |
-
|
| 177 |
-
This bundle reproduces the analyses across Sections 1–7 and collects figures/tables for submission.
|
| 178 |
-
|
| 179 |
-
## Quick Start
|
| 180 |
-
```bash
|
| 181 |
-
pip install -r requirements.txt
|
| 182 |
-
# run notebook sections 2–7 to regenerate figures under results/
|
| 183 |
-
```
|
| 184 |
-
## Figure → File Map
|
| 185 |
-
See `results/figure_map.csv` (with MD5 checksums).
|
| 186 |
-
|
| 187 |
-
## Headline Claims
|
| 188 |
-
See `results/claims_table.csv` (all numeric claims with units and section tags).
|
| 189 |
-
|
| 190 |
-
## Data
|
| 191 |
-
Processed CSVs: `data/processed/` (proteins, ligands, labels, causal_table)
|
| 192 |
-
|
| 193 |
-
## Citation
|
| 194 |
-
See `CITATION.cff` (add DOI when minted).
|
| 195 |
-
""").strip()+"\n"
|
| 196 |
-
(PKG/"README.md").write_text(readme_txt)
|
| 197 |
-
|
| 198 |
-
license_txt = textwrap.dedent(f"""
|
| 199 |
-
MIT License
|
| 200 |
-
|
| 201 |
-
Copyright (c) {datetime.now().year}
|
| 202 |
-
|
| 203 |
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
| 204 |
-
of this software and associated documentation files (the "Software"), to deal
|
| 205 |
-
in the Software without restriction, including without limitation the rights
|
| 206 |
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
| 207 |
-
copies of the Software, and to permit persons to whom the Software is
|
| 208 |
-
furnished to do so, subject to the following conditions:
|
| 209 |
-
|
| 210 |
-
The above copyright notice and this permission notice shall be included in all
|
| 211 |
-
copies or substantial portions of the Software.
|
| 212 |
-
|
| 213 |
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
| 214 |
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
| 215 |
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
| 216 |
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
| 217 |
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
| 218 |
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
| 219 |
-
SOFTWARE.
|
| 220 |
-
""").strip()+"\n"
|
| 221 |
-
(PKG/"LICENSE").write_text(license_txt)
|
| 222 |
-
|
| 223 |
-
citation_cff = textwrap.dedent(f"""
|
| 224 |
-
cff-version: 1.2.0
|
| 225 |
-
message: "If you use this package, please cite it."
|
| 226 |
-
title: "ABC-Atlas: protein–ligand prediction with causal ranking and active learning"
|
| 227 |
-
authors:
|
| 228 |
-
- family-names: "YourSurname"
|
| 229 |
-
given-names: "YourName"
|
| 230 |
-
version: "0.1.0"
|
| 231 |
-
doi: ""
|
| 232 |
-
date-released: "{datetime.now().date()}"
|
| 233 |
-
""").strip()+"\n"
|
| 234 |
-
(PKG/"CITATION.cff").write_text(citation_cff)
|
| 235 |
-
|
| 236 |
-
req_txt = textwrap.dedent("""
|
| 237 |
-
numpy
|
| 238 |
-
pandas
|
| 239 |
-
scikit-learn
|
| 240 |
-
torch
|
| 241 |
-
transformers
|
| 242 |
-
matplotlib
|
| 243 |
-
seaborn
|
| 244 |
-
econml
|
| 245 |
-
""").strip()+"\n"
|
| 246 |
-
(PKG/"requirements.txt").write_text(req_txt)
|
| 247 |
-
|
| 248 |
-
for name, src in [("results", RES), ("docs", DOCS)]:
|
| 249 |
-
dst = PKG/name
|
| 250 |
-
if dst.exists(): shutil.rmtree(dst)
|
| 251 |
-
if src.exists(): shutil.copytree(src, dst)
|
| 252 |
-
|
| 253 |
-
(PKG/"data/processed").mkdir(parents=True, exist_ok=True)
|
| 254 |
-
for pth in [PROC/"protein.csv", PROC/"ligand.csv", PROC/"labels.csv", PROC/"causal_table.csv"]:
|
| 255 |
-
if pth.exists(): shutil.copy2(pth, PKG/"data/processed"/pth.name)
|
| 256 |
-
|
| 257 |
-
manifest = {
|
| 258 |
-
"built_at": datetime.utcnow().isoformat()+"Z",
|
| 259 |
-
"python": sys.version.replace("\n"," "),
|
| 260 |
-
"artifacts": found,
|
| 261 |
-
"figures": fig_map.to_dict(orient="records"),
|
| 262 |
-
"claims": claims_df.to_dict(orient="records"),
|
| 263 |
-
}
|
| 264 |
-
(RES/"build_manifest.json").write_text(json.dumps(manifest, indent=2))
|
| 265 |
-
print("Wrote:", RES/"build_manifest.json")
|
| 266 |
-
print("✅ Section 8 prep complete — run the ZIP cell next.")
|
| 267 |
-
|
| 268 |
-
# ──────────────────────────────────────────────────
|
| 269 |
-
|
| 270 |
-
# --- Write a polished README.md (standalone) ---
|
| 271 |
-
from pathlib import Path
|
| 272 |
-
import textwrap, json, datetime
|
| 273 |
-
|
| 274 |
-
PKG = Path("package"); PKG.mkdir(exist_ok=True)
|
| 275 |
-
RES = Path("results"); RES.mkdir(exist_ok=True)
|
| 276 |
-
|
| 277 |
-
def _safe_json(p):
|
| 278 |
-
try:
|
| 279 |
-
return json.loads(Path(p).read_text())
|
| 280 |
-
except Exception:
|
| 281 |
-
return {}
|
| 282 |
-
|
| 283 |
-
# Best-effort headline extraction
|
| 284 |
-
headline_auprc = "~0.09"; headline_auroc = "~0.65"
|
| 285 |
-
s2 = {}
|
| 286 |
-
for cand in ["atlas_section2_snapshot.json", "section2_snapshot.json", "baseline_summary.json"]:
|
| 287 |
-
p = RES/cand
|
| 288 |
-
if p.exists():
|
| 289 |
-
s2 = _safe_json(p); break
|
| 290 |
-
if s2:
|
| 291 |
-
block = s2.get("cold_both") or s2.get("random") or {}
|
| 292 |
-
try:
|
| 293 |
-
if isinstance(block.get("AUPRC"), (int,float)): headline_auprc = f"{block['AUPRC']:.3f}"
|
| 294 |
-
if isinstance(block.get("AUROC"), (int,float)): headline_auroc = f"{block['AUROC']:.3f}"
|
| 295 |
-
except Exception:
|
| 296 |
-
pass
|
| 297 |
-
|
| 298 |
-
al_gain = "≥1.2×"
|
| 299 |
-
al = _safe_json(next((str(p) for p in RES.glob("al_section4_snapshot*.json")), ""))
|
| 300 |
-
if isinstance(al.get("gains_vs_random_mean"), dict):
|
| 301 |
-
try:
|
| 302 |
-
best = max(al["gains_vs_random_mean"], key=lambda k: al["gains_vs_random_mean"][k])
|
| 303 |
-
al_gain = f"{al['gains_vs_random_mean'][best]:.2f}× (best={best})"
|
| 304 |
-
except Exception:
|
| 305 |
-
pass
|
| 306 |
-
|
| 307 |
-
top_causal = "ATM1, VBA1/2, YBT1, SNQ2"
|
| 308 |
-
s3 = _safe_json(next((str(p) for p in RES.glob("causal_section3_snapshot*.json")), ""))
|
| 309 |
-
ate_tbl = s3.get("ATE_table") or s3.get("stress_ate")
|
| 310 |
-
if isinstance(ate_tbl, dict):
|
| 311 |
-
try:
|
| 312 |
-
vals = {}
|
| 313 |
-
for k,v in ate_tbl.items():
|
| 314 |
-
if isinstance(v, dict): # per-stress
|
| 315 |
-
arr = [abs(float(x)) for x in v.values() if isinstance(x,(int,float))]
|
| 316 |
-
if arr: vals[k] = sum(arr)/len(arr)
|
| 317 |
-
elif isinstance(v,(int,float)):
|
| 318 |
-
vals[k] = abs(float(v))
|
| 319 |
-
if vals:
|
| 320 |
-
top = sorted(vals, key=vals.get, reverse=True)[:4]
|
| 321 |
-
top_causal = ", ".join(t.replace("_expr","") for t in top)
|
| 322 |
-
except Exception:
|
| 323 |
-
pass
|
| 324 |
-
|
| 325 |
-
today = datetime.date.today().isoformat()
|
| 326 |
-
|
| 327 |
-
readme = textwrap.dedent("""
|
| 328 |
-
# ABC-Atlas: Prediction, Causal Ranking, and Active Learning for Yeast ABC Transporters
|
| 329 |
-
|
| 330 |
-
**Pipeline:** *Atlas (Section 2) → Causal (Section 3) → Active Learning (Section 4) → Stress Transfer (Section 5) → Validation (Section 6).*
|
| 331 |
-
|
| 332 |
-
This package reproduces the full analysis and assembles figures/tables for submission.
|
| 333 |
-
|
| 334 |
-
---
|
| 335 |
-
|
| 336 |
-
## 🚀 Quick Start
|
| 337 |
-
```bash
|
| 338 |
-
pip install -r requirements.txt
|
| 339 |
-
# Re-generate figures and tables (Sections 2–7):
|
| 340 |
-
jupyter nbconvert --to notebook --execute notebooks/main.ipynb
|
| 341 |
-
```
|
| 342 |
-
|
| 343 |
-
Outputs are written to `results/` and tracked in `package/figure_map.csv`.
|
| 344 |
-
|
| 345 |
-
---
|
| 346 |
-
|
| 347 |
-
## 📌 Headline Results (auto-filled)
|
| 348 |
-
- **Section 2 – Atlas:** AUPRC **{auprc}**, AUROC **{auroc}** under cold splits.
|
| 349 |
-
- **Section 3 – Causal ranking:** top resilience drivers include **{top_causal}**.
|
| 350 |
-
- **Section 4 – Active learning:** mean efficiency gain over random **{gain}**.
|
| 351 |
-
- **Section 5 – Stress transfer:** train on ethanol → measurable generalization to oxidative/osmotic.
|
| 352 |
-
- **Section 6 – Validation:** literature cross-check concordant for **PDR5, YOR1, ATM1**; SNQ2 shows context-dependent sign.
|
| 353 |
-
|
| 354 |
-
See `results/claims_table.csv` for full numeric statements and CIs.
|
| 355 |
-
|
| 356 |
-
---
|
| 357 |
-
|
| 358 |
-
## 📊 Figure & Table Guide
|
| 359 |
-
- S2: `results/pr_curves_random.png`, `results/calibration_curves.png`
|
| 360 |
-
- S3: `results/causal_section3_waterfall.png`, `results/causal_section3_stress_heatmap.png`
|
| 361 |
-
- S4: `results/al_section4_efficiency_curve.png`, `results/al_section4_gain_bars.png`
|
| 362 |
-
- S5: `results/transfer_train_ethanol_test_oxidative.png`
|
| 363 |
-
- S6: `results/validation_lit_crosscheck.csv`, `results/validation_external_heatmap.png`
|
| 364 |
-
- WOW: `results/fig_ct_map.png`, `results/fig_SIMS_waterfall.png`
|
| 365 |
-
|
| 366 |
-
For an audited file list with MD5 checksums, see `package/figure_map.csv`.
|
| 367 |
-
|
| 368 |
-
---
|
| 369 |
-
|
| 370 |
-
## 📂 Data (processed)
|
| 371 |
-
- `data/processed/protein.csv` – 30–38 ABC transporters (ESM-2 embeddings)
|
| 372 |
-
- `data/processed/ligand.csv` – ~600 compounds (ChemBERTa embeddings + provenance)
|
| 373 |
-
- `data/processed/labels.csv` – ~8–9k protein×ligand binary interactions with assay provenance
|
| 374 |
-
- `data/processed/causal_table.csv` – ~6k stress/regulator outcomes for causal estimation
|
| 375 |
-
|
| 376 |
-
---
|
| 377 |
-
|
| 378 |
-
## 🔁 Reproducibility
|
| 379 |
-
- Seeds, splits, and estimator configs saved in `results/*snapshot*.json`.
|
| 380 |
-
- `package/figure_map.csv` contains MD5 checksums for every artifact in `results/`.
|
| 381 |
-
- Environment pins in `requirements.txt` (lock exact versions on request).
|
| 382 |
-
|
| 383 |
-
---
|
| 384 |
-
|
| 385 |
-
## ⚖️ Limitations
|
| 386 |
-
Ligand diversity (~600) is narrower than industrial libraries; causal signs can be stress-specific; transfer is preliminary; wet-lab validation is recommended.
|
| 387 |
-
|
| 388 |
-
---
|
| 389 |
-
|
| 390 |
-
## 🤝 Contributions
|
| 391 |
-
- Concept & design: …
|
| 392 |
-
- Data curation: …
|
| 393 |
-
- Modeling & analysis: …
|
| 394 |
-
- Writing: …
|
| 395 |
-
|
| 396 |
-
---
|
| 397 |
-
|
| 398 |
-
## 📜 Citation
|
| 399 |
-
See `CITATION.cff`. A DOI will be minted via Zenodo upon release.
|
| 400 |
-
|
| 401 |
-
*Generated on {date}.*
|
| 402 |
-
""").strip().format(
|
| 403 |
-
auprc=headline_auprc,
|
| 404 |
-
auroc=headline_auroc,
|
| 405 |
-
top_causal=top_causal,
|
| 406 |
-
gain=al_gain,
|
| 407 |
-
date=today
|
| 408 |
-
)
|
| 409 |
-
|
| 410 |
-
(PKG/"README.md").write_text(readme)
|
| 411 |
-
print("✅ Wrote:", PKG/"README.md")
|
| 412 |
-
|
| 413 |
-
|
| 414 |
-
|
| 415 |
-
from pathlib import Path
|
| 416 |
-
import shutil, os
|
| 417 |
-
|
| 418 |
-
PKG = Path("package")
|
| 419 |
-
RES = Path("results")
|
| 420 |
-
|
| 421 |
-
zip_name = RES/"wow_camera_ready.zip"
|
| 422 |
-
if zip_name.exists():
|
| 423 |
-
zip_name.unlink()
|
| 424 |
-
|
| 425 |
-
# Make sure package exists and has content
|
| 426 |
-
assert PKG.exists() and any(PKG.iterdir()), "Package folder is empty; run the previous cell first."
|
| 427 |
-
|
| 428 |
-
shutil.make_archive(base_name=str(zip_name.with_suffix('')), format="zip", root_dir=str(PKG))
|
| 429 |
-
print(" Built:", zip_name, "| size:", os.path.getsize(zip_name), "bytes")
|
| 430 |
-
|
| 431 |
-
# Quick listing
|
| 432 |
-
import zipfile
|
| 433 |
-
with zipfile.ZipFile(zip_name, "r") as z:
|
| 434 |
-
names = z.namelist()
|
| 435 |
-
print(f"ZIP contains {len(names)} files; preview:")
|
| 436 |
-
for n in names[:20]:
|
| 437 |
-
print(" -", n)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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