OpenIslet

scripts/extract_ring1_corpus.py

Step 5B (v0.3 Deep Quantitative & Canonical Graph Upgrade):

script Release v0.8.0 gen-eb955f8266035aba 296 KB · 22 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/extract_ring1_corpus.py · SHA-256: eee6ac565ed0fb16…

    elif pmid == "40544428":
        # Reichman TW et al., N Engl J Med 2025 (Zimislecel / VX-880; NCT04786262)
        record["study_metadata"]["nct_id"] = "NCT04786262"
        for arm in arms:
            g1 = arm["gate1_substrate_and_differentiation"]
            g1["cell_source_class"] = "hESC"
            g1["cell_line_id"] = (
                "Undisclosed proprietary hESC line (zimislecel / VX-880; USAN-documented hESC origin)"
            )
            g1["protocol_backbone"] = (
                "Allogeneic human embryonic stem-cell-derived fully differentiated islet therapy "
                "(zimislecel / VX-880; embryonic stem-cell origin documented in USAN name statement, "
                "exact proprietary line undisclosed; absent from PubMed abstract)"
            )
            g1["canonical_differentiation_stage_evaluated"] = "InVivo_Engrafted_Maturation"
            g5 = arm["gate5_engraftment_niche"]
            g5["transplant_site"] = "Portal_Vein_Intrahepatic"
            g5["oxygen_bridge_72h_carrier"] = "None"
            g5["systemic_immunosuppression_regimen"] = (
                "Glucocorticoid-free systemic immunosuppressive therapy "
                "(Reichman et al. NEJM 2025 abstract, NCT04786262)"
            )
        for eff in effects:
            eid = eff.get("effect_id")
            eff["focal_factor_X"] = "Zimislecel_Portal_Infusion_Under_GlucocorticoidFree_Systemic_IS"
            eff["outcome_domain"] = "InVivo_Glycemic_Cure_and_Graft_Longevity"
            eff["conditioning_context_Z"]["Z1_developmental_stage_and_timing"] = "InVivo_Engrafted_Maturation"
            eff["conditioning_context_Z"]["Z2_genetic_background_and_allelic_dose"] = "hESC"
            eff["conditioning_context_Z"]["Z6_microenvironment_oxygen_and_vascular_niche"] = "Portal_Vein_Intrahepatic"
            if eid == "pmid40544428_eff1":
                eff["outcome_variable_Y"] = (
                    "[Endpoint: Part C primary efficacy endpoint specification] "
                    "Freedom from severe hypoglycemic events (days 90-365) with HbA1c <7% or "
                    ">=1 percentage-point reduction (days 180-365)"
                )
                eff["effect_direction"] = "Neutral_or_NonInferior"
                eff["conditioning_context_Z"]["Z3_immune_effector_and_stressor_pathway"] = "InVivo_Glycemic_Cure_and_Graft_Longevity"
            elif eid == "pmid40544428_eff2":
                # Transparent clinical safety/mortality attribution (never Differentiation_Yield_and_Lineage_Purity)
                eff["outcome_variable_Y"] = (
                    "[Endpoint: Clinical safety and all-cause mortality adverse events] "
                    "Two participant deaths occurred (one cryptococcal meningitis under systemic "
                    "immunosuppression; one progression of preexisting neurocognitive impairment; "
                    "clinical safety observation, not differentiation yield)"
                )
                eff["effect_direction"] = "Deleterious_or_Impaired"
                eff["conditioning_context_Z"]["Z3_immune_effector_and_stressor_pathway"] = (
                    "Clinical_Safety_and_Systemic_Immunosuppression_Mortality_Observation"
                )
            elif eid == "pmid40544428_eff3":
                eff["outcome_variable_Y"] = (
                    "[Endpoint: Glycemic control and SHE freedom (Parts B and C)] "
                    "All 12 full-dose recipients free of severe hypoglycemic events with HbA1c <7% "
                    "and TIR >70% (70-180 mg/dL)"
                )
                eff["effect_direction"] = "Protective_or_Improved"
                eff["conditioning_context_Z"]["Z3_immune_effector_and_stressor_pathway"] = "InVivo_Glycemic_Cure_and_Graft_Longevity"
            elif eid == "pmid40544428_eff4":
                eff["outcome_variable_Y"] = (
                    "[Endpoint: Exogenous insulin independence at day 365] "
                    "10 of 12 full-dose recipients (83%) insulin-independent without exogenous insulin at day 365"
                )
                eff["effect_direction"] = "Protective_or_Improved"
                eff["conditioning_context_Z"]["Z3_immune_effector_and_stressor_pathway"] = "InVivo_Glycemic_Cure_and_Graft_Longevity"
            _populate_effect_provenance(eff, dossier, dossier_sha, "Portal_Vein_Intrahepatic")
            if eid == "pmid40544428_eff2":
                eff["contrast_metadata"]["endpoint_name"] = "Clinical_Safety_and_Mortality_Adverse_Events"
            elif eid == "pmid40544428_eff4":
                eff["contrast_metadata"]["timepoint"] = "day 365"
            eff["contrast_metadata"]["population_or_model"] = "hESC (Tier_1_Human_InVivo)"
            eff["direction_adjudication_method"] = "source_adjudicated_curated_override"

    elif pmid == "37040771":
        # Zhu H et al., Dev Cell 2023 (PMC10175223; STAR Methods names H1/WA01 across multiple stages + primary human donor pancreas)
        for arm in arms:
            arm["arm_label"] = (
                "Multi-stage hESC (H1/WA01) in vitro SC-islet differentiation with primary childhood "
                "and adult human donor pancreas comparisons in Zhu H (2023) "
                "[STAR Methods PMC10175223, absent from PubMed abstract: H1/WA01 line across multiple stages]"
            )
            g1 = arm["gate1_substrate_and_differentiation"]
            g1["cell_source_class"] = "hESC"
            g1["cell_line_id"] = "H1/WA01"
            g1["canonical_differentiation_stage_evaluated"] = None
            g1["protocol_backbone"] = (
                "Multi-stage in vitro hESC (H1/WA01) pancreatic islet differentiation single-cell multiome "
                "compared with primary childhood and adult human pancreas donors "
                "[STAR Methods PMC10175223, DOI:10.1016/j.devcel.2023.03.011, absent from PubMed abstract]"
            )
        for eff in effects:
            eff["conditioning_context_Z"]["Z1_developmental_stage_and_timing"] = (
                "Multi-stage in vitro hESC (H1/WA01) differentiation plus primary childhood and adult human pancreas comparisons"
            )
            eff["conditioning_context_Z"]["Z2_genetic_background_and_allelic_dose"] = "hESC"
            if isinstance(eff.get("contrast_metadata"), dict):
                eff["contrast_metadata"]["population_or_model"] = (
                    "hESC (H1/WA01 multi-stage differentiation plus primary human donor pancreas comparison; "
                    "Tier_3_Human_Cells_AbioticStress_or_ImmunodeficientMouse)"
                )

    elif pmid == "40700651":
        # O'Brien S et al., ACS Biomater Sci Eng 2025 (Methods section 2.3 names WA01/H1 hESC line)
        for arm in arms:
            g1 = arm["gate1_substrate_and_differentiation"]
            g1["cell_source_class"] = "hESC"
            g1["cell_line_id"] = "WA01/H1"
            g1["protocol_backbone"] = (
                "Micropocket polyacrylamide hydrogel SC-islet differentiation from WA01/H1 hESCs "
                "[full text Methods section 2.3, DOI:10.1021/acsbiomaterials.5c00372, absent from PubMed abstract]"
            )

    elif pmid == "37809993":
        # Yabe SG et al., Heliyon 2023 (Methods identifies TkDN4-M: 4M hiPSC line; donor health provenance noted)
        for arm in arms:
            g1 = arm["gate1_substrate_and_differentiation"]
            g1["cell_source_class"] = "iPSC_healthy_donor"
            g1["cell_line_id"] = "TkDN4-M"
            g1["protocol_backbone"] = (
                "6-stage differentiation of human iPS cell line TkDN4-M (4M; Methods identifies line "
                "from IMSUT University of Tokyo, with donor health status requiring separate line-registry provenance)"
            )

    elif pmid == "42182975":
        # Krishnan SR et al., Device 2026 (PMC13196877; Abstract_Only multi-model summary; cross-reference CEG R1_0378)
        for arm in arms:
            arm["arm_label"] = (
                "Active wireless O2-Macrodevice multi-model summary arm (mouse, rat, human SC-islet, NHP; "
                "Abstract_Only) in Krishnan SR (2026) [unoxygenated comparator controls separated in full text; "
                "cross-reference CEG R1_0378 for arm-level model and control scope]"
            )

    elif pmid == "40320524":
        # Traini L et al., Stem Cell Res Ther 2025 (PMC12051322; Alt-R CRISPR-Cas12a [Cpf1] TXNIP exon-3 KO; renal subcapsular kidney-capsule NOD-SCID graft)
        for arm in arms:
            for ed in arm.get("gate2_3_4_genetic_and_epitope_edits", []):
                if ed.get("gene_symbol_hgnc") == "TXNIP" and ed.get("edit_modality") == "CRISPR_Cas9_KO":
                    ed["edit_modality"] = "CRISPR_Cas12a_Multiplex_KO"
            g5_403 = arm.get("gate5_engraftment_niche")
            if isinstance(g5_403, dict) and g5_403.get("transplant_site") == "Intramuscular_Forearm_or_Rectus":
                g5_403["transplant_site"] = "Kidney_Capsule"
        for eff in effects:
            if isinstance(eff.get("focal_factor_X"), str):
                eff["focal_factor_X"] = eff["focal_factor_X"].replace("CRISPR_Cas9_KO", "CRISPR_Cas12a_Multiplex_KO")
            cm_403 = eff.get("contrast_metadata")
            if isinstance(cm_403, dict) and isinstance(cm_403.get("intervention_label"), str):
                cm_403["intervention_label"] = cm_403["intervention_label"].replace("CRISPR_Cas9_KO", "CRISPR_Cas12a_Multiplex_KO")
            cz_403 = eff.get("conditioning_context_Z")
            if isinstance(cz_403, dict) and cz_403.get("Z6_microenvironment_oxygen_and_vascular_niche") == "Intramuscular_Forearm_or_Rectus":
                cz_403["Z6_microenvironment_oxygen_and_vascular_niche"] = "Kidney_Capsule"
        for mod_403 in record.get("effect_modifier_interactions") or []:
            if isinstance(mod_403.get("focal_factor_X"), str):
                mod_403["focal_factor_X"] = mod_403["focal_factor_X"].replace("CRISPR_Cas9_KO", "CRISPR_Cas12a_Multiplex_KO")
        bridges_403 = record.get("cross_study_discovery_bridges") or {}
        for rv_403 in bridges_403.get("residual_failure_and_escape_vectors") or []:
            if isinstance(rv_403.get("arm_or_intervention"), str):
                rv_403["arm_or_intervention"] = rv_403["arm_or_intervention"].replace("CRISPR_Cas9_KO", "CRISPR_Cas12a_Multiplex_KO")


def infer_cell_source_and_stage(
    full_text: str, mesh_terms: list[str] | None = None, title: str = "", pmid: str = ""
) -> tuple[str, str | None, str | None]:
    tl = full_text.lower()
    mesh_lower = " ".join(mesh_terms or []).lower()
    tl_unnegated = re.sub(
        r"\b(?:no|without|lacking|neither|non[- ])\s*human\s+(?:pancreatic\s+|donor\s+|cadaveric\s+)?(?:islets?|beta[- ]cells?|β[- ]cells?|cells?|donors?|patients?|primates?)\b",
        " ",
        tl,
    )
    tl_substrate = re.sub(
        r"\bhuman\s+(?:t\s+cells?|cd[48]\+?\s*t\s+cells?|nk\s+cells?|pbmcs?|peripheral\s+blood|lymphocytes?|monocytes?|macrophages?|serum|autoantibodies|antibodies|complement|leukocytes?|immune\s+cells?|effectors?|cytotoxic\s+t)\b",
        " ",
        tl_unnegated,
    )
    has_nhp = bool(re.search(r"\b(?:cynomolgus|macaque|rhesus|baboon|non[- ]?human\s+primates?|nhp)\b", tl))
    has_xeno_islet = bool(
        re.search(
            r"\b(?:porcine|pig|pigs|swine|bovine|canine|ovine|xenogeneic)\s+(?:pancreatic\s+|donor\s+|neonatal\s+|fetal\s+|adult\s+)?(?:islets?|beta[- ]cells?|β[- ]cells?)\b",
            tl,
        )
    )
    has_human = bool(
        re.search(
            r"(?<!non-)(?<!non\s)(?<!no\s)\b(?:humans?|patients?|cadaveric|donors?\s+with\s+t1d|hescs?|hipscs?|ipscs?|sc-islets?|sc-beta|endoc)\b",
            tl_substrate,
        )
        or ("humans" in mesh_lower)
    )
    has_rodent = bool(
        re.search(r"\b(?:mouse|mice|murine|rat|rats|rodent|nod\b|c57bl|balb/c|akita|stz-induced\s+diabetic\s+mice)\b", tl)
        or (any(m in mesh_lower for m in ("mice", "rats", "rodentia")) and "humans" not in mesh_lower)
    )
    has_islet_or_beta = bool(
        re.search(
            r"\b(?:islets?|beta[- ]cells?|β[- ]cells?|pancreatic\s+endocrine|insulin-producing\s+cells?|sc-islets?|sc-beta)\b",
            tl,
        )
        or ("islets of langerhans" in mesh_lower)
    )
    has_explicit_human_islet = bool(
        re.search(
            r"(?<!non-)(?<!non\s)(?<!no\s)\b(?:human\s+(?:pancreatic\s+|donor\s+|cadaveric\s+)?islets?|cadaveric\s+(?:human\s+|donor\s+)?islets?|islets?\s+(?:isolated\s+)?from\s+human|human\s+(?:beta|β)[- ]cells?)\b",
            tl_unnegated,
        )
    )

    if "cipsc" in tl or "chemically induced pluripotent" in tl:
        source_class = "CiPSC_chemically_induced"
    elif ("t1d" in tl or "type 1 diabet" in tl) and ("patient-derived ipsc" in tl or "t1d ipsc" in tl or "t1d-ipsc" in tl):
        source_class = "iPSC_T1D_or_LADA_patient"
    elif re.search(r"\b(?:ipscs?|hipscs?|induced\s+pluripotent)\b", tl):
        source_class = "iPSC_healthy_donor"
    elif (
        re.search(r"\b(?:hescs?|human\s+embryonic\s+stem|embryonic\s+stem\s+cells?|esc-derived|hues8|wa01|mel1|cyt49)\b", tl)
        or bool(re.search(r"\b(?:h1\s+hescs?|h1\s+escs?|h1\s+cells?|h1\s+line)\b", tl))
    ) and not re.search(r"embryonic\s+stem\s+cells?\s+were\s+not\s+used|without\s+embryonic\s+stem\s+cells?", tl):
        source_class = "hESC"
    elif any(k in tl for k in ("endoc-b", "endoc-β", "endoc_b", "endocbh")):
        source_class = "EndoC_betaH1_or_H2_H3"
    elif re.search(r"\b(?:nit-1|min6|ins-1e?)\b", tl):
        source_class = "Rodent_Beta_Cell_Line_NIT1_MIN6_INS1"
    elif has_explicit_human_islet:
        source_class = "Primary_Human_Islet"
    elif has_nhp and has_islet_or_beta and not has_explicit_human_islet:
        source_class = "NHP_Primary_Islet"
    elif has_xeno_islet and not has_explicit_human_islet:
        source_class = "Unspecified_In_Source_Abstract"
    elif has_islet_or_beta:
        if has_rodent and not has_human:
            source_class = "Rodent_Primary_Islet"
        elif has_human and not has_rodent:
            source_class = "Primary_Human_Islet"
        elif has_rodent and has_human:
            # Mixed human/rodent mention without explicit human islet phrase: check whether rodent islet or human islet is primary
            if re.search(r"\b(?:mouse|mice|murine|rat|rodent)\s+(?:pancreatic\s+|donor\s+)?islets?\b", tl):
                source_class = "Rodent_Primary_Islet"
            else:
                source_class = "Unspecified_In_Source_Abstract"
        else:
            source_class = "Unspecified_In_Source_Abstract"
    else:
        source_class = "Unspecified_In_Source_Abstract"

    cell_line = None
    if source_class in ("hESC", "iPSC_healthy_donor", "iPSC_T1D_or_LADA_patient", "CiPSC_chemically_induced"):
        for cl, pat in (
            ("HUES8", r"\bhues-?8\b"),
            ("WA01", r"\bwa01\b"),
            ("H1", r"\b(?:h1\s+hescs?|h1\s+escs?|h1\s+cells?|h1\s+line|h1/h9|h9\s+and\s+h1)\b"),
            ("MEL1", r"\bmel-?1\b"),