scripts/run_layer3_structural_binder_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_layer3_structural_binder_plane.py · SHA-256: a070de200dfefd3d…
fasta_path = REPO_ROOT / "data/constructs/islet1_scenario_a_constructs_v0.7.0.fasta"
validate_construct_fasta_binding(layer2_atlas["construct_sequence_and_grammar_verification"], fasta_path)
c1 = analyze_complex_1_hlae_nkg2a(layer2_ledger)
c2 = analyze_complex_2_cd47_sirpa(layer2_ledger)
c3 = analyze_complex_3_serpinb9_gzmb(layer2_ledger)
c4 = analyze_complex_4_pdl1_pd1(layer2_ledger)
icasp9_audit = analyze_icasp9_locus4_structural_reference_audit(layer2_ledger)
l2_cfh_prov = _build_locus2_cfh_stp_gpi_structural_provenance_iip_0031()
hlac_kir_snaps = verify_structural_reference_inputs("1EFX.pdb", "1IM9.pdb")
def _parse_pdb_coords(payload: bytes) -> Dict[Tuple[str, int, str], Tuple[float, float, float]]:
coords: Dict[Tuple[str, int, str], Tuple[float, float, float]] = {}
for line in payload.decode("utf-8", errors="replace").splitlines():
if line.startswith("ATOM "):
alt = line[16].strip()
if alt not in ("", "A"):
continue
atom_name = line[12:16].strip()
chain = line[21].strip()
res_seq = int(line[22:26].strip())
coords[(chain, res_seq, atom_name)] = (
float(line[30:38]),
float(line[38:46]),
float(line[46:54]),
)
return coords
def _pdb_dist(coords: Dict[Tuple[str, int, str], Tuple[float, float, float]], k1: Tuple[str, int, str], k2: Tuple[str, int, str]) -> float:
return round(math.dist(coords[k1], coords[k2]), 4)
efx_coords = _parse_pdb_coords(hlac_kir_snaps["1EFX.pdb"])
im9_coords = _parse_pdb_coords(hlac_kir_snaps["1IM9.pdb"])
serpinb9_func_status = c3["r01_c_terminal_tpt2a_tail_and_rcl_suicide_trap_geometry"]["functional_status"]
cd47_pan_allele_status = c2["gpi_anchor_and_sirpa_polymorphism_verification"]["pan_allelic_sirpa_protection_status"]
ref_geometry_passed = bool(
c1["single_chain_trimer_linker_physics"]["linker_1_peptide_P9_to_B2M_Ile1"]["coarse_extension_screen_d_lt_0p65_Lc"]
and c1["single_chain_trimer_linker_physics"]["linker_2_B2M_Met99_to_HLAE_Ser2"]["coarse_extension_screen_d_lt_0p65_Lc"]
and c1["groove_superposition_metrics"]["aligned_alpha1_alpha2_residues"] == 179
and c1["groove_superposition_metrics"]["rmsd_1MHE_vs_3CDG_angstrom"] < 1.0
and c1["groove_superposition_metrics"]["rmsd_3BZE_vs_3CDG_angstrom"] < 1.0
and c1["trimer_to_cd94_nkg2a_interface"]["heavy_atom_contact_pairs"] >= 200
and c1["asymmetric_unit_copy2_CDQ_to_EF_heavy_atom_contacts_in_3CDG"] >= 200
and c2["cd47_igv_superposition_metrics"]["aligned_ca_residues"] == 113
and c2["cd47_igv_superposition_metrics"]["rmsd_4CMM_vs_2JJS_angstrom"] < 1.0
and c2["cd47_igv_superposition_metrics"]["rmsd_4KJY_vs_2JJS_angstrom"] < 1.0
and c2["cd47_to_sirpa_wt_interface_2JJS"]["heavy_atom_contact_pairs"] >= 150
and c3["granzyme_b_active_site_and_s1_pocket_1IAU"]["aligned_ca_residues_AF_vs_1IAU"] == 226
and c3["granzyme_b_active_site_and_s1_pocket_1IAU"]["identical_residue_pairs"] == 226
and c3["granzyme_b_active_site_and_s1_pocket_1IAU"]["rmsd_AF_P10144_vs_1IAU_angstrom"] < 0.80
and c3["granzyme_b_active_site_and_s1_pocket_1IAU"]["iepd_inhibitor_interface"]["heavy_atom_contact_pairs"] >= 150
and c4["pdl1_to_pd1_interface_4ZQK"]["heavy_atom_contact_pairs"] >= 150
)
all_product_functions_resolved = bool(
serpinb9_func_status == "experimentally_verified"
and cd47_pan_allele_status == "experimentally_verified"
)
canonical_experimental_pdb_inventory = [
"1MHE", "3CDG", "3BZE", "2JJS", "4CMM", "4KJY", "4ZQK", "1IAU", "1EFX", "1IM9", "1BL4", "1JXQ", "1NW9"
]
challenger_iip0031_pdb_inventory = [
l2_cfh_prov["pdb_2wii"]["pdb_id"],
l2_cfh_prov["pdb_5o32"]["pdb_id"],
]
experimental_pdb_inventory = canonical_experimental_pdb_inventory + challenger_iip0031_pdb_inventory
mmcif_exp_count = sum(f"pdb_0000{acc.lower()}.cif" in STRUCTURAL_REFERENCE_SHA256 for acc in experimental_pdb_inventory)
legacy_pdb_exp_count = sum(f"{acc}.pdb" in STRUCTURAL_REFERENCE_SHA256 for acc in experimental_pdb_inventory)
if (
len(set(experimental_pdb_inventory)) != len(experimental_pdb_inventory)
or mmcif_exp_count + legacy_pdb_exp_count != len(experimental_pdb_inventory)
):
raise ValueError(
f"Inconsistent Layer-3 experimental PDB inventory: total={len(experimental_pdb_inventory)}, "
f"mmcif={mmcif_exp_count}, legacy_pdb={legacy_pdb_exp_count}"
)
atlas = {
"schema_version": "0.8.0",
"layer": "Layer 3 — 3D Structural & Protein Interface Verification Plane",
"status": ("COORDINATE_GEOMETRY_VERIFIED_PRODUCT_FUNCTION_UNRESOLVED_PENDING_WETLAB" if ref_geometry_passed else "COORDINATE_GEOMETRY_FAILED_PRODUCT_FUNCTION_UNRESOLVED_PENDING_WETLAB"),
"layer2_construct_fasta_sha256_linked": layer2_atlas["construct_sequence_and_grammar_verification"]["fasta_sha256"],
"summary": {
"total_experimental_pdb_structures_verified": len(experimental_pdb_inventory),
"experimental_rcsb_mmcif_structures_verified": mmcif_exp_count,
"experimental_rcsb_legacy_pdb_structures_verified": legacy_pdb_exp_count,
"canonical_experimental_pdb_structures_verified": len(canonical_experimental_pdb_inventory),
"challenger_iip0031_experimental_pdb_structures_verified": len(challenger_iip0031_pdb_inventory),
"experimental_pdb_accession_inventory": experimental_pdb_inventory,
"total_alphafold_v6_models_verified": 2,
"foldseek_databases_queried": ["pdb100", "afdb-swissprot"],
"complexes_verified": 4,
"icasp9_locus4_structural_reference_audit_status": icasp9_audit["qualification_status"],
"granzyme_b_1iau_insertion_code_safe_aligned_residues": 226,
"granzyme_b_1iau_insertion_code_safe_rmsd_angstrom": c3["granzyme_b_active_site_and_s1_pocket_1IAU"]["rmsd_AF_P10144_vs_1IAU_angstrom"],
"reference_coordinate_geometry_status": "PASS" if ref_geometry_passed else "FAIL",
"sequence_to_reference_identity_status": "QUALIFIED_NON_IDENTICAL_ENGINEERED_DIFFERENCES_DISCLOSED",
"serpinb9_2a_tail_functional_status": serpinb9_func_status,
"cd47_cys33_and_sirpa_pan_allelic_functional_status": cd47_pan_allele_status,
"exact_product_functional_qualification_status": (
"PASS" if all_product_functions_resolved else "UNRESOLVED_REQUIRES_WETLAB_KINETICS_AND_MEMBRANE_ASSAYS"
),
"all_reference_coordinate_geometric_screens_passed": ref_geometry_passed,
"canonical_l1_15aa_surface_geodesic_screen_d_lt_0p65_Lc_passed": False,
"challenger_l1_20aa_g4s4_surface_geodesic_screen_d_lt_0p65_Lc_passed": True,
"all_exact_product_functional_constraints_passed": all_product_functions_resolved,
"all_graveyard_and_r01_structural_constraints_passed": all_product_functions_resolved,
},
"complexes": [c1, c2, c3, c4],
"icasp9_locus4_structural_reference_audit": icasp9_audit,
"hlac_sct_kir2dl_f_pocket_clearance_and_self_peptide_audit_argon_r4": {
"evidence_class": "CRYSTALLOGRAPHIC_FOOTPRINT_AND_WLC_LINKER_CLEARANCE_MODEL_REQUIRES_GATE_0B_SCT_SPR_VERIFICATION",
"c1_subbank_hlac0304_kir2dl2_1EFX": {
"pdb_id": "1EFX",
"pdb_sha256": STRUCTURAL_REFERENCE_SHA256["1EFX.pdb"],
"evaluated_chains": {"hlac_heavy_chain": "A", "b2m": "B", "peptide": "C", "kir2dl2": "D"},
"citation": "Boyington et al. 2000 Nature PMID:10850706",
"product_variant_id": "ISLET1_B_SCT_C1_CIITA",
"self_peptide_9mer": "GAVDPLLAL",
"tethered_human_self_peptide": "GAVDPLLAL",
"self_peptide_source": "Human importin-alpha-2 / KPNA2 residues 204-212 in PDB:1EFX header (KPNA1/KPNA2 conserved nonamer; P2=Ala, P7=Leu, P8=Ala, P9=Leu; replaces viral Influenza A M1 58-66 GILGFVFTL)",
"native_kir2dl2_kd_uM": 7.2,
"p9_leu_c_to_kir2dl2_ser184_og_angstrom_in_1EFX": _pdb_dist(efx_coords, ("C", 9, "C"), ("D", 184, "OG")),
"kir2dl2_f_pocket_contact_residues": ["HLA-C Val76", "Ser77", "Asn80 (C1 specificity)", "Arg84/Tyr84", "Thr143", "Lys146", "Ala150", "Peptide P7=Leu", "Peptide P8=Ala"],
"f_pocket_exit_engineering": "HLA-C*03:04 Tyr84Ala (or Tyr84Cys-Linker[Cys2] disulfide-trapped) lateral F-pocket exit channel routing the 20-aa (G4S)4 L1 linker beneath the alpha-1 C-terminal rim so it does not collide with KIR2DL2/3 Lys44/Phe45/Gln71/Ser184/Glu187",
"l1_linker_wlc_metrics_20aa_g4s4": worm_like_chain_metrics(20, _pdb_dist(efx_coords, ("C", 9, "C"), ("B", 1, "N"))),
"l2_linker_wlc_metrics_20aa_g4s4": worm_like_chain_metrics(20, _pdb_dist(efx_coords, ("B", 99, "C"), ("A", 2, "N"))),
},
"c2_subbank_hlac0401_kir2dl1_1IM9": {
"pdb_id": "1IM9",
"pdb_sha256": STRUCTURAL_REFERENCE_SHA256["1IM9.pdb"],
"evaluated_chains": {"kir_bound_complex": {"hlac_heavy_chain": "A", "b2m": "B", "peptide": "C", "kir2dl1": "D"}, "kir_free_copy_in_asu": {"hlac_heavy_chain": "E", "b2m": "F", "peptide": "G"}},
"citation": "Fan et al. 2001 Nat Immunol PMID:11323700; Fan & Wiley 1999 J Exp Med PMID:10429675",
"product_variant_id": "ISLET1_B_SCT_C2_CIITA",
"self_peptide_9mer": "QYDDAVYKL",
"tethered_consensus_peptide": "QYDDAVYKL",
"self_peptide_source": "HLA-Cw4 crystallographic consensus nonamer designed from pool sequencing and crystallized in PDB:1IM9 (P2=Tyr, P7=Tyr, P8=Lys, P9=Leu; Fan & Wiley 1999 PMID:10429675; paired with endogenous HLA-C*04:01 self-peptide challenger in Gate 0B-SCT)",
"native_kir2dl1_kd_uM": 7.2,
"native_kir2ds1_kd_uM": 30.0,
"p9_leu_c_to_kir2dl1_glu187_oe1_angstrom_in_1IM9": _pdb_dist(im9_coords, ("C", 9, "C"), ("D", 187, "OE1")),
"kir2dl1_f_pocket_contact_residues": ["HLA-C Val76", "Asn77", "Lys80 (C2 specificity)", "Tyr84", "Thr143", "Lys146", "Ala150", "Peptide P7=Tyr", "Peptide P8=Lys"],
"f_pocket_exit_engineering": "HLA-C*04:01 Tyr84Ala lateral F-pocket exit channel routing the 20-aa (G4S)4 L1 linker away from KIR2DL1 Met44/Phe45/Ser184/Glu187",
"l1_linker_wlc_metrics_20aa_g4s4": worm_like_chain_metrics(20, _pdb_dist(im9_coords, ("C", 9, "C"), ("B", 1, "N"))),
"l2_linker_wlc_metrics_20aa_g4s4": worm_like_chain_metrics(20, _pdb_dist(im9_coords, ("B", 99, "C"), ("A", 2, "N"))),
},
"f_pocket_lateral_channel_mutation_required_for_hlac_sct": {
"engineered_groove_mutation": "Tyr84Ala (Y84A)",
"disulfide_trap_comparators_disentangled_kimi31_r4": {
"L3_B_SCT_Y84A_L1_20AA": "Canonical Y84A F-pocket lateral channel with 20-aa (G4S)4 L1 linker (0 engineered cysteines; loses native Tyr84:OH-Leu9:OXT H-bond [3.5169 A in 1EFX, 2.8531 A in 1IM9] and Tyr84-KIR Asp183 contact [3.5584 A / 3.2425 A])",
"L3_B_SCT_WTY84_L1_25AA": "Intact WT Tyr84 with extended 25-aa (G4S)5 L1 linker routing around the F-pocket rim (0 engineered cysteines; preserves Tyr84-KIR Asp183 contact while testing whether peptide-bond conversion of P9:OXT is tolerated)",
"L3_B_SCT_DT1_Y84C_L1CYS2": "Peptide-linker disulfide trap: HLA-C(Y84C, A139-WT) or HLA-C(Y84A, A139C) + L1 = GCGGS(G4S)3 (2 engineered cysteines forming a single disulfide bond that covalently locks the tethered peptide C-terminus in the F-pocket against thermal/competitive displacement; Truscott et al. 2007 J Immunol PMID:17475856; Finton et al. 2023 PMID:37207206)",
"L3_B_SCT_DT2_Y84C_A139C": "Alpha1-alpha2 F-pocket staple: HLA-C(Y84C/A139C) + non-cysteine (G4S)4 L1 (2 engineered cysteines forming an intra-heavy-chain Y84C-to-A139C disulfide staple; per Finton et al. 2023 Front Immunol PMID:37207206 Results §2.8, Y84C/A139C alone stabilizes the groove rim whereas preventing competitive high-affinity peptide exchange in their MHC-I SCT screen required adding T143A + W147A, which on HLA-C must be weighed against KIR2DL binding; never combined with L1-Cys to avoid a 3-cysteine scramble)",
},
"structural_rationale": (
"Unlike CD94/NKG2A (which tolerates intact Tyr84 on HLA-E because CD94 sits high above the alpha1/alpha2 helices in PDB:3CDG), "
"KIR2DL1/2/3 D1/D2 loops clamp directly onto the HLA-C F-pocket C-terminal rim (Res 76, 80, 84, 143, 146) and peptide P7-P8 "
"(Boyington et al. 2000 PMID:10850706; Fan et al. 2001 PMID:11323700). Substituting Tyr84Ala opens a lateral exit channel so the "
"20-aa (G4S)4 L1 linker exits laterally beneath the alpha1 helix without upward displacement into the KIR2DL1/2/3 footprint."
),
},
"mandatory_stage0_gate_0b_sct": (
"Monomeric KIR2DL2 / KIR2DL3 (for C1 HLA-C*03:04:GAVDPLLAL SCT) and monomeric KIR2DL1 (for C2 HLA-C*04:01:QYDDAVYKL SCT) "
"SPR K_D <= 10.29 uM (>= 70% of native monomeric K_D = 7.2 uM; <= 15.0 uM dimeric KIR-Fc screen), primary sorted KIR2DS1+/KIR2DL1- NK non-activation (CD107a <= 10%, 4-h lysis <= 10%) on C2 arms, negative recipient anti-HLA-C CDC/ADCC serum crossmatch, negative recipient CD8+ MLC across all recipients, and < 10% Hour-0 lysis by primary NKG2A- KIR2DL+ NK cells (AUDIT-REF & AUDIT-REF)."
),
"native_1efx_1im9_tyr84_kir_asp183_contact_deletion_and_kir2ds1_audit_sol61_r4": {
"primary_citations": ["PMID:10850706", "PMID:11323700", "PMID:33846289", "PMID:17475856", "PMID:37207206", "PMID:10429675", "PMID:16141329", "PMID:23554313"],
"pdb_3cdg_hlae_tyr84_to_cd94_nkg2a_nearest_heavy_atom_geometry": {
"copy1_hlae_A_tyr84_oh_to_cd94_J_asn160_nd2_angstrom": 9.0068,
"copy2_hlae_C_tyr84_oh_to_cd94_E_asn160_nd2_angstrom": 8.7331,
"hlae_tyr84_to_cd94_nkg2a_heavy_atom_pairs_within_4p5A": 0,
},
"pdb_1efx_hlac0304_gavdpllal_kir2dl2_native_geometry": {
"evaluated_chains": "A (HLA-C*03:04), B (B2M), C (GAVDPLLAL, KPNA2 204-212), D (KIR2DL2)",
"tyr84_oh_to_kir2dl2_asp183_od2_distance_angstrom": _pdb_dist(efx_coords, ("A", 84, "OH"), ("D", 183, "OD2")),
"tyr84_to_kir2dl2_heavy_atom_pairs_within_4p5A": 4,
"tyr84_oh_to_peptide_leu9_o_angstrom": _pdb_dist(efx_coords, ("A", 84, "OH"), ("C", 9, "O")),
"tyr84_oh_to_peptide_leu9_oxt_angstrom": _pdb_dist(efx_coords, ("A", 84, "OH"), ("C", 9, "OXT")),
"thr143_og1_to_peptide_leu9_oxt_hydrogen_bond_angstrom": _pdb_dist(efx_coords, ("A", 143, "OG1"), ("C", 9, "OXT")),
"ser77_og_to_peptide_leu9_o_distance_angstrom": _pdb_dist(efx_coords, ("A", 77, "OG"), ("C", 9, "O")),
"asn80_nd2_to_peptide_leu9_o_hydrogen_bond_angstrom": _pdb_dist(efx_coords, ("A", 80, "ND2"), ("C", 9, "O")),
"lys146_nz_to_peptide_leu9_o_distance_angstrom": _pdb_dist(efx_coords, ("A", 146, "NZ"), ("C", 9, "O")),
"lys146_nz_to_peptide_leu9_oxt_distance_angstrom": _pdb_dist(efx_coords, ("A", 146, "NZ"), ("C", 9, "OXT")),
"lys146_nz_to_kir2dl2_asp183_od2_salt_bridge_angstrom": _pdb_dist(efx_coords, ("A", 146, "NZ"), ("D", 183, "OD2")),
"lys146_nz_to_kir2dl2_glu187_oe1_distance_angstrom": _pdb_dist(efx_coords, ("A", 146, "NZ"), ("D", 187, "OE1")),
"lys146_nz_to_peptide_leu9_o_hydrogen_bond_angstrom": _pdb_dist(efx_coords, ("A", 146, "NZ"), ("C", 9, "O")),
"tyr84_oh_to_peptide_leu9_oxt_hydrogen_bond_angstrom": _pdb_dist(efx_coords, ("A", 84, "OH"), ("C", 9, "OXT")),
"native_l1_p9_c_to_b2m_ile1_n_euclidean_span_angstrom": _pdb_dist(efx_coords, ("C", 9, "C"), ("B", 1, "N")),
"native_l1_p9_c_to_b2m_met0_n_euclidean_span_angstrom": _pdb_dist(efx_coords, ("C", 9, "C"), ("B", 0, "N")),
"native_l2_b2m_met99_c_to_hlac_gly1_n_euclidean_span_angstrom": _pdb_dist(efx_coords, ("B", 99, "C"), ("A", 1, "N")),
"native_l2_b2m_met99_c_to_hlac_ser2_n_euclidean_span_angstrom": _pdb_dist(efx_coords, ("B", 99, "C"), ("A", 2, "N")),
"l1_open_chord_heavy_atom_obstacles_within_4p0A_excl_endpoints": {
"wt_all_heavy_atoms": 31,
"wt_sidechain_plus_cbeta_atoms": 23,
"y84a_all_heavy_atoms": 31,
"y84a_sidechain_plus_cbeta_atoms": 23,
},
},
"pdb_1im9_hlac0401_qyddavykl_kir2dl1_native_geometry": {
"evaluated_chains": "A (HLA-C*04:01), B (B2M), C (QYDDAVYKL), D (KIR2DL1) [KIR-bound complex; KIR-free copy is E/F/G]",
"tyr84_ce1_to_kir2dl1_asp183_od2_distance_angstrom": _pdb_dist(im9_coords, ("A", 84, "CE1"), ("D", 183, "OD2")),
"tyr84_oh_to_kir2dl1_asp183_od2_distance_angstrom": _pdb_dist(im9_coords, ("A", 84, "OH"), ("D", 183, "OD2")),
"tyr84_to_kir2dl1_heavy_atom_pairs_within_4p5A": 8,
"tyr84_oh_to_peptide_leu9_o_angstrom": _pdb_dist(im9_coords, ("A", 84, "OH"), ("C", 9, "O")),
"tyr84_oh_to_peptide_leu9_oxt_angstrom": _pdb_dist(im9_coords, ("A", 84, "OH"), ("C", 9, "OXT")),
"thr143_og1_to_peptide_leu9_oxt_kir_bound_AC_angstrom": _pdb_dist(im9_coords, ("A", 143, "OG1"), ("C", 9, "OXT")),
"thr143_og1_to_peptide_leu9_oxt_kir_free_EG_angstrom": _pdb_dist(im9_coords, ("E", 143, "OG1"), ("G", 9, "OXT")),