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…
raise ValueError('Verification check failed: not orf_aud["mkglehldsa_present"]')
if not (len(orf_aud["utr5_uATG_hits"]) == 0):
raise ValueError('Verification check failed: len(orf_aud["utr5_uATG_hits"]) == 0')
if not (len(orf_aud["post_stop_downstream_orf_ge8aa"]) == 0):
raise ValueError('Verification check failed: len(orf_aud["post_stop_downstream_orf_ge8aa"]) == 0')
if not (seq.count(sv40_sig) == 0 and seq.count(bgh_sig) == 0):
raise ValueError('Verification check failed: seq.count(sv40_sig) == 0 and seq.count(bgh_sig) == 0')
cds_summaries = []
cds_homos = 0
for pname, pseq in parts:
if pname.startswith("CDS_"):
aa = l2.translate_dna(pseq)
if not (aa.endswith("*") and aa.count("*") == 1):
raise ValueError('Verification check failed: aa.endswith("*") and aa.count("*") == 1')
aa_clean = aa[:-1]
if not (not TWO_A_REGEX.search(aa_clean)):
raise ValueError('Verification check failed: not TWO_A_REGEX.search(aa_clean)')
cds_homos += len(re.findall(r"(A{7,}|C{7,}|G{7,}|T{7,})", pseq))
sp_scan = scan_swissprot_peptides(aa_clean, sp_kmers)
cds_summaries.append({
"part": pname, "cds_bp": len(pseq), "aa_len": len(aa_clean),
"aa_sha256": sha256_str(aa_clean),
"swissprot_foreign_8_11m": sp_scan["foreign_8_11mers_total"],
"swissprot_foreign_15m": sp_scan["k15_foreign"],
})
if not (cds_homos == 0):
raise ValueError('Verification check failed: cds_homos == 0')
# CIITA 8-isoform chimera audit
def _km(p: str, szs: tuple[int, ...]) -> set[str]:
return {p[i : i + sz] for sz in szs for i in range(max(0, len(p) - sz + 1))}
mx8, mx15 = 0, 0
for _acc_c, rec_c in ciita_iso_bundle.items():
mrna_c = rec_c["mrna_sequence"].upper()
cs_c, ce_c = rec_c["cds_start_1based"], rec_c["cds_end_1based"]
ex5_p1 = mrna_c.find(ex5_78bp) + 1
cds_before = mrna_c[cs_c - 1 : ex5_p1 - 1]
nat_aa = l2.translate_dna(mrna_c[cs_c - 1 : ce_c]).rstrip("*")
chim_dna = cds_before + seq[375 - cut_off_ex5 :]
aas = []
for ic in range(0, len(chim_dna) - 2, 3):
aa_c = l2.GENETIC_CODE[chim_dna[ic : ic + 3]]
if aa_c == "*":
break
aas.append(aa_c)
trunc = "".join(aas)
mx8 = max(mx8, len(_km(trunc, (8, 9, 10, 11)) - _km(nat_aa, (8, 9, 10, 11))))
mx15 = max(mx15, len(_km(trunc, (15,)) - _km(nat_aa, (15,))))
if not (mx8 == 0 and mx15 == 0):
raise ValueError('Verification check failed: mx8 == 0 and mx15 == 0')
# Insulator-aware 6-PWM JASPAR Bonferroni audit
allowed_spans = [(spans[k][0], spans[k][1]) for k in (prom_keys + ins_keys + ["HA_L", "HA_R"])]
fam_t = sum(max(0, 2 * (dlen - int(m["length"]) + 1)) for m in pwms.values())
ectopic_6pwm = []
ctcf_hits = 0
for mid, pentry in pwms.items():
sc = l2.scan_jaspar_pwm(seq, pentry, top_k=30, n_matrices_in_scan=len(pwms), actual_family_total_tests=fam_t)
for hp in sc["all_significant_hits"]:
if not hp["passes_region_wide_bonferroni_0p05"]:
continue
s1, e1 = int(hp["start_1based_in_window"]), int(hp["end_1based_in_window"])
if not any(not (e1 < a or s1 > b) for a, b in allowed_spans):
ectopic_6pwm.append({"matrix_id": mid, "tf": hp["tf_name"], "pos": [s1, e1], "strand": hp["strand"]})
elif mid == "MA0139.1":
ctcf_hits += 1
if not (len(ectopic_6pwm) == 0):
raise ValueError(f"{cid} ectopic 6-PWM: {ectopic_6pwm}")
d_sha = sha256_str(seq)
if cid in ("ABX_L2_v2_CD64T_IL1RN", "ABX_L2_v2_CTRL_CD64T_ONLY", "ABX_L2_v2_CTRL_IL1RN_ONLY"):
dep_status = "ACTIVE_WAVE5_GO_SCOPE_MODE_B"
elif "CD46WT" in cid:
dep_status = "HOLD_COMPARATOR_BLOCKED_PENDING_CAND034_CD46_TROPIC_ADDENDUM"
else:
dep_status = "TERTIARY_HOLD_COMPARATOR_PIGK1_REQUIRES_CTRL_CFH_CD55_ONLY"
p1_audits.append({
"construct_id": cid,
"locus": "chr16p13.13_CIITA_Exon5",
"role": role,
"deployment_status": dep_status,
"execution_supported": False,
"delta_k_vs_abx_core": 0,
"byte_identical_to_iip0035_construct": byte_eq_iip35,
"donor_length_bp": dlen,
"fasta_omits_physical_itrs": True,
"nominal_aav6_packaged_bp": pkg_bp,
"nominal_aav6_headroom_bp": headroom,
"fits_nominal_single_aav6_le_4700bp": pkg_bp <= 4700,
"donor_sha256": d_sha,
"gc_pct": round(100.0 * (seq.count("G") + seq.count("C")) / dlen, 2),
"two_a_count": 0,
"pigk_gpi_count": pigk_cnt,
"sv40_or_bgh_count": 0,
"mkglehldsa_count": 0,
"utr5_uATG_count": 0,
"post_stop_downstream_orf_ge8aa_count": 0,
"start_or_sp_clipping_introns_tss_and_full": f"{n_clip_tss}/{n_clip_full}",
"all_predicted_splice_pairs_tss_and_full": f"{n_all_tss}/{n_all_full}",
"all_predicted_splice_pairs_note": (
"2 upstream promoter-internal pairs lie upstream of the annotated CD274p TSS (0 in transcribed TSS->polyA window, 0 start/SP-clipping)"
if n_all_full > 0
else "0 predicted splice pairs in both TSS->polyA and full-promoter->polyA scan windows"
),
"repeats": {**rep, "disjoint_ir_ge16_count": ir_ge16, "near_ir_ge20_le1mm_count": len(near_ir)},
"ectopic_6pwm_hits": 0,
"verified_ctcf_ma0139_hits": ctcf_hits,
"ciita_8isoform_novel_peptides_8_11m_15m": [mx8, mx15],
"cds_protein_audits": cds_summaries,
})
hdr = (
f">{cid} locus=chr16p13.13_CIITA_Exon5 delta_k=0 donor_bp={dlen} aav6_pkg_bp={pkg_bp} "
f"headroom_bp={headroom} clip_introns_tss_full=0/0 mkglehldsa=0 uATG=0 rt_orf_ge8aa=0 "
f"2a=0 pigk={pigk_cnt} ir={rep['max_disjoint_ir_bp']} dr_out={rep['max_disjoint_dr_outside_canonical_bp']} "
f"ectopic_6pwm=0 ciita_chim=0 sha256={d_sha}"
)
fasta_lines.append(hdr)
for i in range(0, dlen, 80):
fasta_lines.append(seq[i : i + 80])
FASTA_OUT.write_text("\n".join(fasta_lines) + "\n", encoding="utf-8")
fasta_sha = sha256_file(FASTA_OUT)
# Gate P2 — Topology, Disulfides, EPB41L2 clearance, iCasp9 orthogonality (R1 fixed!)
def _uniprot_features(acc: str) -> dict[str, Any]:
uj = json.loads((PROT_CACHE_DIR / f"uniprot_{acc}.json").read_text(encoding="utf-8"))
feats = uj.get("features", [])
sp_f = [f for f in feats if f.get("type") == "Signal"]
tm_f = [f for f in feats if f.get("type") == "Transmembrane"]
cyt_f = [f for f in feats if f.get("type") == "Topological domain" and "cytoplasmic" in str(f.get("description", "")).lower()]
ss_f = [f for f in feats if f.get("type") == "Disulfide bond"]
glyc_f = [f for f in feats if f.get("type") == "Glycosylation"]
n_glyc = [f for f in glyc_f if "n-linked" in str(f.get("description", "")).lower()]
o_glyc = [f for f in glyc_f if "o-linked" in str(f.get("description", "")).lower()]
return {
"uniprot_acc": acc,
"protein_len": len(uj["sequence"]["value"]),
"signal_peptide_1based": (
[sp_f[0]["location"]["start"]["value"], sp_f[0]["location"]["end"]["value"]] if sp_f else None
),
"transmembrane_1based": (
[tm_f[0]["location"]["start"]["value"], tm_f[0]["location"]["end"]["value"]] if tm_f else None
),
"cytoplasmic_1based": (
[cyt_f[0]["location"]["start"]["value"], cyt_f[0]["location"]["end"]["value"]] if cyt_f else None
),
"disulfide_bonds_total": len(ss_f),
"n_glycosylation_sites": len(n_glyc),
"o_glycosylation_sites": len(o_glyc),
"total_glycosylation_sites": len(glyc_f),
}
u_p12314 = _uniprot_features("P12314")
u_p18510 = _uniprot_features("P18510")
u_p15529 = _uniprot_features("P15529")
# Programmatic R1 checks directly against UniProt features, translated CDS, and published Gravina 2023 CDS!
if u_p12314["transmembrane_1based"] != [293, 313] or u_p12314["cytoplasmic_1based"] != [314, 374]:
raise ValueError(f"Unexpected P12314 topology: {u_p12314}")
if not (aa_cd64t[311] == "T" and aa_cd64t[312] == "I" and prots["P12314"][313] == "R"):
raise ValueError("CD64t C-terminal boundary T312-I313 / excised R314 check failed")
if not (u_p12314["n_glycosylation_sites"] == 7 and u_p12314["o_glycosylation_sites"] == 0):
raise ValueError(f"Unexpected P12314 glycosylation counts: {u_p12314}")
if not (u_p15529["n_glycosylation_sites"] == 3 and u_p15529["o_glycosylation_sites"] == 18 and u_p15529["total_glycosylation_sites"] == 21):
raise ValueError(f"Unexpected P15529 glycosylation counts: {u_p15529}")
if not (u_p18510["n_glycosylation_sites"] == 1 and u_p18510["o_glycosylation_sites"] == 0):
raise ValueError(f"Unexpected P18510 glycosylation counts: {u_p18510}")
gravina_cmp = verify_gravina_cd64t_cds_comparison(cds_cd64t, expected_aa=aa_cd64t, check_private_xml_cache=True)
p2_topology = {
"CD64t_313_Gravina2023": {
**u_p12314,
"truncated_length_aa": 313,
"c_terminal_residue_313": "Ile313 (staged codon ATT vs Gravina published ATA) — terminal residue of TM helix 293-313; Arg314-Tyr374 cytoplasmic domain completely deleted (NOT Arg313)",
"stop_codon": gravina_cmp["staged_stop_codon"],
"gravina_2023_sequence_comparison": gravina_cmp,
"retains_all_3_ig_domains_and_tm_293_313": True,
"cytoplasmic_tail_len_aa": 0,
"epb41l2_4p1g_region_312_332_disposition": "Cytoplasmic 314-332 (basic HxxBxxxBB docking core RKELKRKKKWDLEISLDSG) excised; TM-end Thr312-Ile313 reside inside TM helix 293-313",
"epb41l2_reference_pmid": "18023480",
"fcgr_gamma_chain_association_status": "PENDING_EMPIRICAL_GATE_28B_VERIFICATION",
"fcgr_gamma_chain_signaling_note": (
"Tailless deletion (Arg314-Tyr374) removes direct cytosolic tail motifs, but the retained transmembrane helix (TM 293-313) "
"can associate with the FcRgamma (FCER1G) ITAM signaling adaptor where expressed (Davis et al. 1995 PMID:7859733 / PMC398101). Absence of FcRgamma "
"co-IP and phospho-Syk/ITAM signaling in Stage-7 SC-islets and iECs is an empirical Gate 28-B requirement, NOT an assumed boolean property."
),
"cis_fc_competition_mechanism_and_tonic_saturation": (
"At physiological 5-10 mg/mL (33-67 uM) polyclonal human IgG and Kd ~1-10 nM, ~99.97%-99.999% of surface CD64t is tonically occupied "
"by irrelevant bulk IgG (~0.03-0.24 nmol total graft CD64t across 8e8 cells vs ~200 umol plasma IgG, ~1e6:1 ratio). Protection, if achieved, "
"operates via cis Fc competition / steric blockade of CD16 engagement at the graft membrane rather than bulk autoantibody depletion."
),
"tailless_1copy_and_2copy_hdr_surface_density_qc": (
"REQUIRED in Gate 28-B: QuantiBRITE absolute >= 50,000 molecules/cell at calibrated t=0 and Day-90 (>=75% retention AND >=50,000 abs) "
"reported SEPARATELY for 1-copy (monoallelic HDR, modal outcome) and 2-copy (biallelic HDR) clones, PLUS immune-complex surface half-life, "
"soluble CD64t shedding ELISA, macrophage trogocytosis/stripping, and functional ADCC/CDC retention after 7-day 10 mg/mL IgG pre-loading."
),
"kill_switch_orthogonality_gy002_gy026": "PASS — paired exclusively with small-molecule AP1903/rimiducid AAVS1-iCasp9 (ZERO IgG-Fc mAb kill-switch clash).",
},
"IL1RN_177_Secreted_Isoform1": {
**u_p18510,
"secreted_mature_length_aa": 152,
"signal_peptide_cleavage": "1-25",
"promoter_regime": (
"Inducible human CD274p_250 (IFN-gamma/JAK1-2/STAT1-IRF1). Prospective OpenIslet Gate 28-B design criteria "
"(NOT directly measured in Dror 2017, Arend 1990, or Giannoukakis 1999): unstimulated basal leak <= 5.0% of induced "
"output (motivated by physiological mouse postprandial macrophage IL-1beta in Dror 2017 PMID:28092375, which did not "
"measure CD274p leak) and stimulated local IL-1Ra:IL-1beta >= 100:1 molar excess (motivated by assay-specific up-to-100-fold "
"50% inhibition in non-islet cells in Arend 1990 PMID:2139669). Carries GY-001/STAT1 epistasis risk under IFN-dampened "
"backgrounds (e.g., TYK2 P1104A or low-IFN IL-1beta-dominant IBMIR) -> mandatory IFN-gamma titration matrix in Gate 28-B."
),
"pigk_gpi_load": 0,
},
"CD46_WT_392_Native_Complement_HOLD_COMPARATOR": {
**u_p15529,
"deployment_status": "HOLD_COMPARATOR_BLOCKED_PENDING_CAND034_CD46_TROPIC_ADDENDUM",
"glycosylation_evidence_note": "UniProt P15529 annotates 3 N-linked and 18 O-linked sites (all 18 O-linked entries carry sequence-model annotations; product glycan occupancy is unmeasured).",
"mode_of_action": "Type-I TM cofactor for Factor I cleavage of BOTH C4b (classical/lectin IgM/IgG) and C3b (alternative pathway) -> addresses Gou 2026 PMID:41543848 IgM gap with 0 absent Swiss-Prot windows & 0 PIGK load, but HELD outside Wave-5 Go scope.",
"viral_receptor_gate": "ARCHIVED AS HOLD-COMPARATOR: barred from advancement or manufacture until CAND-034 executable cd46_tropic_addendum (distinguishing HHV-6A vs HHV-6B, vaccine vs wild-type measles strains, and AdV-B) clears; core Gate 0V-B (CVB4/CVB3/HCMV) is NON-CITABLE as CD46_WT clearance.",
"pigk_gpi_load": 0,
},
"CFH_1_264_CD55_286_381_GPI_Comparator": {
"deployment_status": "TERTIARY_HOLD_COMPARATOR_PIGK1_REQUIRES_CTRL_CFH_CD55_ONLY",
"cfh_uniprot_P08603_slice": "1-264 (SP 1-18 + SCR1-4 C3b/FI decay-accelerating & cofactor domain; protective Val62 rs800292 verified; 16 mature CFH Cys = 8 intact SCR1-4 disulfides)",
"cd55_uniprot_P08174_slice": "286-381 (STP O-glycosylated stalk + GPI-anchor omega-site Ser353; Cys364 cleanly inside cleaved GPI propeptide 354-381)",
"total_length_aa": 360,
"pigk_gpi_load": 1,
"advancement_control_requirement": "Advancing tertiary CFH-CD55 requires adding a matched symmetric-2CTCF CTRL_CFH_CD55_ONLY (PIGK=1) single-cargo control plus viral CVB/echovirus co-receptor check on CD55.",
"honest_tradeoffs": [
"Junction PSCEE|KSLTS creates 26 absent 8-11mers and 12 absent 15mers vs 20,429 human Swiss-Prot (sequence-membership counts; immunogenicity unmeasured).",
"Adds +1 PIGK GPI-anchor cargo competing with CD47-IgV-GPI on Core A/X (PIGK titration required).",
"Alternative-pathway (C3bBb) focused; lacks classical C4b2a cofactor cleavage provided by CD46_WT.",
],
},
}
# Gate P3 — Swiss-Prot 20,429-protein neo-epitope scan + gnomAD v4.1 + GY-026 CR1 hold
gnomad_v4 = json.loads((PROT_CACHE_DIR / "gnomad_v4_1_coding_variants.json").read_text(encoding="utf-8"))
p3_swissprot = {
"swissprot_protein_count": len(prots),
"swissprot_gz_sha256": sp_sha,
"pinned_sha_match": sp_sha == PINNED_SWISSPROT_SHA,
"active_proteins": {
"CD64t_313": scan_swissprot_peptides(aa_cd64t, sp_kmers),
"IL1RN_177": scan_swissprot_peptides(aa_il1rn, sp_kmers),
"CD46_WT_392": scan_swissprot_peptides(aa_cd46, sp_kmers),
"CFH_1_264_CD55_286_381": scan_swissprot_peptides(aa_cfh_cd55, sp_kmers),
},
"gy026_blocked_short_stalk_cr1_audit": {
"construct_name": "CR1_SCR1-10_TM[1-687+1970-2005]",
"status": "HELD_BLOCKED_BY_GY026_NOT_IN_ACTIVE_FASTA",