scripts/verify_iip0041_clinical_h1_cd64t_siglec.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0041_clinical_h1_cd64t_siglec.py · SHA-256: f004cf6d8259b8b4…
"attribution_decomposition_and_disclosures": {
"core_3arm_h1_only_delta_S0_to_S2a_pp": round(core_h1_only_ex, 4),
"core_3arm_h1_only_delta_S0_to_S2a_exact_pp": round(core_h1_only_ex, 12),
"core_3arm_S0_to_S2a_attribution": (
"100.00% of Core 3-arm S2a's true unrounded +1.1540 pp locked gain (+1.154049955346 pp exact; "
"50.7781980352% -> 51.9322479906%, display 50.7782% -> 51.9322%) comes strictly from H1: 88% -> 90% "
"(50.7781980352% * 90/88 = 51.9322479906%); 0.0000 pp comes from ABX_L2_v2_CD64T_IL1RN vs live S0 "
"(its +2.3340 pp value is strictly defensive recovery vs the modeled unfixed S1b c3=85% downside 49.5982% -> 51.9322%)."
),
"five_arm_abx_cd64t_recovery_S1b_to_S2a_W_U3_pp": round(wu3_rec_ex, 4),
"five_arm_abx_cd64t_recovery_S1b_to_S2a_W_U3_exact_pp": round(wu3_rec_ex, 10),
"five_arm_abx_cd64t_recovery_S1b_to_S2a_W_U4_pp": round(wu4_rec_ex, 4),
"five_arm_abx_cd64t_recovery_S1b_to_S2a_W_U4_exact_pp": round(wu4_rec_ex, 10),
"five_arm_portfolio_wide_shock_S1c_to_S2a_W_U3_pp": round(wu3_s1c_ex, 4),
"five_arm_portfolio_wide_shock_S1c_to_S2a_W_U3_exact_pp": round(wu3_s1c_ex, 10),
"five_arm_attribution_note": (
"Computed on unrounded exact probabilities BEFORE display rounding: on 5-arm W_U3, co-primary ABX_L2_v2_CD64T_IL1RN alone "
"recovers +0.6033 pp locked (+0.6033300593 pp exact; S1b -> S2a; W_U4: +0.5938 pp exact +0.5938006279 pp) against the A/B/X-only IgG gap. "
"The larger +2.7844 pp delta (S1c -> S2a: +2.7843979952 pp exact) is a counterfactual parameter change reflecting a portfolio-wide c3=85% IgM/Ab shock "
"hitting ALL 5 arms; mitigating it via CD46_WT is explicitly ARCHIVED as HOLD-comparator outside Wave-5 Go scope until CAND-034's executable "
"cd46_tropic_addendum clears (zero circular gate reference)."
),
"judgemental_sensitivity_parameters_disclosure": (
"Both c3 = 0.85 (-4 pp autoAb shock) and S2c p3 = [0.62, 0.68, 0.78] are speculative uncalibrated judgemental sensitivity scenarios — "
"NOT empirically parameterized from Gu 2021's 23.6% new-onset ZnT8ecA seroprevalence (endogenous long-standing T1D titer distribution and "
"Channel-(b) fraction of H3 failure remain unquantified)."
),
"shock_law_conditioning_disclosure": (
"In asymmetric scenarios S1a/S1b (c3_abx = 0.85, c3_y = 0.89), attribution is conditional on the assumed nested shock law (where Y's H3 survival "
"is conditionally independent of the A/B/X-only shock given U_y = 1, u_y3 = 89.89%). Holding arm marginals and the incumbent law fixed while sweeping "
"feasible Y survival within the shared H3 shock moves W_U3 recovery across [+0.4977, +1.5440] pp and W_U4 across [+0.4605, +1.7828] pp; "
"these numbers evaluate parameter counterfactuals and do not measure experimentally proven construct protection."
),
},
"core_3arm_2pow12_scenarios": core_3arm_scenarios,
"five_arm_2pow20_registered_route_only_scenarios": five_arm_scenarios,
}
# =============================================================================
# PART E — 100% LIVE NCBI E-UTILITIES + EUROPE PMC PMID VERIFICATION RECEIPT
# =============================================================================
ALL_EXP028_PMIDS = [
# Part A — Clinical H1 SC-islet cohorts
"40544428", # Reichman et al. NEJM 2025 (zimislecel/VX-880)
"39326417", # Wang et al. Cell 2024 (autologous CiPSC under rectus sheath, prior liver tx tacrolimus)
"41765034", # Shi et al. Lancet Diabetes Endocrinol Apr 2026 (Letter, 0 abs chars)
"38684699", # Wu et al. Cell Discov 2024 (autologous E-islet T2D)
"40757665", # Carlsson et al. NEJM 2025 (UP421 HIP B2M-/- CIITA-/- CD47+ human sentinel)
"42430558", # Carlsson et al. NEJM 2026 (UP421 14-month sentinel)
# Part B — Autoantibody gap, CD64t, IL1RN, CD46, CFH, GY-026 CR1 & iCasp9
"42392079", # Deuse & Schrepfer Cell Rep Med Oct 2026 (Review, anti-ZnT8/TSPAN7)
"36593395", # Gravina et al. Nat Biotechnol 2023 (CD64t[1-313] shields against IgG ADCC/CDC)
"41543848", # Gou et al. Xenotransplantation 2026 (hCD64 blocks IgG CDC/ADCC, NOT IgM)
"34130115", # Gu et al. J Autoimmun 2021 (ZnT8ecA 74/313=23.6%, earliest IAb 10/10, binds beta-cell surface)
"18023480", # Beekman et al. Mol Immunol 2008 (Protein 4.1G/EPB41L2 binds Fc gamma RI cytoplasmic tail)
"10480601", # Giannoukakis et al. Diabetes 1999 (IL-1Ra gene transfer to human islets prevents IL-1beta GSIS loss & Fas apoptosis)
"28092375", # Dror et al. Nat Immunol 2017 (postprandial macrophage IL-1beta stimulates physiological insulin secretion)
"28494868", # Garcia-Diaz et al. Cell Rep 2017 (IFN-gamma-JAK1/2-STAT1/2/3-IRF1 regulates CD274/PD-L1 promoter)
"2139669", # Arend et al. J Clin Invest 1990 (IL-1Ra requires up to 100-fold molar excess over IL-1 for 50% inhibition)
"40812299", # Hu et al. Cell Stem Cell 2025 (already in live Ring-1; CD64t / HIP context)
"23416052", # Ogembo et al. Cell Rep 2013 (CR1 is EBV gp350 receptor — GY-026)
"20855594", # Tham et al. PNAS 2010 (CR1 is P. falciparum PfRh4 receptor — GY-026)
"27013439", # Forneris et al. EMBO J 2016 (PDB 5FO8 CD46 / 5FO9 CR1 C3b complement structures)
"25925696", # Kiyoshi et al. Nat Commun 2015 (PDB 4W4O FcgammaRI-IgG1 Fc)
"25561553", # Lu et al. PNAS 2015 (PDB 4X4M FcgammaRI-IgG1 Fc glycan pocket)
"9062194", # Schreuder et al. Nature 1997 (PDB 1IRA IL1RN-IL1R1 crystal structure)
"22047558", # Di Stasi et al. NEJM 2011 (iCasp9 / AP1903 clinical safety switch)
"21813778", # Westwell-Roper et al. J Immunol 2011 (hIAPP-macrophage IL-1beta)
"24222351", # Westwell-Roper et al. Diabetes 2014 (islet resident macrophage IL-1beta)
# Part C — Zero-edit Siglec-7/-9 glycoengineering vs genetic ST6GAL1 PDAC hazard
"42875686", # Rana et al. Adv Sci Oct 2026 (luminal Siglec-7/-9 LQS8% glycoengineering)
"37643018", # Bhalerao et al. JCI Insight 2023 (ST6GAL1 drives ADM & accelerates PDAC survival collapse)
]
def _urlopen_with_retry(url: str, *, timeout: int = 45, attempts: int = 3) -> bytes:
last_err: Exception | None = None
for attempt in range(attempts):
try:
return urllib.request.urlopen(
urllib.request.Request(url, headers={"User-Agent": "OpenIslet-EXP028/1.0"}),
timeout=timeout,
).read()
except Exception as exc:
last_err = exc
time.sleep(1.5 * (attempt + 1))
raise RuntimeError(f"Failed to fetch {url} after {attempts} attempts: {last_err}")
def fetch_live_pubmed_and_epmc(pmids: list[str]) -> dict[str, dict[str, Any]]:
ids_csv = ",".join(pmids)
# 1. NCBI E-utilities esummary.fcgi (JSON)
esum_url = f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=pubmed&id={ids_csv}&retmode=json"
esum_raw = _urlopen_with_retry(esum_url)
esum_json = json.loads(esum_raw.decode("utf-8"))["result"]
time.sleep(0.35)
# 2. NCBI E-utilities efetch.fcgi (XML — full abstract, DOI, PMCID, pub types, retraction flags)
efetch_url = f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pubmed&id={ids_csv}&retmode=xml"
efetch_xml = _urlopen_with_retry(efetch_url)
root = ET.fromstring(efetch_xml)
records: dict[str, dict[str, Any]] = {}
for art in root.findall(".//PubmedArticle"):
pmid = art.findtext(".//MedlineCitation/PMID") or ""
title_el = art.find(".//ArticleTitle")
title = "".join(title_el.itertext()).strip() if title_el is not None else ""
journal = art.findtext(".//Journal/ISOAbbreviation") or art.findtext(".//Journal/Title") or ""
year = (
art.findtext(".//JournalIssue/PubDate/Year")
or art.findtext(".//JournalIssue/PubDate/MedlineDate")
or ""
)
m_yr = re.search(r"(19|20)\d{2}", year)
pub_year = int(m_yr.group(0)) if m_yr else None
authors = []
for au in art.findall(".//AuthorList/Author"):
ln = au.findtext("LastName")
ini = au.findtext("Initials")
coll = au.findtext("CollectiveName")
if ln:
authors.append(f"{ln} {ini}".strip() if ini else ln)
elif coll:
authors.append(coll)
abs_parts = ["".join(ab.itertext()).strip() for ab in art.findall(".//Abstract/AbstractText")]
abstract = " ".join(p for p in abs_parts if p)
pub_types = [pt.text.strip() for pt in art.findall(".//PublicationTypeList/PublicationType") if pt.text]
doi, pmcid = None, None
for aid in art.findall(".//PubmedData/ArticleIdList/ArticleId"):
idtype = aid.attrib.get("IdType")
if idtype == "doi" and aid.text:
doi = aid.text.strip()
elif idtype == "pmc" and aid.text:
pmcid = aid.text.strip()
retracted = any("retracted" in pt.lower() or "retraction of" in pt.lower() for pt in pub_types)
esum_rec = esum_json.get(pmid, {})
records[pmid] = {
"pmid": pmid,
"pmcid": pmcid,
"doi": doi,
"pub_year": pub_year,
"pubdate_esummary": esum_rec.get("pubdate"),
"journal": journal,
"first_author": authors[0] if authors else None,
"senior_author": authors[-1] if authors else None,
"authors_count": len(authors),
"title": title,
"abstract": abstract,
"abstract_chars": len(abstract),
"publication_types": pub_types,
"retracted": retracted,
"esummary_verified": pmid in esum_json and "error" not in esum_rec,
"epmc_is_open_access": None,
"epmc_oa_license": None,
}
# 3. Europe PMC OA / license batch lookup
epmc_q = " OR ".join(f"EXT_ID:{p}" for p in pmids)
epmc_url = (
"https://www.ebi.ac.uk/europepmc/webservices/rest/search?"
+ urllib.parse.urlencode({"query": epmc_q, "format": "json", "resultType": "core", "pageSize": len(pmids) + 5})
)
epmc_raw = _urlopen_with_retry(epmc_url)
for res in json.loads(epmc_raw.decode("utf-8")).get("resultList", {}).get("result", []):
pm = str(res.get("pmid") or "")
if pm in records:
records[pm]["epmc_is_open_access"] = res.get("isOpenAccess")
lic = None
ft_list = (res.get("fullTextUrlList") or {}).get("fullTextUrl") or []
if res.get("license"):
lic = str(res["license"])
elif res.get("isOpenAccess") == "Y":
lic = "OA_EPMC"
records[pm]["epmc_oa_license"] = lic
if not records[pm]["pmcid"] and res.get("pmcid"):
records[pm]["pmcid"] = res["pmcid"]
missing = [p for p in pmids if p not in records]
if not (not missing):
raise ValueError(f"Missing PMIDs in live NCBI efetch: {missing}")
if not (all(not r["retracted"] for r in records.values())):
raise ValueError("Retracted PMID encountered!")
return records
def fetch_epmc_fulltext_sections(pmcid: str) -> dict[str, Any]:
urls = [
f"https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?db=pmc&id={pmcid}&retmode=xml",
f"https://www.ebi.ac.uk/europepmc/webservices/rest/{pmcid}/fullTextXML",
]
xml_bytes = None
last_err = None
for url in urls:
for attempt in range(3):
try:
xml_bytes = urllib.request.urlopen(
urllib.request.Request(url, headers={"User-Agent": "OpenIslet-EXP028/1.0"}), timeout=30
).read()
if xml_bytes and b"<body" in xml_bytes:
break
except Exception as exc:
last_err = exc
time.sleep(1.5 * (attempt + 1))
if xml_bytes and b"<body" in xml_bytes:
break
if not xml_bytes:
raise RuntimeError(f"Failed to fetch full-text XML for {pmcid}: {last_err}")
root = ET.fromstring(xml_bytes)
paras: list[str] = []
for sec in root.findall(".//body//sec"):
sec_t = "".join(sec.find("title").itertext()).lower() if sec.find("title") is not None else ""
if any(k in sec_t for k in ("result", "discussion", "finding")):
for p in sec.findall(".//p"):
txt = re.sub(r"\s+", " ", "".join(p.itertext())).strip()
if len(txt) >= 40 and txt not in paras:
paras.append(txt)
figs: list[dict[str, str]] = []
seen_caps: set[str] = set()
for fig in root.findall(".//fig"):
lbl = re.sub(r"\s+", " ", "".join(fig.find("label").itertext())).strip() if fig.find("label") is not None else ""
cap = re.sub(r"\s+", " ", "".join(fig.find("caption").itertext())).strip() if fig.find("caption") is not None else ""
if len(cap) >= 30 and cap not in seen_caps:
seen_caps.add(cap)
figs.append({"label": lbl or f"Figure {len(figs) + 1}", "caption": cap})
return {"results_paragraphs": paras[:120], "methods_paragraphs": [], "figure_legends": figs[:40]}
# =============================================================================
# PART F — WORKFLOW.md §5.6 MULTI-ARM QUANTITATIVE RING-1 + CEG EXTRACTION (G1..G8)
# =============================================================================
def compute_aggregate_verbatim_chars(record_obj: Any, source_text: str, min_run: int = 25) -> dict[str, Any]:
src_norm = re.sub(r"\s+", " ", source_text).strip().lower()
exempt = {
"pmid", "pmcid", "doi", "citation_short", "title", "journal",
"schema_version", "study", "dossier_sha256", "first_author", "senior_author",
}
max_single, max_field = 0, ""
intervals: list[tuple[int, int]] = []
for fpath, val in walk_strings(record_obj):
leaf = fpath.split(".")[-1].split("[")[0]
if leaf in exempt or len(val) < min_run or pep.is_redaction_token_prefix(val):
continue
sh = int(grm._max_verbatim_shingle_chars(val, source_text))
if sh > max_single:
max_single, max_field = sh, fpath
if sh >= min_run:
v_norm = re.sub(r"\s+", " ", val).strip().lower()
i = 0
while i <= len(v_norm) - min_run: