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…
"serpinb9_rcl_335_345_to_core_1_322_mean_pae_angstrom": sb9_rcl_to_core_pae_mean,
"aligned_rcl_335_345_scored_core_1_322_mean_pae_angstrom": sb9_rcl_to_core_pae_mean,
"aligned_core_1_322_scored_rcl_335_345_mean_pae_angstrom": sb9_core_to_rcl_pae_mean,
"pae_row_aligned_col_scored_convention_astra_r3": {
"convention_note": (
"Per the official AlphaFold DB PAE v6 specification (predicted_aligned_error[i][j]), row index i is the ALIGNED residue and column index j is the SCORED residue "
"(expected positional error at residue j when the structure is aligned on residue i): therefore pae[334:345, :322] = 27.29 A is rows RCL 335-345 (aligned) / cols core 1-322 (scored), "
"pae[:322, 334:345] = 15.20 A is rows core 1-322 (aligned) / cols RCL 335-345 (scored), pae[375:376, 334:345] = 21.27 A is row Pro376 (aligned) / cols RCL 335-345 (scored), "
"pae[334:345, 375:376] = 25.45 A is rows RCL 335-345 (aligned) / col Pro376 (scored), pae[371:376, 334:350] = 13.24 A is rows 372-376 (aligned) / cols RCL 335-350 (scored), "
"and pae[334:350, 371:376] = 19.90 A is rows RCL 335-350 (aligned) / cols 372-376 (scored) (AUDIT-REF & AUDIT-REF)."
),
"pae_rows_rcl_335_345_aligned_cols_core_1_322_scored_mean_angstrom": sb9_rows_rcl_aligned_cols_core_scored_pae_mean,
"pae_rows_core_1_322_aligned_cols_rcl_335_345_scored_mean_angstrom": sb9_rows_core_aligned_cols_rcl_scored_pae_mean,
"pae_row_pro376_aligned_cols_rcl_335_345_scored_mean_angstrom": sb9_row_pro376_aligned_cols_rcl_335_345_scored_pae_mean,
"pae_rows_rcl_335_345_aligned_col_pro376_scored_mean_angstrom": sb9_rows_rcl_335_345_aligned_col_pro376_scored_pae_mean,
"pae_rows_cterm_372_376_aligned_cols_rcl_335_350_scored_mean_angstrom": sb9_rows_cterm_372_376_aligned_cols_rcl_335_350_scored_pae_mean,
"pae_rows_rcl_335_350_aligned_cols_cterm_372_376_scored_mean_angstrom": sb9_rows_rcl_335_350_aligned_cols_cterm_372_376_scored_pae_mean,
},
"pae_row_scored_col_aligned_convention_kimi31_r3": {
"convention_note": (
"Corrected in AUDIT-REF and AUDIT-REF to match official AlphaFold DB PAE v6 row=aligned / col=scored semantics: "
"aligned on core 1-322 (rows :322) / scored on RCL 335-345 (cols 334:345) is 15.20 A, and aligned on RCL 335-345 (rows 334:345) / scored on core 1-322 (cols :322) is 27.29 A "
"(AUDIT-REF & AUDIT-REF)."
),
"pae_rows_rcl_335_345_aligned_cols_core_1_322_scored_mean_angstrom": sb9_rows_rcl_aligned_cols_core_scored_pae_mean,
"pae_rows_core_1_322_aligned_cols_rcl_335_345_scored_mean_angstrom": sb9_rows_core_aligned_cols_rcl_scored_pae_mean,
"pae_row_pro376_aligned_cols_rcl_335_345_scored_mean_angstrom": sb9_row_pro376_aligned_cols_rcl_335_345_scored_pae_mean,
"pae_rows_rcl_335_345_aligned_col_pro376_scored_mean_angstrom": sb9_rows_rcl_335_345_aligned_col_pro376_scored_pae_mean,
"pae_rows_cterm_372_376_aligned_cols_rcl_335_350_scored_mean_angstrom": sb9_rows_cterm_372_376_aligned_cols_rcl_335_350_scored_pae_mean,
"pae_rows_rcl_335_350_aligned_cols_cterm_372_376_scored_mean_angstrom": sb9_rows_rcl_335_350_aligned_cols_cterm_372_376_scored_pae_mean,
},
"granzyme_b_mature_21_246_mean_pae_angstrom": gzmb_mature_21_246_pae_mean,
"granzyme_b_mature_21_247_mean_pae_angstrom": gzmb_mature_21_247_pae_mean,
},
"p1_glu340_plddt": round(plddt_glu340, 2),
"p1_prime_cys341_plddt": round(plddt_cys341, 2),
"literature_native_wt_k_ass_M_inv_s_inv": 1.7e6,
"literature_native_wt_stoichiometry_of_inhibition_SI": 1.0,
"pro376_c_terminus_to_p1_glu340_ca_distance_angstrom": round(dist_pro376_to_glu340, 2),
"pro376_c_terminus_to_p1_prime_cys341_ca_distance_angstrom": round(dist_pro376_to_cys341, 2),
"pro376_c_terminus_to_rcl_hinge_val322_ca_distance_angstrom": round(dist_pro376_to_val322, 2),
"min_heavy_atom_distance_cterm_372_376_to_rcl_335_345_angstrom": round(min_heavy_dist_cterm_to_rcl, 2),
"pro376_only_min_heavy_atom_distance_to_rcl_335_345_angstrom": round(min_heavy_dist_pro376_only_to_rcl, 2),
"pro376_c_peptide_bond_anchor_to_rcl_335_345_angstrom": round(min_heavy_dist_pro376_c_to_rcl_335_345, 2),
"min_heavy_atom_distance_cterm_372_376_to_rcl_337_346_angstrom": round(min_heavy_dist_cterm_to_rcl_337_346, 2),
"pro376_only_min_heavy_atom_distance_to_rcl_337_346_angstrom": round(min_heavy_dist_pro376_only_to_rcl_337_346, 2),
"min_heavy_atom_distance_cterm_372_376_to_rcl_335_350_angstrom": round(min_heavy_dist_cterm_to_rcl_335_350, 2),
"pro376_only_min_heavy_atom_distance_to_rcl_335_350_angstrom": round(min_heavy_dist_pro376_only_to_rcl_335_350, 2),
"pro376_c_peptide_bond_anchor_to_rcl_335_350_angstrom": round(min_heavy_dist_pro376_c_to_rcl_335_350, 2),
"min_heavy_atom_distance_cterm_372_376_to_proximal_hinge_318_334_angstrom": round(min_heavy_dist_cterm_to_hinge_318_334, 2),
"pro376_only_min_heavy_atom_distance_to_proximal_hinge_318_334_angstrom": round(min_heavy_dist_pro376_only_to_hinge_318_334, 2),
"pro376_c_peptide_bond_anchor_to_proximal_hinge_318_334_angstrom": round(min_heavy_dist_pro376_c_to_hinge_318_334, 2),
"s_to_r_and_acyl_enzyme_structural_qualification": (
"Unmodified AF-P50453-F1 models only the stressed (S) native monomer prior to Granzyme B docking, "
"and PDB:8ZCR (superseding 8H4X) resolves only the RCL-cleaved relaxed (R) state without a C-terminal 2A extension; "
"neither structure resolves the 1:1 covalent SERPINB9:Granzyme B acyl-enzyme trap or S->R beta-sheet A insertion kinetics."
),
"rcl_low_plddt_and_high_pae_coordinate_uncertainty_qualification_sonnet55_r2": (
"Because AF-P50453-F1 predicts mobile RCL residues at low local coordinate confidence (residues 335-350 coordinate mean pLDDT = 53.30; "
"recognition loop 335-345 coordinate mean = 36.21 [min 25.48 at Cys335, 29.20 at P1'-Cys341, max 59.00 at Ser345]; hinge-to-P3' loop 322-348 coordinate mean = 48.36; "
"P1-Glu340 = 31.52, P1'-Cys341 = 29.20; global coordinate mean = 91.16 [AFDB v6 summary API metadata = 91.19; AF-P10144-F1 global coordinate mean = 92.41, API summary = 92.44]) "
"and high inter-domain positional uncertainty relative to the serpin beta-sheet core (RCL 335-345 vs core 1-322 mean PAE = 27.29 A; aligned core 1-322 scored RCL 335-345 mean PAE = 15.20 A; single rigid domain 1-325), "
"static Pro376->RCL heavy-atom clearances (26.13 A [28.57 A from Pro376.C] to 335-345, 12.55 A [15.07 A from Pro376.C] to s1C Cys350, 10.40 A [11.21 A from Pro376.C; 12.02 A CA-CA] to hinge Val322) are accompanied by 15.20-27.29 A AlphaFold directional expected positional error (PAE, which is an expected pairwise alignment error in Angstroms rather than a calibrated symmetric +/- probabilistic confidence interval) "
"and are order-of-magnitude geometric priors that cannot substitute for Decision Experiment #3 recombinant GzmB k_ass and SI measurements (S55R2-D3-05, AUDIT-REF, AUDIT-REF & AUDIT-REF)."
),
"c_terminal_2a_extension_polymer_reach_models": tail_ensemble_models,
"structural_and_conformational_uncertainty_note": (
f"In unmodified AF-P50453-F1, Pro376 is {dist_pro376_to_glu340:.2f} A from P1-Glu340 CA, {dist_pro376_to_val322:.2f} A from proximal-hinge Val322 CA, "
f"and {min_heavy_dist_cterm_to_rcl:.2f} A (C-terminal sheet 372-376 Phe373.CE1<->Ser345.CB; {min_heavy_dist_pro376_only_to_rcl:.2f} A Pro376-only Pro376.CG<->Ser345.CB; "
f"{min_heavy_dist_pro376_c_to_rcl_335_345:.2f} A from peptide-bond anchor Pro376.C<->Ser345.CB) from RCL recognition residues 335-345 "
f"({min_heavy_dist_cterm_to_rcl_337_346:.2f} A from 372-376 / {min_heavy_dist_pro376_only_to_rcl_337_346:.2f} A Pro376-only to 337-346 via Gly346.O; "
f"{min_heavy_dist_cterm_to_rcl_335_350:.2f} A from 372-376 [Phe373.CD1<->Cys350.C] / {min_heavy_dist_pro376_only_to_rcl_335_350:.2f} A Pro376-only [Pro376.CD<->Cys350.O] / {min_heavy_dist_pro376_c_to_rcl_335_350:.2f} A Pro376.C across full mobile RCL 335-350 including s1C anchor Cys350; "
f"{min_heavy_dist_cterm_to_hinge_318_334:.2f} A from 372-376 [Phe373.CD2<->Val322.CG2] / {min_heavy_dist_pro376_only_to_hinge_318_334:.2f} A Pro376-only [Pro376.OXT<->Val322.O] / {min_heavy_dist_pro376_c_to_hinge_318_334:.2f} A Pro376.C to proximal hinge 318-334; "
f"unmodified serpin-intrinsic heavy-atom distances; no bound SERPINB9:Granzyme B complex structure is claimed). "
f"The mobile RCL has low local prediction confidence (residues 335-350 mean pLDDT = {float(np.mean(rcl_mobile_loop_335_350_plddts)):.2f}, "
f"335-345 mean pLDDT = {float(np.mean(rcl_recognition_335_345_plddts)):.2f}, Glu340 = {plddt_glu340:.2f}, Cys341 = {plddt_cys341:.2f}); "
f"while the 21-aa WLC RMS extension (23.58 A) is below both the {min_heavy_dist_cterm_to_rcl:.2f} A (372-376) and {min_heavy_dist_pro376_c_to_rcl_335_345:.2f} A (Pro376.C anchor) P6-P5' recognition-loop clearances, "
f"it exceeds the {min_heavy_dist_cterm_to_rcl_335_350:.2f} A / {min_heavy_dist_pro376_c_to_rcl_335_350:.2f} A s1C (Cys350) and {min_heavy_dist_cterm_to_hinge_318_334:.2f} A / {min_heavy_dist_pro376_c_to_hinge_318_334:.2f} A proximal-hinge (Val322) clearances, "
f"and its 73.50 A contour upper bound (as well as 26-aa 91.0 A and 50-aa 175.0 A contours) exceeds {min_heavy_dist_cterm_to_rcl:.2f} A. "
"Whether the 21-aa GSG-P2A stub perturbs S->R serpin loop insertion must be resolved empirically "
"by measuring k_ass and SI against recombinant human Granzyme B alongside a 2A-free control (Decision Experiment #3)."
),
},
}
def analyze_complex_4_pdl1_pd1(layer2_ledger: Dict[str, Any]) -> Dict[str, Any]:
"""Analyze Complex 4: PD-L1 (CD274) : PD-1 (PDCD1) (PDB: 4ZQK)."""
snapshots = verify_structural_reference_inputs("pdb_00004zqk.cif")
atoms_4zqk = parse_mmcif_atoms(STRUCT_DIR / "pdb_00004zqk.cif", source_bytes=snapshots["pdb_00004zqk.cif"])
pdl1_4zqk = filter_polymer_atoms(atoms_4zqk, ["A"], (18, 132))
pdl1_4zqk_mature_19_132 = filter_polymer_atoms(atoms_4zqk, ["A"], (19, 132))
pd1_4zqk = filter_polymer_atoms(atoms_4zqk, ["B"], (33, 150))
interface_4zqk = compute_interface_metrics(pdl1_4zqk, pd1_4zqk)
interface_4zqk_mature_19_132 = compute_interface_metrics(pdl1_4zqk_mature_19_132, pd1_4zqk)
if interface_4zqk["heavy_atom_contact_pairs"] != interface_4zqk_mature_19_132["heavy_atom_contact_pairs"]:
raise ValueError("Cloning artifact Ala18 unexpectedly contributed PD-1 interface contacts in 4ZQK")
interface_4zqk["chain_a_resolved_residue_range_audit"] = {
"pdb_4zqk_chain_a_resolved_span": (
"Ala18..Ala132 (115 residues; Zak et al. 2015 PMID:26602187 Experimental Procedures expressed human PD-L1 residues 18..134 "
"[where Ala18 is the native precursor residue immediately preceding mature Phe19] and human PD-1 residues 33..150 C93S, "
"resolving 115 PD-L1 residues Ala18..Ala132 including 114 mature positions Phe19..Ala132, with C-terminal residues 133..134 unmodeled; AUDIT-REF)"
),
"ala18_heavy_atom_contacts_to_pd1": 0,
"mature_19_132_heavy_atom_contact_pairs": interface_4zqk_mature_19_132["heavy_atom_contact_pairs"],
"mature_19_132_unique_residue_contact_pairs": interface_4zqk_mature_19_132["unique_residue_contact_pairs"],
"note_on_pdb_3bze": "PDB:3BZE is an HLA-E*01:01/B2M/VMAPRTLFL complex structure (Chain A: 273 HLA-E heavy-chain residues Ser2..Trp274 analyzed in Complex 1), NOT a PD-L1 structure.",
}
phe19_ca = get_atom_coord(atoms_4zqk, "A", 19, "CA")
pd1_coords = np.array([[a["x"], a["y"], a["z"]] for a in pd1_4zqk if a["element"] != "H"])
dist_nterm_to_pd1 = float(np.min(np.linalg.norm(pd1_coords - phe19_ca, axis=1)))
phe19_atoms = [a for a in pdl1_4zqk if a["seq_id"] == 19 and a["element"] != "H"]
phe19_coords = np.array([[a["x"], a["y"], a["z"]] for a in phe19_atoms], dtype=np.float64)
dist_nterm_min_heavy_to_pd1 = float(np.min(np.linalg.norm(phe19_coords[:, None, :] - pd1_coords[None, :, :], axis=-1)))
pdl1_prod = layer2_ledger["PDL1_mature_cell_surface"]
return {
"complex_id": "LAYER3_COMPLEX_4_PDL1_PD1",
"locus": "Locus 3 (CXCL10 Exon-1 KI: CXCL10::SERPINB9-GSG-P2A-PD-L1)",
"engineered_protein": "Human PD-L1 (CD274, downstream of GSG-P2A: Pro+M1..A18 signal peptide cleaved -> native F19..T290 protein)",
"layer2_processed_polypeptide_hashes": {
"PDL1_mature_272aa_sha256": pdl1_prod["sha256"],
},
"experimental_structures_analyzed": [
{
"pdb_id": "4ZQK",
"resolution_angstrom": 2.45,
"pmid": "26602187",
"citation": "Zak et al. 2015 Structure",
"description": "Crystal structure of the human PD-1 / PD-L1 ectodomain complex",
"sha256": hashlib.sha256(snapshots["pdb_00004zqk.cif"]).hexdigest(),
}
],
"pdl1_to_pd1_interface_4ZQK": interface_4zqk,
"translocation_and_cys272_palmitoylation_verification": {
"evidence_class": "ectodomain_crystal_geometry_plus_signal_peptidase_topology_rationale",
"pdl1_c_terminal_tail_and_cys272_resolved_in_4zqk": False,
"graveyard_rule_verified": "Locus 3 translation order (Cytosolic SERPINB9 upstream -> ER-targeted PD-L1 downstream)",
"mature_n_terminus_phe19_distance_to_pd1_angstrom": round(dist_nterm_to_pd1, 2),
"mature_n_terminus_phe19_ca_distance_to_pd1_angstrom": round(dist_nterm_to_pd1, 2),
"mature_n_terminus_phe19_min_heavy_atom_distance_to_pd1_angstrom": round(dist_nterm_min_heavy_to_pd1, 3),
"literature_kd_pdl1_pd1_uM": 8.2,
"kd_pdl1_pd1_uM": 8.2,
"cheng_2013_table2_soluble_kd_pdl1_pd1_uM": 8.2,
"cheng_2013_table2_soluble_kd_pdl1_pd1_sd_uM": 0.1,
"cheng_2013_table2_soluble_kd_pdl1_cd80_b7_1_analyte_uM": 18.8,
"cheng_2013_soluble_3d_spr_kd_pdl1_fc_cd80_uM": 18.8,
"cheng_2013_table2_soluble_kd_pdl1_cd80_b7_1_analyte_sd_uM": 3.8,
"cheng_2013_table2_soluble_kd_pdl1_cd80_reverse_orientation_uM": 35.4,
"cheng_2013_table2_soluble_kd_pdl1_cd80_reverse_orientation_sd_uM": 4.4,
"historical_soluble_3d_avidity_kd_pdl1_cd80_uM": 1.7,
"literature_kd_pdl1_cd80_cis_uM": 1.7,
"kd_pdl1_cd80_cis_uM": 1.7,
"legacy_key_alias_note_kimi31_r3": (
"literature_kd_pdl1_cd80_cis_uM and kd_pdl1_cd80_cis_uM are retained as legacy schema aliases for backward compatibility "
"and store the ~1.7 uM historical bivalent Fc-fusion 3D SPR avidity baseline cited in Cheng et al. 2013 Table 2 "
"(canonical key: historical_soluble_3d_avidity_kd_pdl1_cd80_uM; monomeric 3D SPR is 18.8 +/- 3.8 uM / 35.4 +/- 4.4 uM, "
"and true 2D membrane cis-heterodimerization is unmeasured in 3D molar units: exact_product_membrane_2d_cis_kd_molecules_per_um2 = None; AUDIT-REF)."
),
"exact_product_membrane_2d_cis_kd_molecules_per_um2": None,
"pdl1_cd80_affinity_provenance_note_astra_r1": (
"Cheng et al. 2013 (PMID:23417675 Table 2) measured 3D soluble human PD-L1:PD-1 K_D = 8.2 +/- 0.1 uM and soluble "
"PD-L1:CD80 (B7-1) K_D = 18.8 +/- 3.8 uM (35.4 +/- 4.4 uM in reverse immobilization), and contrasted this with a historical ~1.7 uM "
"soluble/immobilized SPR report (hB7-1 injected over immobilized hPD-L1; whereas true 2D membrane cis-heterodimerization on co-expressing "
"membranes per Zhao et al. 2019 PMID:31757674 is governed by surface receptor densities in molecules/um^2 rather than a 3D molar K_D; AUDIT-REF); "
"because resting human SC-beta cells lack constitutive CD80 expression, trans PD-1 engagement is not expected to be limited by CD80-dependent cis "
"sequestration unless CD80 is ectopically induced, subject to direct functional PD-1 reporter/T-cell verification (AUDIT-REF & AUDIT-REF)."
),
"scope_and_limitations_note": (
"Positioning PD-L1 downstream of 2A preserves its native C-terminal cytoplasmic tail (Cys272/CMTM6 motif); "
"however, signal-peptidase cleavage efficiency of the Pro-prefixed signal peptide and absence of unskipped "
"SERPINB9-PD-L1 read-through product must be verified by anti-PD-L1 / anti-SERPINB9 Western blot."
),
},
}
def analyze_icasp9_locus4_structural_reference_audit(layer2_ledger: Dict[str, Any]) -> Dict[str, Any]:
"""Audit experimentally resolved reference domains for Locus 4 iCasp9 (IIP-0011 / DEC-090)."""
aa3_to_1 = {
"ALA": "A", "ARG": "R", "ASN": "N", "ASP": "D", "CYS": "C",
"GLN": "Q", "GLU": "E", "GLY": "G", "HIS": "H", "ILE": "I",
"LEU": "L", "LYS": "K", "MET": "M", "PHE": "F", "PRO": "P",
"SER": "S", "THR": "T", "TRP": "W", "TYR": "Y", "VAL": "V",
}
ic_entry = layer2_ledger["iCasp9_cytosolic_monomer"]
ic_seq = ic_entry["sequence"]
if len(ic_seq) != 396:
raise ValueError(f"Expected 396-aa iCasp9_cytosolic_monomer, got {len(ic_seq)}")
fkbp_seq = ic_seq[:108]
linker_6aa = ic_seq[108:114]
casp9_g135_s416 = ic_seq[114:]