OpenIslet

scripts/verify_iip0056_route4_omentum_and_exvivo_rest.py

OpenIslet Wave-6 Round-14 Prospective Candidate W6-C2 (Staged Slot IIP-0047 -> Provisional

script Release v0.8.0 gen-eb955f8266035aba 466 KB · 37 sections

Use this file in any AI chat (paste-only or attachment-capable):

Download as text (.txt) Download section (.txt)

Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0056_route4_omentum_and_exvivo_rest.py · SHA-256: 25e12d578ba80b55…

    def rem(t: float) -> float:
        s = 0.0
        pref = (math.pi ** 2) * d_cm2_s * t / (4.0 * half_thickness_cm ** 2)
        for k in range(n_modes):
            odd = 2 * k + 1
            e = pref * odd * odd
            if e > 700.0:
                break
            s += math.exp(-e) / (odd * odd)
        return (8.0 / (math.pi ** 2)) * s

    out: Dict[str, float] = {}
    for label, target in [("t50_s", 0.50), ("t90_s", 0.10), ("t99_s", 0.01)]:
        lo, hi = 0.0, 1e6
        for _ in range(80):
            mid = 0.5 * (lo + hi)
            if rem(mid) > target:
                lo = mid
            else:
                hi = mid
        out[label] = round(0.5 * (lo + hi), 4)
    return out


def compute_gy014_diazoxide_kill_and_h46_exvivo(c: Dict[str, Any]) -> Dict[str, Any]:
    diff_regimes = [
        ("free_interstitial_5e-6", 5.0e-6),
        ("hindered_hydrogel_2e-6", 2.0e-6),
        ("cellular_retarded_Kp10_3e-7", 3.0e-7),
        ("hydrophobic_PPCN_Kp50_6e-8", 6.0e-8),
    ]
    sphere_65um = {name: _sphere_washout_times(32.5e-4, dval) for name, dval in diff_regimes}
    slab_85um = {name: _slab_washout_times(42.5e-4, dval) for name, dval in diff_regimes}
    slab_120um = {name: _slab_washout_times(60.0e-4, dval) for name, dval in diff_regimes}
    slab_350um = {name: _slab_washout_times(175.0e-4, dval) for name, dval in diff_regimes}

    require_cond(abs(sphere_65um["free_interstitial_5e-6"]["t50_s"] - 0.06453) <= 0.0005, "Bare 65um t50 drift")
    require_cond(abs(sphere_65um["free_interstitial_5e-6"]["t90_s"] - 0.38656) <= 0.001, "Bare 65um t90 drift")
    require_cond(1.40 <= slab_120um["free_interstitial_5e-6"]["t50_s"] <= 1.45, "120um free slab t50 drift")
    require_cond(3.50 <= slab_120um["hindered_hydrogel_2e-6"]["t50_s"] <= 3.58, "120um gel slab t50 drift")

    # Systemic oral Proglycem free plasma PK (90-94% albumin bound -> fu = 0.06..0.10; NO unsubstantiated toxicity multiplier claim)
    ec50, n_h, max_ocr = 35.0, 1.6, 0.30
    ic50_sdh, n_sdh = 400.0, 1.8
    systemic_pk = []
    for total_ug_ml in (10.0, 20.0, 35.0):
        total_uM = (total_ug_ml / 230.68) * 1000.0
        for fu in (0.06, 0.10):
            free_uM = total_uM * fu
            occ = (free_uM ** n_h) / (free_uM ** n_h + ec50 ** n_h)
            systemic_pk.append({
                "total_plasma_ug_mL": total_ug_ml,
                "total_uM": round(total_uM, 2),
                "free_fraction_fu": fu,
                "free_uM": round(free_uM, 2),
                "katp_occupancy_pct": round(100.0 * occ, 2),
                "modeled_max_ocr_cut_at_20mM_glc_pct": round(100.0 * max_ocr * occ, 2),
            })
    req_total_ug_ml_100free = round((100.0 / 0.08) * 230.68 / 1000.0, 1)

    # Single-point parametric ATP illustration anchored ONLY to Grimmsmann & Rustenbeck 1998 (500 uM -> -29% ATP)
    sdh_ref = (500.0 ** n_sdh) / (500.0 ** n_sdh + ic50_sdh ** n_sdh)
    dose_window = []
    for c0 in (50.0, 100.0, 150.0, 325.0, 500.0):
        occ = (c0 ** n_h) / (c0 ** n_h + ec50 ** n_h)
        atp_drop = 29.0 * ((c0 ** n_sdh) / (c0 ** n_sdh + ic50_sdh ** n_sdh)) / sdh_ref
        dose_window.append({
            "diazoxide_uM": c0,
            "katp_occupancy_frac": round(occ, 4),
            "modeled_exvivo_ocr_drop_pct": round(100.0 * max_ocr * occ, 2),
            "parametric_1pt_illustration_atp_drop_pct": round(atp_drop, 2),
            "within_h46_exvivo_prospective_window": bool(100.0 <= c0 <= 150.0),
        })

    wash_dilution_steps = []
    conc = 150.0
    for step in range(0, 4):
        wash_dilution_steps.append({
            "wash_cycle": step,
            "ideal_supernatant_diazoxide_uM": round(conc, 6),
            "below_lcms_loq_0p05uM": bool(conc <= 0.05),
            "below_alpha_glucagon_threshold_30uM": bool(conc < 30.0),
        })
        conc /= 20.0

    # Decoupled Retrievability Burden Audit (NO division of surgical mass fraction into OQ-012 clonogenic regrowth!)
    total_cells = 933_500_000
    f_clon = 1e-4
    retr_audit = {}
    for pct in (85.0, 95.0, 99.0, 99.9):
        rem_frac = 1.0 - pct / 100.0
        retr_audit[f"surgical_mass_recovery_{pct}pct"] = {
            "residual_mass_fraction": round(rem_frac, 6),
            "residual_IEQ_of_500k": round(500_000.0 * rem_frac, 1),
            "residual_living_cells_of_933p5M": int(round(total_cells * rem_frac)),
            "residual_putative_clonogens_at_1e-4": round(total_cells * f_clon * rem_frac, 2),
            "residual_stored_insulin_IU_at_138p3_cap": round(138.3 * rem_frac, 4),
            "sufficient_alone_to_satisfy_oq012_without_switch": False,
        }

    # Needle fluid bleb homogeneous slab O2 collapse (GY-028(3))
    alpha = c["alpha_o2_nominal_mol_cm3_mmhg"]
    d_eff = 1.4e-5
    q_areal_2500 = 2500.0 * c["vol_1_ieq_cm3"] * c["vmax_islet_pure_mol_cm3_s"] * 1.15 * 1.097
    bleb_audit = []
    for h_um in (120.0, 250.0, 400.0):
        h_cm = h_um * 1e-4
        dp_bi = (q_areal_2500 * h_cm) / (8.0 * d_eff * alpha)
        dp_uni = (q_areal_2500 * h_cm) / (2.0 * d_eff * alpha)
        bleb_audit.append({
            "bleb_thickness_um": h_um,
            "loading_ieq_cm2": 2500.0,
            "slab_center_pO2_35mmHg_bilateral_mmhg": round(max(0.0, 35.0 - dp_bi), 2),
            "slab_worst_pO2_35mmHg_unilateral_mmhg": round(max(0.0, 35.0 - dp_uni), 2),
        })

    return {
        "gy014_status": "IN_VIVO_72H_DIAZOXIDE_KILLED_BLOCK",
        "diazoxide_mw_da": 230.68,
        "sphere_65um_bare_cluster_washout": sphere_65um,
        "slab_85um_washout": slab_85um,
        "slab_120um_washout": slab_120um,
        "slab_350um_route1_matches_gy014_7_to_177s": slab_350um,
        "overestimate_factor_vs_3h_bare_65um": round(10800.0 / sphere_65um["free_interstitial_5e-6"]["t50_s"], 1),
        "overestimate_factor_vs_3h_120um_gel": round(10800.0 / slab_120um["hindered_hydrogel_2e-6"]["t50_s"], 1),
        "systemic_oral_proglycem_free_pk": systemic_pk,
        "required_total_plasma_ug_mL_for_100uM_free_at_fu0p08": req_total_ug_ml_100free,
        "systemic_pk_epistemic_note": (
            "Albumin binding (90-94%, fu=0.06-0.10) limits free plasma diazoxide to 2.60-8.67 uM at 10-20 ug/mL total; "
            "reaching 100 uM free requires ~288.4 ug/mL total (14.4-28.8x the 10-20 ug/mL reference plasma concentration range), "
            "with no unsubstantiated human toxicity threshold multiple claimed."
        ),
        "alpha_cell_glucagon_suppression_threshold_uM": 30.0,
        "alpha_cell_glucagon_suppression_pmid": "17503968",
        "exvivo_dose_selectivity_illustration": {
            "model_scope": "SINGLE_POINT_PARAMETRIC_ILLUSTRATION_ANCHORED_TO_GRIMMSMANN_1998_500UM_MINUS_29PCT_ONLY",
            "warning": "Not a multi-point fitted dose-response curve; Stage-0 FCCP maximal reserve measurement (H46E-01) is mandatory.",
            "rows": dose_window,
        },
        "preclinical_evidence_scope_fidelity": {
            "ma_2013_pmid23935835": (
                "40% hypoxic necrosis reduction and preserved post-rest glucose-stimulated OCR are 22 h rat islet endpoints "
                "(where hypoxia-associated apoptosis was observed and not reversed by diazoxide, and residual diazoxide carryover was not ruled out); "
                "the two-preparation human pilot used 22 h / 325 uM; the human-islet xenograft used 48 h / 325 uM with 14-day follow-up in mice."
            ),
            "wang_2020_pmid32433410": (
                "8 h / 150 uM diazoxide preservation of whole NHP donor pancreata during procurement/cold storage, "
                "with functional efficacy assessed after transplantation into diabetic mice."
            ),
            "tudca_pmid20541525_and_pmid24225943": (
                "Porcine (Lee 2010) and mouse (Engin 2013, which carries a published author-spelling correction notice) preclinical anchors; "
                "human SC-islet paired validation remains prospective under H46E-01..04."
            ),
        },
        "h46_exvivo_clinical_protocol": {
            "preconditioning_duration_h": 22.0,
            "diazoxide_uM_range": [100.0, 150.0],
            "tudca_gmp_uM": 250.0,
            "ferrostatin_1_excluded_from_clinical_lead": True,
            "isrib_excluded_from_clinical_lead": True,
            "design_a_strictly_excluded_from_exvivo_rest": True,
            "design_a_preexisting_catalase_hydrogel_exception_disclosed": (
                "Governed v0.8.0 Design A retains its pre-existing passive CaO2-PDMS + >=20 um planar recombinant human P04040 "
                "catalase barrier hydrogel (GY-013 / live GATE-31), with zero additional immobilized cuff proteins, zero soluble biologics, "
                "zero ex-vivo rest, and zero drugs."
            ),
            "eligible_arms_for_optional_exvivo_rest": ["B", "X", "Y", "D", "Z"],
            "min_washout_cycles": 3,
            "lcms_distinct_supernatant_and_pellet_loq_cap_uM": 0.05,
            "day0_invivo_fvm_ocr_credit_pct": 0.0,
            "primary_h4_credit_pp": 0.0,
            "prospective_sensitivity_h4_credit_pp": 1.5,
            "prospective_sensitivity_scope": "All eligible non-A arms (B/X/Y/D/Z) ONLY pending paired H46E-01..04 wet-lab qualification; zero primary portfolio credit.",
            "paired_perioperative_clamp_gate": "R3P-06 (5-day euglycemic insulin clamp 100-180 mg/dL)",
            "ideal_washout_dilution_illustration": wash_dilution_steps,
        },
        "decoupled_retrievability_and_oq012_audit": {
            "epistemic_status": "PROSPECTIVE_STAGE1_ENDPOINT_NOT_YET_ACHIEVED",
            "prospective_stage1_mass_recovery_target_pct": 99.9,
            "oq012_governing_gate": "BLUEPRINT_GATE_5_LONG_HORIZON_CLONOGENIC_ERADICATION (distinct from acute stressed 5-lineage Gate 0V-Kill under GY-030)",
            "three_separate_non_commensurate_endpoints": [
                "1_surgical_mass_recovery_pct (prospective Stage-1 R4O-04 porcine/NHP partial-omentectomy endpoint >= 99.9%)",
                "2_residual_viable_cell_localization_and_burden (histology/bioluminescence/C-peptide extinction; 99.9% still leaves 500 IEQ / 933,500 cells / 93.35 putative clonogens at 1e-4)",
                "3_post_switch_clonogenic_regrowth_oq012 (<= 1e-8 long-horizon pan-lineage clonogenic eradication owned by Blueprint Gate 5, strictly distinct from acute 24-h/72-h stressed 5-lineage Gate 0V-Kill under GY-030 — never divided by surgical mass fraction)",
            ],
            "residual_burden_by_recovery_fraction": retr_audit,
        },
        "needle_bleb_gy028_3_collapse_audit": bleb_audit,
    }


# =============================================================================
# 6. Exact 2^20 Common-Shock Portfolio Engine & Hash-Verified Master Contract Parity (S.2)
# =============================================================================
def biv_bern(p1: float, p2: float, phi: float) -> Dict[Tuple[int, int], float]:
    require_cond(0.0 <= p1 <= 1.0 and 0.0 <= p2 <= 1.0 and 0.0 <= phi <= 1.0, f"Invalid biv_bern inputs: {p1}, {p2}, {phi}")
    p11 = (1.0 - phi) * (p1 * p2) + phi * min(p1, p2)
    out = {
        (0, 0): 1.0 - p1 - p2 + p11,
        (1, 0): p1 - p11,
        (0, 1): p2 - p11,
        (1, 1): p11,
    }
    for k, v in out.items():
        require_cond(v >= -1e-12, f"Negative biv_bern prob {k}={v}")
        out[k] = max(0.0, v)
    require_cond(abs(sum(out.values()) - 1.0) < 1e-12, "biv_bern sum != 1")
    return out


def frechet_joint(probs: Sequence[float], phi: float) -> List[float]:
    m = len(probs)
    require_cond(0.0 <= phi <= 1.0, f"Invalid phi={phi}")
    for p in probs:
        require_cond(0.0 <= p <= 1.0, f"Invalid marginal p={p}")
    n_states = 1 << m
    d_ind = [0.0] * n_states
    for mask in range(n_states):
        w = 1.0
        for i in range(m):
            w *= probs[i] if (mask & (1 << i)) else (1.0 - probs[i])
        d_ind[mask] = w
    if phi == 0.0:
        return d_ind
    order = sorted(range(m), key=lambda i: probs[i])
    d_pos = [0.0] * n_states
    prev = 0.0
    for idx, i in enumerate(order):
        w = probs[i] - prev
        if w > 0.0:
            d_pos[sum(1 << j for j in order[idx:])] += w
        prev = probs[i]
    d_pos[0] += 1.0 - prev
    out = [(1.0 - phi) * d_ind[s] + phi * d_pos[s] for s in range(n_states)]
    require_cond(all(v >= -1e-12 for v in out) and abs(sum(out) - 1.0) < 1e-12, "frechet_joint sum/sign error")
    return [max(0.0, v) for v in out]


def frechet_couple(base_dist: Sequence[float], u_new: float, phi: float, event_fn: Callable[[int], bool]) -> List[float]:
    n0 = len(base_dist)
    require_cond(abs(sum(base_dist) - 1.0) < 1e-12 and 0.0 <= u_new <= 1.0 and 0.0 <= phi <= 1.0, "Invalid frechet_couple args")
    p_e1 = sum(base_dist[mi] for mi in range(n0) if event_fn(mi))
    p_e0 = 1.0 - p_e1
    d_ind = [0.0] * (2 * n0)
    for mi in range(n0):
        w = base_dist[mi]
        d_ind[mi] = w * (1.0 - u_new)
        d_ind[mi | n0] = w * u_new
    d_pos = [0.0] * (2 * n0)
    p11 = min(p_e1, u_new)