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…

        re.search(
            r"\b(ameliorat\w+|preserv\w+|restor\w+|rescu\w+|revers\w+|counteract\w+|prevent\w+|protect\w+)\b(?:(?!(?:\bbut\b|\bhowever\b|\bwhereas\b|\bwhile\b|\balthough\b|\byet\b|\bdespite\b))[^.;]){0,65}\b(impair\w+|decreas\w+|reduc\w+|dedifferentiat\w+|dysfunction)",
            sl,
        )
        or re.search(
            r"\b(impair\w+|decreas\w+|reduc\w+|dedifferentiat\w+|dysfunction)\b(?:(?!(?:\bbut\b|\bhowever\b|\bwhereas\b|\bwhile\b|\balthough\b|\byet\b|\bdespite\b))[^.;]){0,95}\b(?:could\s+be\s+|was\s+|were\s+)(ameliorat\w+|preserv\w+|restor\w+|rescu\w+)\b",
            sl,
        )
        or re.search(
            r"\b(in\s+untreated\s+\w+|in\s+control\s+mice|in\s+diabetic\s+controls?)\b[^.;]*\b(?:whereas|while)\b[^.;]*\b(ameliorat\w+|preserv\w+|restor\w+|rescu\w+|revers\w+|prevent\w+|protect\w+)\b",
            sl,
        )
    )
    is_non_experimental_or_baseline_context = any(
        k in sl
        for k in (
            "we questioned if ",
            "thus, we hypothesized that ",
            "was associated with t2d and reduced insulin secretion",
            "type 2 diabetes (t2d) is associated with defective insulin secretion",
            "which may account for the deficient insulin secretion observed in our mody3 patients",
            "conferring the increased risk of impaired insulin secretion and future risk of t2d",
            "ethical issues still exist",
            "persisted in both wt and rnls ko",
        )
    )

    func_targets_pat = (
        r"(?:gsis|glucose-stimulated\s+insulin\s+secretion|glucose-dependent\s+insulin\s+secretion|"
        r"insulin\s+secretion|insulin\s+release|insulin\s+content|insulin\s+synthesis|"
        r"c-peptide\s+(?:level|secretion|release)|proinsulin\s+cleavage|proinsulin\s+signal|"
        r"(?:β-cell|beta-cell|β\s+cell|beta\s+cell|pancreatic|endocrine|progenitor|sc-islet|pp|ep)\s+(?:differentiation|maturation|commitment|identity|mass|survival|viability|function)|"
        r"differentiation\s+(?:into|of\s+(?:human|pancreatic|functional|β|beta)|efficiency|efficiencies|block)|"
        r"commitment\s+to\s+chga\+|formation\s+of\s+glucose-responsive|"
        r"first-phase\s+glucose-stimulated|peak\s+stimulation|glucose\s+sensing|glucose-sensing|"
        r"cell\s+viability|graft\s+viability|viability\s+compared|viability\s+observed|"
        r"nkx6-1|neurog3|pdx1\s+expression|iapp\s+induction|coordinate\s+function)"
    )
    impair_verbs_pat = r"(?:impair\w+|compromis\w+|blunt\w+|defect\w+|deficien\w+|abolish\w+|diminish\w+|weaker\s+response|absent\s+gsis|poor\s+glucose\s+responsiveness|poor\s+gsis|poor\s+dynamic|suppression\s+of\s+the\s+machinery\s+for\s+glucose-sensing|inhibit\w+(?=\s+(?:gsis|glucose-stimulated\s+insulin\s+secretion|insulin\s+secretion|insulin\s+release)))"
    down_verbs_pat = r"(?:reduc\w+|decreas\w+|lower\w*)"

    has_bound_penalty = False
    if not is_non_experimental_or_baseline_context:
        for clause in re.split(
            r"[.;]|,\s*(?:whereas|while|although|but|however|yet|despite|and\s+was\s+associated|resulting\s+in|as\s+demonstrated\s+by|as\s+indicated\s+by|accompanied\s+by)|\b(?:but|however|whereas|while|although|yet|despite)\b|(?=\bwithout\b)",
            sl,
        ):
            if any(
                neg in clause
                for neg in (
                    "did not ",
                    "does not ",
                    "do not ",
                    "were not ",
                    "was not ",
                    "not impaired",
                    "without ",
                    "with no impact on",
                    "not significantly ",
                    "no significant ",
                    "no reduction in",
                    "no decrease in",
                    "no change in",
                    "no loss of",
                )
            ):
                continue
            if re.search(
                r"\b(ameliorat\w+|preserv\w+|restor\w+|rescu\w+|revers\w+|counteract\w+|prevent\w+|protect\w+)\b[^.;]{0,65}\b(impair\w+|decreas\w+|reduc\w+|dedifferentiat\w+|dysfunction)",
                clause,
            ) or re.search(
                r"\b(impair\w+|decreas\w+|reduc\w+|dedifferentiat\w+|dysfunction)\b[^.;]{0,95}\b(?:could\s+be\s+|was\s+|were\s+)(ameliorat\w+|preserv\w+|restor\w+|rescu\w+)\b",
                clause,
            ) or is_rescue_of_impairment:
                continue
            if "pyruvate" in clause or "basal insulin secretion (2 mmol" in clause:
                continue
            if re.search(
                r"\b(?:reduc\w+|decreas\w+|lower\w*)\s+(?:the\s+)?(?:number\s+of\s+|content\s+ratio\s+of\s+the\s+|expression\s+of\s+)?(?:blood\s+glucose|glucose\s+level|glycemi\w*|hyperglycemi\w*|glycated\s+hemoglobin|hba1c|exogenous\s+insulin|costs?|non-?endocrine|off-target|enterochromaffin|pluripotency|teratoma|proliferation|cytotoxic\w*|susceptibility|cell\s+death|apoptos\w*|hla\s+class|recognition|pyruvate|cellular\s+zinc)",
                clause,
            ):
                continue
            if "associated with increased insulin secretion" in clause or "increasing insulin secretion" in clause or re.search(r"\bcaused\s+mody\d*\b", clause):
                continue
            if re.search(r"\b(?:impair\w+|compromis\w+|blunt\w+|defect\w+|abolish\w+)\s+(?:the\s+)?(?:secretion|differentiation|maturation)\b", clause):
                has_bound_penalty = True
                break
            if re.search(impair_verbs_pat + r"[^,;]{0,45}" + func_targets_pat, clause) or re.search(
                func_targets_pat + r"[^,;]{0,45}" + impair_verbs_pat, clause
            ):
                has_bound_penalty = True
                break
            if re.search(down_verbs_pat + r"[^,;]{0,35}" + func_targets_pat, clause) or re.search(
                func_targets_pat
                + r"[^,;]{0,25}(?:was|were|is|are|remained|continued\s+to)?\s*(?:1\.\d+-fold\s+(?:and\s+1\.\d+-fold\s+)?)?"
                + down_verbs_pat,
                clause,
            ):
                has_bound_penalty = True
                break
            if ("insulin:c-peptide" in sl or "insulin/c-peptide" in sl) and re.search(
                r"\b\d+(?:\.\d+)?-fold\s+lower\s+ratio\b", clause
            ):
                has_bound_penalty = True
                break

    has_direct_hazard_pen = (
        ("hypoglycemi" in sl and not neg_hypo and any(w in sl for w in ("fasting hypoglycemi", "induced hypoglycemi", "caused hypoglycemi", "risk of hypoglycemi", "fell to 70 mg/dl or less")))
        or ("teratoma" in sl and not neg_teratoma and any(w in sl for w in ("teratoma formation", "formed teratoma", "teratoma risk", "teratomas")))
        or ("off-target" in sl and not neg_off_target and any(w in sl for w in ("slc18a1", "enterochromaffin")))
        or ("elevated insulin secretion in low glucose" in sl)
    )
    penalty_observed = has_bound_penalty or has_direct_hazard_pen

    haz_pat = r"(lysis|killing|apoptosis|apoptotic|cell death|cytotoxic\w*|rejection|inflammation|er stress|fibrosis|necrosis|hyperglyc\w+|insulitis|infiltrat\w+)"
    up_pat = r"(increas\w+|elevat\w+|higher|enhanc\w+|greater|upregulat\w+|induc\w+|exacerbat\w+|accelerat\w+|more)"
    down_pat = r"(reduc\w+|decreas\w+|lower\w*|prevent\w*|protect\w*|attenuat\w+|inhibit\w+|abolish\w*|block\w*|suppress\w*|diminish\w*|ameliorat\w+|delay\w*|abrogat\w+|less|fewer|resist\w*|rescu\w+|spar\w+)"
    haz_up_fwd = bool(
        re.search(up_pat + r"[^.;]{0,50}" + haz_pat, sl)
        and not re.search(
            r"\b(?:did\s+not|was\s+not|were\s+not|does\s+not|do\s+not|no|without|never|neither)\b[^.;]{0,25}" + up_pat,
            sl,
        )
    )
    haz_up_rev = bool(
        re.search(
            haz_pat + r"[^.;]{0,50}\b(?:was|were|is|are|remained|became|significantly|markedly|drastically|substantially|\s)+" + up_pat,
            sl,
        )
        and not re.search(r"\b(?:did\s+not|was\s+not|were\s+not|no|without)\b[^.;]{0,25}" + up_pat, sl)
    )
    haz_down_any = bool(
        re.search(down_pat + r"[^.;]{0,50}" + haz_pat, sl)
        or re.search(haz_pat + r"[^.;]{0,40}\b(?:was|were|is|are)\s+(?:significantly\s+|markedly\s+)?" + down_pat, sl)
    )
    haz_increase = (haz_up_fwd or haz_up_rev) and not haz_down_any
    is_graft_survival_reduction = bool(
        (
            re.search(r"\b(?:reduc\w+|decreas\w+|shorten\w+|curtail\w+|impair\w+|loss\s+of)\b[^.;]{0,40}\b(?:allograft|graft|islet)\s+survival\b", sl)
            or re.search(r"\b(?:allograft|graft|islet)\s+survival\b[^.;]{0,35}\b(?:was|were|is|are)?\s*(?:significantly\s+|markedly\s+)?(?:reduc\w+|decreas\w+|shorten\w+|curtail\w+|impair\w+)\b", sl)
        )
        and not re.search(r"\b(?:did\s+not|was\s+not|were\s+not|without)\b", sl)
    )

    if (
        any(
            k in sl
            for k in (
                "unchanged",
                "similar",
                "no significant difference",
                "not significantly",
                "not statistically significant",
                "comparable",
                "did not affect",
                "was not prolonged",
                "were not prolonged",
                "did not increase",
                "did not prevent",
                "no protection",
                "failed to prolong",
                "not sufficient to prevent",
                "not sufficient to protect",
                "insufficient to prevent",
            )
        )
        and not haz_increase
        and not penalty_observed
        and not is_graft_survival_reduction
    ):
        return "Neutral_or_NonInferior", False

    has_non_cyto_toxic = bool(re.search(r"(?<!cyto)\btoxic\w*", sl))
    has_harm_kw = has_non_cyto_toxic or (
        (
            any(
                k in sl
                for k in (
                    "impair",
                    "compromis",
                    "fail",
                    "destroyed",
                    "rejected",
                    "chromothripsis",
                    "exacerbat",
                    "worsen",
                    "blunt",
                    "poor gsis",
                    "poor dynamic",
                    "large deletion",
                    "kilobase deletion",
                    "on-target deletion",
                    "returned to a diabetic",
                    "returned to diabetic",
                    "reverted to hyperglycemi",
                    "reverted to a diabetic",
                )
            )
            or ("hypoglycemi" in sl and not neg_hypo)
            or ("teratoma" in sl and not neg_teratoma)
            or ("silenc" in sl and not is_rnai_silenc and any(w in sl for w in ("epigenetic", "transgene", "promoter", "methylation", "icasp9")))
            or ("translocation" in sl and not is_benign_transloc and any(w in sl for w in ("chromosom", "balanced", "unbalanced", "cas9", "nickase", "dsb", "editing", "cast-seq")))
        )
        and not neg_impair
        and not is_rescue_of_impairment
        and not neg_off_target
    )

    is_functional_reduction = has_bound_penalty or is_graft_survival_reduction

    if has_harm_kw or haz_increase or is_functional_reduction or penalty_observed:
        direction = "Deleterious_or_Impaired"
    elif neg_impair and not any(
        k in sl
        for k in (
            "increas",
            "improv",
            "enhanc",
            "protect",
            "prolong",
            "restor",
            "preserv",
            "prevent",
            "evad",
            "resist",
            "surviv",
            "revers",
            "ameliorat",
            "counteract",
            "normoglycemi",
            "reduced cell death",
            "cell death was significantly reduced",
        )
    ):
        direction = "Neutral_or_NonInferior"
    elif any(
        k in sl
        for k in (
            "increas",
            "improv",
            "enhanc",
            "protect",
            "prolong",
            "restor",
            "preserv",
            "prevent",
            "evad",
            "resist",
            "surviv",
            "revers",