def analyze_complex_2_cd47_sirpa(layer2_ledger: Dict[str, Any]) -> Dict[str, Any]: """Analyze Complex 2: CD47-IgV-GPI : SIRPalpha V1 & V2.""" snapshots = verify_structural_reference_inputs("pdb_00002jjs.cif", "pdb_00004cmm.cif", "pdb_00004kjy.cif") atoms_2jjs = parse_mmcif_atoms(STRUCT_DIR / "pdb_00002jjs.cif", source_bytes=snapshots["pdb_00002jjs.cif"]) atoms_4cmm = parse_mmcif_atoms(STRUCT_DIR / "pdb_00004cmm.cif", source_bytes=snapshots["pdb_00004cmm.cif"]) atoms_4kjy = parse_mmcif_atoms(STRUCT_DIR / "pdb_00004kjy.cif", source_bytes=snapshots["pdb_00004kjy.cif"]) cd47_2jjs = filter_polymer_atoms(atoms_2jjs, ["C"], (1, 125), include_hetatm_peptides=True) sirpa_2jjs = filter_polymer_atoms(atoms_2jjs, ["A"], (1, 125), include_hetatm_peptides=True) interface_2jjs = compute_interface_metrics(cd47_2jjs, sirpa_2jjs) cd47_4cmm = filter_polymer_atoms(atoms_4cmm, ["B"], (1, 125), include_hetatm_peptides=True) sirpa_4cmm = filter_polymer_atoms(atoms_4cmm, ["A"], (1, 125), include_hetatm_peptides=True) interface_4cmm = compute_interface_metrics(cd47_4cmm, sirpa_4cmm) cd47_4kjy = filter_polymer_atoms(atoms_4kjy, ["A"], (1, 125), include_hetatm_peptides=True) sirpa_4kjy = filter_polymer_atoms(atoms_4kjy, ["B"], (1, 125), include_hetatm_peptides=True) interface_4kjy = compute_interface_metrics(cd47_4kjy, sirpa_4kjy) atoms_4cmm_altb = parse_mmcif_atoms(STRUCT_DIR / "pdb_00004cmm.cif", source_bytes=snapshots["pdb_00004cmm.cif"], allowed_alt_ids=(".", "?", "B")) interface_4cmm_altb = compute_interface_metrics( filter_polymer_atoms(atoms_4cmm_altb, ["B"], (1, 125), include_hetatm_peptides=True), filter_polymer_atoms(atoms_4cmm_altb, ["A"], (1, 125), include_hetatm_peptides=True), ) atoms_4kjy_altb = parse_mmcif_atoms(STRUCT_DIR / "pdb_00004kjy.cif", source_bytes=snapshots["pdb_00004kjy.cif"], allowed_alt_ids=(".", "?", "B")) interface_4kjy_altb = compute_interface_metrics( filter_polymer_atoms(atoms_4kjy_altb, ["A"], (1, 125), include_hetatm_peptides=True), filter_polymer_atoms(atoms_4kjy_altb, ["B"], (1, 125), include_hetatm_peptides=True), ) ca_2jjs = get_ca_map(atoms_2jjs, "C") ca_4cmm = get_ca_map(atoms_4cmm, "B") ca_4kjy = get_ca_map(atoms_4kjy, "A") common_cd47 = sorted(set(range(2, 116)) & set(ca_2jjs.keys()) & set(ca_4cmm.keys()) & set(ca_4kjy.keys())) c_2jjs = np.array([[ca_2jjs[r]["x"], ca_2jjs[r]["y"], ca_2jjs[r]["z"]] for r in common_cd47]) c_4cmm = np.array([[ca_4cmm[r]["x"], ca_4cmm[r]["y"], ca_4cmm[r]["z"]] for r in common_cd47]) c_4kjy = np.array([[ca_4kjy[r]["x"], ca_4kjy[r]["y"], ca_4kjy[r]["z"]] for r in common_cd47]) rmsd_4cmm_vs_2jjs, _, _ = kabsch_rmsd(c_4cmm, c_2jjs) rmsd_4kjy_vs_2jjs, _, _ = kabsch_rmsd(c_4kjy, c_2jjs) val115_ca = get_atom_coord(atoms_2jjs, "C", 115, "CA") sirpa_coords = np.array([[a["x"], a["y"], a["z"]] for a in sirpa_2jjs if a["element"] != "H"]) dist_c_term_to_sirpa = float(np.min(np.linalg.norm(sirpa_coords - val115_ca, axis=1))) # Insertion-aware sequence/residue comparison between SIRPa V2 (2JJS Chain A) and SIRPa V1 (4CMM Chain A), # accounting for the 1-residue insertion Asp101 in SIRPa V1 (4CMM Chain A 99..105 is P99-D100-D101[ins]-V102-E103-F104-K105, # whereas 2JJS Chain A 99..104 is P99-D100-T101-E102-F103-K104; closes AUDIT-REF): aa3_to_1 = { "ALA": "A", "ARG": "R", "ASN": "N", "ASP": "D", "ASJ": "D", "CYS": "C", "GLN": "Q", "GLU": "E", "GLY": "G", "HIS": "H", "ILE": "I", "LEU": "L", "LYS": "K", "MET": "M", "PHE": "F", "PRO": "P", "PCA": "Q", "SER": "S", "THR": "T", "TRP": "W", "TYR": "Y", "VAL": "V", } sirpa_2jjs_ca = get_ca_map(atoms_2jjs, "A") sirpa_4cmm_ca = get_ca_map(atoms_4cmm, "A") sirpa_aligned_substitutions = [] sirpa_insertion_and_substitution_differences = [] for seq_2jjs in sorted(sirpa_2jjs_ca.keys()): if seq_2jjs == 101 and 101 in sirpa_4cmm_ca: ins_aa = aa3_to_1.get(sirpa_4cmm_ca[101]["comp_id"], "X") sirpa_insertion_and_substitution_differences.append({ "difference_type": "V1_single_residue_insertion", "sirpa_v2_2JJS_seq_id": None, "sirpa_v2_2JJS_aa": "-", "sirpa_v1_4CMM_seq_id": 101, "sirpa_v1_4CMM_aa": ins_aa, }) seq_4cmm = seq_2jjs if seq_2jjs < 101 else (seq_2jjs + 1) if seq_4cmm in sirpa_4cmm_ca: r2 = aa3_to_1.get(sirpa_2jjs_ca[seq_2jjs]["comp_id"], "X") r4 = aa3_to_1.get(sirpa_4cmm_ca[seq_4cmm]["comp_id"], "X") if r2 != r4: sub_entry = { "difference_type": "amino_acid_substitution", "sirpa_v2_2JJS_seq_id": seq_2jjs, "sirpa_v2_2JJS_aa": r2, "sirpa_v1_4CMM_seq_id": seq_4cmm, "sirpa_v1_4CMM_aa": r4, } sirpa_aligned_substitutions.append(sub_entry) sirpa_insertion_and_substitution_differences.append(sub_entry) sirpa_v1_v2_polymorphic_sites = [d["sirpa_v2_2JJS_seq_id"] for d in sirpa_aligned_substitutions] sirpa_contact_seq_ids = {int("".join(ch for ch in res.split(":")[1][3:] if ch.isdigit())) for res in interface_2jjs["partner_2_contact_residues"]} sirpa_v1_4cmm_contact_seq_ids = sorted({int("".join(ch for ch in res.split(":")[1][3:] if ch.isdigit())) for res in interface_4cmm["partner_2_contact_residues"]}) sirpa_v1_v2_polymorphic_and_indel_v1_sites = sorted({d["sirpa_v1_4CMM_seq_id"] for d in sirpa_insertion_and_substitution_differences if d.get("sirpa_v1_4CMM_seq_id") is not None}) overlapping_polymorphic_sites_v1_4cmm = sorted(set(sirpa_v1_v2_polymorphic_and_indel_v1_sites) & set(sirpa_v1_4cmm_contact_seq_ids)) overlapping_polymorphic_sites = sorted(set(sirpa_v1_v2_polymorphic_sites) & sirpa_contact_seq_ids) cd47_prod = layer2_ledger["CD47_IgV_GPI_mature_cell_surface"] designed_cd47_120aa = cd47_prod["sequence"][:120] retained_cd55_stalk_9aa = cd47_prod["sequence"][120:] if not (designed_cd47_120aa[-1] == "S" and retained_cd55_stalk_9aa[0] == "P" and retained_cd55_stalk_9aa[-1] == "S"): raise ValueError('Molecular source invariant failed: designed_cd47_120aa[-1] == "S" and retained_cd55_stalk_9aa[0] == "P" and retained_cd55_stalk_9aa[-1] == "S"') cryst_2jjs_residues = {s_id: aa3_to_1.get(ca_2jjs[s_id]["comp_id"], "X") for s_id in sorted(ca_2jjs.keys())} cryst_2jjs_seq_115aa = "".join(cryst_2jjs_residues[s_id] for s_id in sorted(cryst_2jjs_residues.keys())) cryst_2jjs_seq_116aa_with_pca1 = "Q" + cryst_2jjs_seq_115aa cryst_4cmm_residues = {s_id: aa3_to_1.get(ca_4cmm[s_id]["comp_id"], "X") for s_id in sorted(ca_4cmm.keys())} cryst_4kjy_residues = {s_id: aa3_to_1.get(ca_4kjy[s_id]["comp_id"], "X") for s_id in sorted(ca_4kjy.keys())} def compare_cd47_to_crystal_2jjs(candidate_mature_seq: str) -> Dict[str, Any]: mismatches = [] for s_id, cryst_aa in sorted(cryst_2jjs_residues.items()): if 1 <= s_id <= len(candidate_mature_seq): des_aa = candidate_mature_seq[s_id - 1] if des_aa != cryst_aa: mismatches.append({ "mature_position_1based": s_id, "precursor_position_1based": s_id + 18, "designed_aa": des_aa, "crystal_2JJS_aa": cryst_aa, "crystal_4CMM_aa": cryst_4cmm_residues.get(s_id), "crystal_4KJY_aa": cryst_4kjy_residues.get(s_id), }) return { "candidate_sequence_sha256": hashlib.sha256(candidate_mature_seq.encode("utf-8")).hexdigest(), "resolved_positions_compared": len(cryst_2jjs_residues), "exact_matches": len(cryst_2jjs_residues) - len(mismatches), "mismatch_count": len(mismatches), "mismatches": mismatches, } cd47_wt_vs_cryst_audit = compare_cd47_to_crystal_2jjs(designed_cd47_120aa) cd47_c15g_counterfactual_seq = designed_cd47_120aa[:14] + "G" + designed_cd47_120aa[15:] cd47_c15g_vs_cryst_audit = compare_cd47_to_crystal_2jjs(cd47_c15g_counterfactual_seq) return { "complex_id": "LAYER3_COMPLEX_2_CD47_IGV_GPI_SIRPA", "locus": "Locus 1 (B2M Exon-1 KI: Arm 1A & Arm 1B)", "engineered_protein": ( f"CD47-IgV-GPI (CD47 M1-{designed_cd47_120aa[-1]}138 ectodomain retaining wild-type Cys33 [mature Cys15] " f"fused to 37-aa DAF/CD55 GPI signal {retained_cd55_stalk_9aa[0]}345-T381; mature 129-aa surface chain Q19-S147 " f"comprising 120-aa CD47 Q19-{designed_cd47_120aa[-1]}138 + 9-aa CD55 stalk {retained_cd55_stalk_9aa[0]}345-{retained_cd55_stalk_9aa[-1]}353 anchored at omega-site Ser353)" ), "layer2_processed_polypeptide_hashes": { "CD47_IgV_GPI_mature_129aa_omega_S353_sha256": cd47_prod["sha256"], "CD47_ectodomain_120aa_designed_wt_Cys15_sha256": cd47_prod["cd47_ectodomain_120aa_sha256"], "CD47_crystal_2JJS_chainC_resolved_115aa_ATOM_CA_C15G_sha256": hashlib.sha256(cryst_2jjs_seq_115aa.encode("utf-8")).hexdigest(), "CD47_crystal_2JJS_chainC_resolved_116aa_with_PCA1_C15G_sha256": hashlib.sha256(cryst_2jjs_seq_116aa_with_pca1.encode("utf-8")).hexdigest(), "CD47_crystal_2JJS_chainC_resolved_116aa_C15G_sha256": hashlib.sha256(cryst_2jjs_seq_116aa_with_pca1.encode("utf-8")).hexdigest(), "deprecated_hash_aliases": {"CD47_crystal_2JJS_chainC_resolved_116aa_C15G_sha256": {"deprecated_alias_of": "CD47_crystal_2JJS_chainC_resolved_116aa_with_PCA1_C15G_sha256", "hashed_length_aa": len(cryst_2jjs_seq_116aa_with_pca1)}}, "designed_wt_Cys15_matches_crystal_C15G_sequence_identically": False, }, "designed_vs_crystallized_cd47_sequence_identity_audit_ultracode_v80_11": { "designed_mature_residue_15_precursor_Cys33": designed_cd47_120aa[14], "designed_ectodomain_last_residue_120_precursor_138": f"{designed_cd47_120aa[-1]}138", "retained_cd55_stalk_first_residue_121_cd55_345": f"{retained_cd55_stalk_9aa[0]}345", "crystal_2JJS_chainC_standard_atom_ca_count": len(cryst_2jjs_residues), "crystal_2JJS_chainC_hetatm_pca1_present": True, "crystal_2JJS_chainC_pca1_edman_and_lcms_note_sol61_r3": ( "Mature CD47 Gln19 (2JJS Chain C residue 1) is converted to N-terminal 5-oxoproline / pyroglutamate " "(HETATM PCA1, -17.03 Da via NH3 loss; catalyzed enzymatically in cells by glutaminyl cyclase QPCTL per Logtenberg et al. 2019 Nat Med PMID:30833751 alongside low-rate spontaneous cyclization), " "which lacks a free alpha-amino group and blocks phenylisothiocyanate (PITC) Edman degradation unless enzymatically deblocked " "with pyroglutamate aminopeptidase (PGP, which excises N-terminal pGlu to expose Leu2 for Edman sequencing rather than reverting pGlu to Gln), " "whereas intact/top-down LC-MS directly resolves the intact-chain -17.03 Da mass shift (AUDIT-REF & AUDIT-REF)." ), "crystal_mature_residue_15_in_2JJS_4CMM_4KJY": { "2JJS_chain_C": cryst_2jjs_residues.get(15), "4CMM_chain_B": cryst_4cmm_residues.get(15), "4KJY_chain_A": cryst_4kjy_residues.get(15), }, "designed_mature_cysteine_positions_1based": [i + 1 for i, aa in enumerate(cd47_prod["sequence"]) if aa == "C"], "designed_wt_Cys15_vs_2JJS_comparison": cd47_wt_vs_cryst_audit, "counterfactual_C15G_mutant_vs_2JJS_comparison": cd47_c15g_vs_cryst_audit, "structural_and_thiol_qualification_note": ( "Full-length native CD47 forms a long-range inter-domain disulfide between IgV Cys33 (mature Cys15) and " "Cys263 at the extracellular loop / transmembrane boundary, whereas soluble crystal structures 2JJS (Hatherley et al. 2008 PMID:18657508), " "4CMM (Hatherley et al. 2014 PMID:24550402), and 4KJY (Weiskopf et al. 2013 PMID:23722425) mutated Cys33->Gly " "(mature C15G) to prevent unpaired-thiol dimerization in soluble expression, and our designed " "CD47-IgV-GPI retains wild-type Cys33 (following Xu et al. 2024 Cell Rep Med PMID:38508139 membrane-anchored CD47-IgV). " "Therefore, soluble C15G crystal coordinates do not settle the free-thiol/disulfide state or membrane orientation of " "wild-type Cys33 CD47-IgV-GPI; Stage-0 pre-pilot must compare wild-type Cys33 vs C33G CD47-IgV-GPI via non-reducing " "SDS-PAGE, Ellman/maleimide free-thiol labeling, PI-PLC sensitivity, and SIRPa V1/V2/V8 binding." ), }, "experimental_structures_analyzed": [ { "pdb_id": "2JJS", "resolution_angstrom": 1.85, "pmid": "18657508", "citation": "Hatherley et al. 2008 Mol Cell", "sha256": hashlib.sha256(snapshots["pdb_00002jjs.cif"]).hexdigest(), }, { "pdb_id": "4CMM", "resolution_angstrom": 1.92, "pmid": "24550402", "citation": "Hatherley et al. 2014 JBC", "sha256": hashlib.sha256(snapshots["pdb_00004cmm.cif"]).hexdigest(), }, { "pdb_id": "4KJY", "resolution_angstrom": 1.93, "pmid": "23722425", "citation": "Weiskopf et al. 2013 Science", "sha256": hashlib.sha256(snapshots["pdb_00004kjy.cif"]).hexdigest(), }, ], "cd47_to_sirpa_wt_interface_2JJS": interface_2jjs, "cd47_to_sirpa_v1_interface_4CMM": interface_4cmm, "cd47_to_sirpa_fd6_interface_4KJY": interface_4kjy, "altloc_conformer_sensitivity_4CMM_and_4KJY_claude_v80_064": { "4CMM_altloc_A_heavy_contacts": interface_4cmm["heavy_atom_contact_pairs"], "4CMM_altloc_B_heavy_contacts": interface_4cmm_altb["heavy_atom_contact_pairs"], "4KJY_altloc_A_heavy_contacts": interface_4kjy["heavy_atom_contact_pairs"], "4KJY_altloc_B_heavy_contacts": interface_4kjy_altb["heavy_atom_contact_pairs"], }, "cd47_igv_superposition_metrics": { "aligned_ca_residues": len(common_cd47), "rmsd_4CMM_vs_2JJS_angstrom": round(rmsd_4cmm_vs_2jjs, 4), "rmsd_4KJY_vs_2JJS_angstrom": round(rmsd_4kjy_vs_2jjs, 4), }, "gpi_anchor_and_sirpa_polymorphism_verification": { "evidence_class": "coordinate_ectodomain_geometry_plus_literature_spr_requires_membrane_gpi_validation", "graveyard_rule_verified": "Locus 1 CD47-IgV-GPI vs 5-TM/TSP-1 Signaling Precaution (paired with GRAVEYARD_009 Hour-0 stoichiometry gate; note GY-003 is G6PC2-null hypoglycemia)", "c_terminal_val115_distance_to_sirpa_angstrom": round(dist_c_term_to_sirpa, 2), "daf_cd55_gpi_signal_residues": "UniProt P08174 residues P345-T381 (37-aa C-terminal GPI signal: 9-aa retained stalk P345-S353 PNKGSGTTS ending at native omega-site Ser353 = precursor residue 147, plus 28-aa cleaved hydrophobic propeptide G354-T381)", "sirpa_v1_v2_substitution_count": len(sirpa_aligned_substitutions), "sirpa_v1_v2_insertion_count": 1, "sirpa_v1_v2_total_alignment_difference_count": len(sirpa_insertion_and_substitution_differences), "sirpa_v1_v2_insertion_aware_alignment_differences": sirpa_insertion_and_substitution_differences, "sirpa_v1_v2_amino_acid_substitutions_only": sirpa_aligned_substitutions, "sirpa_4cmm_pdb_numbering_indel_note": ( "In 2JJS Chain A (SIRPa V2), residues 99..104 are P99-D100-T101-E102-F103-K104; in 4CMM Chain A (SIRPa V1), " "residues 99..105 are P99-D100-D101-V102-E103-F104-K105, where the consecutive Asp100-Asp101 pair reflects a 1-residue " "insertion in V1 relative to V2 (annotated as Asp100 in Hatherley et al. 2014 PMID:24550402 Fig. 1 sequence alignment, whereas 3D C-alpha " "superposition of residues 3-96 places V2 Asp100 0.36 A from V1 Asp101 [which contacts CD47:Lys39:NZ via A:ASP101:OD1 at 2.79 A (2.7852 A exact), within the 4.5 A shell, whereas CD47:Arg103:NH2 is 16.35 A away] and 3.49 A " "from V1 Asp100 [min CD47 distance 4.65 A to CD47:Lys39:NZ, outside the 4.5 A shell], so V1's 4.5 A polymorphic/indel contact set is positions 66 and 101; AUDIT-REF & AUDIT-REF) " "that shifts subsequent V1 residue numbers by +1 (mapping V2 T101->V1 V102, V2 E102->V1 E103, " "V2 F103->V1 F104, V2 K104->V1 K105). Total V1 vs V2 differences across the IgV domain: 12 amino-acid substitutions " "+ 1 single-residue insertion (Asp100/Asp101 in 4CMM) = 13 alignment differences (closes AUDIT-REF & AUDIT-REF)." ), "sirpa_v1_v2_polymorphic_positions_tested": sirpa_v1_v2_polymorphic_sites, "polymorphic_positions_overlapping_4p5A_contact_shell": overlapping_polymorphic_sites, "polymorphic_positions_overlapping_4p5A_contact_shell_v2_2jjs": overlapping_polymorphic_sites, "polymorphic_and_indel_positions_overlapping_4p5A_contact_shell_v1_4cmm": overlapping_polymorphic_sites_v1_4cmm, "v1_4cmm_asp101_insertion_within_4p5A_cd47_contact_shell": bool(101 in sirpa_v1_4cmm_contact_seq_ids), "literature_kd_sirpa_v1_uM": 1.2, "literature_kd_sirpa_v2_uM": 1.6, "kd_sirpa_v1_uM": 1.2, "kd_sirpa_v2_uM": 1.6, "hatherley_2014_table2_soluble_spr_37C_kd_sirpa_v1_uM": 0.74, "hatherley_2014_table2_soluble_spr_37C_kd_sirpa_v1_sd_uM": 0.07, "hatherley_2014_table2_soluble_spr_37C_kd_sirpa_v2_uM": 0.64, "hatherley_2014_table2_soluble_spr_37C_kd_sirpa_v2_sd_uM": 0.06, "sirpa_temperature_and_immobilization_affinity_reconciliation_sonnet55_r2": { "summary": (