scripts/run_layer2_perturbation_and_regulatory_plane.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/run_layer2_perturbation_and_regulatory_plane.py · SHA-256: 3220e68f97203dbc…
"Blocked 2x2 transient IL1R1-knockdown x FAS-knockdown human SC-islet experiment within matched independent differentiations prior to integrated "
"6-arm AAV6 donor synthesis, comparing double-control, single IL1R1 KD, single FAS KD, and dual KD with an independent targeting reagent pair or "
"RNAi-resistant rescue across IL-1beta, membrane mFasL vs SA-FasL (Trivedi 2019 PMID:31552143; Headen 2018 PMID:29867165), and a TNF-alpha + IFN-gamma + TRAIL bypass condition."
),
"unresolved_human_islet_secretory_tradeoffs": (
"Must test matched absolute insulin/C-peptide output (>=85% of ARM1), low-glucose shut-off, and post-cytokine recovery alongside SI >= 2.5 because "
"human islet literature shows conflicting effects: Loweth 1998 (PMID:9588443) vs Loweth 2000 (PMID:11220355) on Fas-expression sufficiency, "
"Schumann 2007 (PMID:17299038) reporting impaired human-islet fuel-stimulated secretion under Fas blockade, Hajmrle 2016 (PMID:27699257) and "
"Dror 2017 (PMID:28092375) showing acute/postprandial IL-1beta insulinotropic compensation, and Wiedemann 2022 (PMID:35750050) addressing microglial/vagal "
"cephalic IL-1beta signaling that isolated graft perifusion does not model."
),
"inherited_stricter_stage0_gates": (
"Inherits existing clonogenic AP1903 escape bounds and recovery controls, >=62,958 independent duplex-UMI molecules for TP53/PPM1D/BCOR somatic sweeps "
f"(50,000 target molecules gives only 87.53% probability of >=3 mutants at VAF 1e-4 and {cbe_bound_50k}% one-sided 95% 0-event bound), "
"CAST-Seq chromosomal-rearrangement scope (Turchiano 2021 PMID:33626327), Rule S8b SA-FasL microgel drop rule, and Arm-2 post-adjunct-depletion rechallenge."
),
},
"verified_6_arm_constructs": parsed_records,
"standalone_cbe_comparator_registry_ensembl_116": {
"annotation_release_note": (
"Reconstructed against Ensembl release 116 canonical transcripts FAS ENST00000652046.1 and IL1R1 ENST00000410023.6, "
"explicitly distinguished from Layer-2's pinned baseline Ensembl release 112 / GENCODE v46 cache. "
"Zero-bystander status applies ONLY to the narrow C-only [4..8] sequence filter: all 3 FAS guides carry an additional C9 inside TadCBEd's [3..9] window "
"(Neugebauer 2023 PMID:36357719), and all 4 CAG->TAG guides carry an adjacent in-codon adenine where residual CBE adenine deamination can convert "
"CAG->TAG->TGG (Trp) and undo stop installation (Zhang 2024 PMID:38402281; GC-context deaminase scope per Thuronyi 2019 PMID:31332326)."
),
"candidate_guides_9_across_7_variants": _IIP_0018_OFFLINE_REFERENCE_BUNDLE["cbe_9_guides_7_variants"],
"retracted_or_reclassified_s1_edits": _IIP_0018_OFFLINE_REFERENCE_BUNDLE["retracted_or_reclassified_s1_edits"],
"germline_protective_coding_benchmarks_non_cbe": _IIP_0018_OFFLINE_REFERENCE_BUNDLE["germline_protective_coding_benchmarks_non_cbe"],
},
"opentargets_mondo_0005147_top200_timestamped_receipt": _IIP_0018_OFFLINE_REFERENCE_BUNDLE["opentargets_receipt"],
"bcrank_t1d_heuristic_stage0_rubric": _IIP_0018_OFFLINE_REFERENCE_BUNDLE["bcrank_t1d_heuristic_rubric"],
"portfolio_2pow12_same_design_withdrawal_proof": _IIP_0018_OFFLINE_REFERENCE_BUNDLE["portfolio_2pow12_withdrawal_proof"],
}
def _build_design_y_wildcard_manifest_iip_0023() -> Dict[str, Any]:
"""
Sequence, promoter-CGI, TadCBEd haplotype, CIITA isoform, and source-flux adenosine reaction-diffusion
audit for Stage-0 Design Y wildcard comparators strictly inside the <= 20% wildcard firewall (IIP-0023; DEC-102).
"""
dy_fasta = REPO_ROOT / "data/constructs/islet1_design_y_wildcard_comparators_v0.8.0.fasta"
raw_bytes = dy_fasta.read_bytes()
file_sha = hashlib.sha256(raw_bytes).hexdigest()
expected_file_sha = "c7f54b824a73cf9d40247d4fd251cb5c28a8eca4a1530b9661284200bb4cbabc"
if file_sha != expected_file_sha:
raise ValueError(f"Design Y wildcard FASTA SHA-256 {file_sha} != {expected_file_sha}")
records: List[Dict[str, Any]] = []
cur_hdr = None
cur_seq: List[str] = []
for ln in raw_bytes.decode("utf-8").splitlines():
s = ln.strip()
if not s:
continue
if s.startswith(">"):
if cur_hdr is not None:
seq_str = "".join(cur_seq).upper()
records.append({
"header": cur_hdr,
"construct_id": cur_hdr.split()[0],
"length_bp": len(seq_str),
"sha256": hashlib.sha256(seq_str.encode("utf-8")).hexdigest(),
"gc_fraction": round((seq_str.count("G") + seq_str.count("C")) / len(seq_str), 6),
"gsg_p2a_motif_occurrences": seq_str.count("GGAAGCGGAGCTACTAACTTCAGCCTGCTGAAGCAGGCTGGAGACGTGGAGGAGAACCCTGGACCT"),
"kanr_or_colE1_ori_motif_occurrences": seq_str.count("ATGAGCCATATTCAACGGGAAACG") + seq_str.count("TTGAGATCCTTTTTTTCTGCGCGTAATCTG"),
})
cur_hdr = s[1:]
cur_seq = []
else:
cur_seq.append(s)
if cur_hdr is not None:
seq_str = "".join(cur_seq).upper()
records.append({
"header": cur_hdr,
"construct_id": cur_hdr.split()[0],
"length_bp": len(seq_str),
"sha256": hashlib.sha256(seq_str.encode("utf-8")).hexdigest(),
"gc_fraction": round((seq_str.count("G") + seq_str.count("C")) / len(seq_str), 6),
"gsg_p2a_motif_occurrences": seq_str.count("GGAAGCGGAGCTACTAACTTCAGCCTGCTGAAGCAGGCTGGAGACGTGGAGGAGAACCCTGGACCT"),
"kanr_or_colE1_ori_motif_occurrences": seq_str.count("ATGAGCCATATTCAACGGGAAACG") + seq_str.count("TTGAGATCCTTTTTTTCTGCGCGTAATCTG"),
})
if [r["length_bp"] for r in records] != [11066, 11859, 12555]:
raise ValueError(f"Unexpected Design Y comparator lengths: {[r['length_bp'] for r in records]}")
# Explicit steady-state peri-islet source-flux adenosine reaction-diffusion balance:
# C_surf(z=0) = J_ADO / sqrt(D_eff * k_clear) * exp(-gap / lambda_ADO), lambda_ADO = sqrt(D_eff / k_clear)
ado_models: List[Dict[str, Any]] = []
for label, j_pmol_cm2_s, d_cm2_s, k_s_inv, gap_um in (
("IEC_CD39_CD73_ModerateClearance_5umGap", 0.18, 4.5e-6, 0.15, 5.0),
("IEC_CD39_CD73_SlowClearance_5umGap", 0.25, 7.0e-6, 0.05, 5.0),
("PanLineage_CD39_CD73_ModerateClearance_0um", 0.45, 4.5e-6, 0.15, 0.0),
):
lam_cm = math.sqrt(d_cm2_s / k_s_inv)
lam_um = lam_cm * 1e4
# J in mol/(cm^2*s) = j_pmol_cm2_s * 1e-12; C in mol/cm^3 -> * 1e12 for nM
c0_nM = (j_pmol_cm2_s * 1e-12 / math.sqrt(d_cm2_s * k_s_inv)) * 1e12
c_gap_nM = c0_nM * math.exp(-(gap_um * 1e-4) / lam_cm)
ado_models.append({
"scenario": label,
"ectonucleotidase_flux_pmol_cm2_s": j_pmol_cm2_s,
"d_eff_cm2_s": d_cm2_s,
"ada1_ent1_clearance_k_s_inv": k_s_inv,
"decay_length_lambda_um": round(lam_um, 2),
"iec_to_beta_gap_um": gap_um,
"predicted_beta_surface_adenosine_nM": round(c_gap_nM, 2),
})
return {
"contribution_id": "IIP-0023",
"decision_id": "DEC-102",
"wildcard_firewall_scope": "Unscored Stage-0 Design Y wildcard within shared <= 20% Y/Z allocation cap; zero changes to core scored Blueprints A, B, or X.",
"fasta_artifact": {
"relative_path": "data/constructs/islet1_design_y_wildcard_comparators_v0.8.0.fasta",
"file_sha256": file_sha,
"constructs": records,
},
"eepassige_attp_in_genome_polarity_and_context_separation": {
"b2m_exon1_twinpe_excision_grch38": "chr15:44711547-44711619 (73 bp removing native Met1, signal peptide, Gln22 and GTGAGT donor -> 52 bp Bxb1 attP)",
"attb_minicircle_recombination_products": "52 bp attP x 38 bp attB -> 45 bp attR (0 sense ATGs across 75 bp retained 5'-UTR + attR leader upstream of 154 bp SPA+MAZ4) + 45 bp attL (0 ATGs either strand)",
"dsb_and_nickase_caveat": "Uses paired Cas9n nickases without intended exposed nuclease DSBs while retaining CAST-Seq (< 1e-5) and long-read ONT checks for paired-nick staggered DSB intermediates (Levesque et al. 2026 PMID:42749803; Hanlon et al. 2019 PMID:31570731; Shy et al. 2023 PMID:36008610; Allen et al. 2024 PMID:37127662).",
"pandey_2025_pmid38858586_experimental_context_disclosure": (
"Pandey et al. 2025 (PMID:38858586) measured 3.8%/20.9%/24% OT4 capture after puromycin enrichment, 0.008%/0.004% OT1/OT2 in primary fibroblasts "
"with IDLV donor, and 3.8% vs 0.52% hiPSC knock-in using homozygous CCR5 attB + 5.6-kb attP plasmid; >= 3.0% pre-enrichment knock-in of an 11.1-kb "
"attB minicircle at B2M attP is therefore an explicit prospective Stage-0 hPSC target rather than an already-demonstrated yield (STRAIGHT-IN clonal "
"hPSC precedent in Blanch-Asensio et al. 2026 PMID:39179886; ISCro4 RNA-guided recombinase context in Pelea et al. 2026 PMID:41642947)."
),
},
"ciita_and_cxcl10_cgi_tadcbed_and_isoform_reconciliation": {
"promoter_cgi_window_reconciliation": {
"cxcl10_601bp_chr4_76023197_76023797": {"cpg_count": 3, "obs_over_exp": 0.1520, "meets_gardiner_garden_cgi": False},
"ciita_piv_601bp_broad_window": {"cpg_count": 30, "obs_over_exp": 0.5154, "meets_gardiner_garden_cgi": False},
"ciita_piv_201bp_tss_subwindow_chr16_10878900_10879100": {
"cpg_count": 16,
"gc_pct": 64.68,
"obs_over_exp": 0.7982,
"meets_gardiner_garden_cgi": True,
},
"crisproff_comparison_note": (
"While CXCL10 lacks a CpG island, CIITA-pIV contains a 201-bp TSS-spanning CpG-dense subwindow (Obs/Exp = 0.7982) and CRISPRoff "
"can silence non-CGI genes in several contexts (Nunez et al. 2021 PMID:33838111); TadCBEd vs CRISPRoff is therefore evaluated as a "
"head-to-head 60-day differentiation + cytokine durability comparison rather than a promoter-CGI exclusion."
),
},
"tadcbed_editing_window_and_a_to_g_haplotype_gate": (
"TadCBEd exhibits C->T activity across protospacer positions 3-9 alongside residual A->G editing (Neugebauer et al. 2023 PMID:36357719): "
"at CIITA Exon 2 (C7AG), joint C7>T + A8>G converts CAG -> TGG (Trp missense instead of TAG stop), and Exon 10 carries adjacent A6. "
"Clonal hPSC qualification therefore requires full amplicon NGS haplotype distributions (quantifying C>T, A>G, and indels simultaneously) "
"rather than C-only bystander scans."
),
"ciita_isoform_accession_reconciliation": (
"Pinned GENCODE v46 ENST00000576601.1 (177 aa, 7 exons) and ENST00000637439.1 are truncated partial models; full-length RefSeq "
"NM_001286402.1 (1,131 aa, pIII) maps chr16:10895386:C>T to p.Gln53*, NM_000246.4 (1,155 aa, pI) to p.Gln77*, and classical pIV "
"(Muhlethaler-Mottet et al. 1997 PMID:9184229) to p.Gln29*. Because 147-bp Exon 2 (147 mod 3 = 0) permits in-frame exon skipping or "
"downstream Met reinitiation, Exon 10 NACHT-domain stop (chr16:10904792, p.Trp334* on NM_001286402.1) is co-tested with protein-level "
"IFN-gamma HLA-DR/DP/DQ flow verification."
),
},
"adenosine_source_flux_reaction_diffusion_and_cd200_scope": {
"human_receptor_and_hypoxia_context": (
"Human islets abundantly express Gi-coupled ADORA1 (inhibiting GSIS; reversed by 1 uM DPCPX in Mohammed Al-Amily et al. 2026 PMID:42660457, "
"tested alongside 100 nM selective DPCPX in Y-03) and Gs-coupled ADORA2A (promoting alpha-cell glucagon release; Liu et al. 2024 PMID:38879678), "
"with hypoxia-regulated adenosine transcript shifts reported in Brandhorst et al. 2026 (PMID:42791925)."
),
"source_flux_reaction_diffusion_scenarios": ado_models,
"cd200_and_mir375_detargeting_caveats": (
"Chai et al. 2022 (PMID:35297680) used alpha-cell-enriched miRNAs rather than miR-375 (which is abundant in both human alpha and beta cells), "
"Hu et al. 2025 (PMID:40251154) co-tested CD99 + CD200 rather than iEC-only CD200 indirect-CD4 suppression alone, and packing 7 tandem units "
"across 11.1 kb can introduce transcriptional supercoiling coupling (Naughton et al. 2013 PMID:23416946; Gilbert & Allan 2014 PMID:24584092), "
"making direct Y-03/Y-04 empirical co-culture, AGO2-RIP miR-375, anti-CD200 reversal, and single-cell multi-cistron gates mandatory."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FHKRYLKKI"
"RDLGEGHFGKVSLYCYDPTNDGTGEMVAVKALKADCGPQHRSGWKQEIDILRTLYHEHIIKYKGCCEDQGEKSLQLVMEYVPLGSLRDYLPRHSIGLAQL"
"LLFAQQICEGMAYLHAQHYIHRDLAARNVLLDNDRLVKIGDFGLAKAVPEGHEYYRVREDGDSPVFWYAPECLKEYKFYYASDVWSFGVTLYELLTHCDS"
"SQSPPTKFLELIGIAQGQMTVLRLTELLERGERLPRPDKCPCEVYHLMKNCWETEASFRPTFENLIPILKTVHEKYQGQAPSVFSVC"
)
EXPECTED_DESIGNB_FASTA_SHA256_IIP0026 = "4bb20389773c76b2705031ba675487825dfbd94d920a692cde75b7d56af22aa4"
EXPECTED_DESIGNB_C1_C5_PAIR_SHA256_IIP0026 = "82c351af082e0f97361e715c36e2ab5872b8d097efa1c9f59dfda53ea60496ea"
EXPECTED_SWISSPROT_UNCOMPRESSED_SHA256_IIP0026 = "13852e174364bf1c705206c38eacae57210f5bca9955f05be6b4ff48f727d37b"
EXPECTED_SWISSPROT_GZ_SHA256_IIP0026 = "40a8856b4e3f3620b11635143b501ef701558ed97309b0cdb4423ef09e4618d0"
def _is_strict_int_iip0026(val: Any) -> bool:
return isinstance(val, int) and not isinstance(val, bool)
def _protein_kmers_iip0026(aa: str, ks: Tuple[int, ...]) -> Set[str]:
out: Set[str] = set()
n = len(aa)
for k in ks:
for i in range(max(0, n - k + 1)):
out.add(aa[i : i + k])
return out
def _translate_strict_cds_iip0026(cds: str, expect_terminal_stop: bool = True) -> str:
s = cds.upper()
if len(s) == 0 or len(s) % 3 != 0 or any(b not in "ACGT" for b in s):
raise ValueError(f"Invalid CDS length ({len(s)}) or alphabet")
codons = [GENETIC_CODE[s[i : i + 3]] for i in range(0, len(s), 3)]
if codons[0] != "M":
raise ValueError(f"CDS does not start with Met (got {codons[0]})")
if expect_terminal_stop:
if codons[-1] != "*" or "*" in codons[:-1]:
raise ValueError("CDS lacks clean terminal stop or has premature stop")
return "".join(codons[:-1])
if "*" in codons:
raise ValueError("Internal stop codon in non-stop CDS")
return "".join(codons)
def validate_design_b_transcribed_construct_iip_0026(
design_id: str,
donor_seq: str,
cargo_bounds_0based: Tuple[int, int],
orf_specs: List[Dict[str, Any]],
parent_mature_proteins: List[str],
swissprot_k8_11: Set[str],
swissprot_k15: Set[str],
pinned_layer3_sequences: Dict[str, str],
*,
expected_donor_sha256: Optional[str] = None,
require_layer3_identity: bool = True,
transcribed_intervals: Optional[List[Dict[str, Any]]] = None,
observed_5prime_race_end_bp: Any = None,
observed_3prime_race_end_bp: Any = None,
readthrough_umi_n_eff: Any = None,
readthrough_umi_k: Any = None,
) -> Dict[str, Any]: