scripts/verify_iip0042_master_multilayer_portfolio_crosswalk.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/verify_iip0042_master_multilayer_portfolio_crosswalk.py · SHA-256: 16964a158458b5cf…
"hla_genotype": "HLA-DQ2.5/HLA-DQ8",
"assay_run_id": f"SHIELD_ASSAY_RUN_{run_idx:02d}",
"cocktail_mixture_id": f"MIX_SHIELD_{mix_idx + 1:02d}",
"expression_batch_ids": donor_batches,
"suppression_pct": float(s_i),
"raw_independent_units_n": int(n_eff_per_donor),
"design_effect_deff": 1.0,
"cytotoxicity_independence_model": _SHIELD_CYTO_INDEPENDENCE_MODEL,
"gy018_independence_justification": {
"independent_unit_class": "INDEPENDENT_REPLICATE_WELLS",
"within_donor_units_physically_independent": True,
"clustering_controls_present_and_verified": True,
"shared_well_technical_reads_excluded": True,
"independence_evidence_record_id": f"GY018-REC-T1D-DONOR-{i + 1:02d}",
"independent_experimental_unit": (
"Single pre-aliquoted independent primary T1D APC assay well "
"(distinct physically isolated well per unit prior to dosing)"
),
"predeclared_per_donor_unit_count_n": int(n_eff_per_donor),
"clustering_controls": (
"Randomized plate layout across physically separated wells with independent "
"dosing aliquots and zero cross-well pooling"
),
},
"apc_cytotoxicity_k_obs": int(k_i),
"apc_cytotoxicity_n_eff": int(n_eff_per_donor),
}
)
register_qc: dict[str, Any] = {
"expression_batch_ids": list(rqc_parent_batch_ids),
"hip11_dq25_dq8t_dq22_exchange_qc_passed": True,
"hip11_peptide_reagent_lot_id": hip11_reagent_lot_id,
"native_wt_insb9_23_15aa": {
"sequence": "SHLVEALYLVCGERG",
"peptide_reagent_lot_id": wt15_reagent_lot_id,
"lcms_identity_passed": True,
"register2_occupancy_qc_passed": True,
},
"engineered_6dfx_p8e9e_12aa": {
"sequence": "VEELYLVAGEEG",
"peptide_reagent_lot_id": r6dfx_reagent_lot_id,
"qc_passed": True,
},
}
if include_optional_1jk8:
register_qc["crystal_ref_1jk8_14aa"] = {
"sequence": "LVEALYLVCGERGG",
"qc_passed": True,
"expression_batch_ids": list(spr_c2_batch_ids),
}
obs_out: dict[str, Any] = {
"expression_batches": expression_batches,
"donor_sampling_and_independence_design": {
"sampling_design_class": sampling_design_class,
"independent_donor_sampling_attested": True,
"between_donor_shared_shock_controls_verified": True,
"sampling_protocol_ref": "PROTOCOL:GATE30-SHIELD-COHORT-INDEP-V1",
"between_donor_independence_justification": (
"STRATIFIED_DISJOINT_BATCH_AND_RUN_T1D_DONOR_COHORT"
if sampling_design_class == "STRATIFIED_INDEPENDENT_T1D_HLA_DQ_COHORT"
else (
"Simple random or consecutive independent T1D HLA-DQ donors executed across disjoint "
"expression batches and separate assay runs with independent reagent preparations"
)
),
},
"on_target_analytes": [
{
"analyte_id": "HLA-DQ2.5 + HIP11",
"peptide_reagent_lot_id": hip11_reagent_lot_id,
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"ic50_l95_nm": 18.0,
"ic50_u95_nm": 42.0,
"selectivity_l95_fold": 95.0,
"selectivity_u95_fold": 160.0,
},
{
"analyte_id": "HLA-DQ8-trans + HIP11",
"peptide_reagent_lot_id": hip11_reagent_lot_id,
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"ic50_l95_nm": 22.0,
"ic50_u95_nm": 48.0,
"selectivity_l95_fold": 85.0,
"selectivity_u95_fold": 140.0,
},
{
"analyte_id": "HLA-DQ2.2 + HIP11",
"peptide_reagent_lot_id": hip11_reagent_lot_id,
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"ic50_l95_nm": 24.0,
"ic50_u95_nm": 52.0,
"selectivity_l95_fold": 78.0,
"selectivity_u95_fold": 135.0,
},
{
"analyte_id": "HLA-DQ8 + native WT InsB:9-23",
"peptide_sequence": "SHLVEALYLVCGERG",
"peptide_reagent_lot_id": wt15_reagent_lot_id,
"replicates_n": 3,
"expression_batch_ids": list(spr_c2_batch_ids),
"ic50_l95_nm": 20.0,
"ic50_u95_nm": 46.0,
"selectivity_l95_fold": 88.0,
"selectivity_u95_fold": 150.0,
},
],
"off_target_controls": [
{
"analyte_id": "HLA-DQ2.5 + CLIP1",
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"selectivity_l95_fold": 92.0,
"selectivity_u95_fold": 165.0,
},
{
"analyte_id": "HLA-DQ2.5 + Self_IGKV2_EAED",
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"selectivity_l95_fold": 80.0,
"selectivity_u95_fold": 145.0,
},
{
"analyte_id": "HLA-DQ2.5 + cel_glutenin_L1",
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"selectivity_l95_fold": 72.0,
"selectivity_u95_fold": 130.0,
},
{
"analyte_id": "HLA-DQ8-trans + Cpep_Nterm_EAED",
"replicates_n": 3,
"expression_batch_ids": list(spr_c1_batch_ids),
"selectivity_l95_fold": 84.0,
"selectivity_u95_fold": 150.0,
},
{
"analyte_id": "HLA-DQ8 + CLIP1",
"replicates_n": 3,
"expression_batch_ids": list(spr_c2_batch_ids),
"selectivity_l95_fold": 90.0,
"selectivity_u95_fold": 160.0,
},
{
"analyte_id": "HLA-DQ8 + DQ8-glia-gamma1a",
"replicates_n": 3,
"expression_batch_ids": list(spr_c2_batch_ids),
"selectivity_l95_fold": 75.0,
"selectivity_u95_fold": 130.0,
},
{
"analyte_id": "HLA-DQ8-trans + WT InsB:9-23",
"peptide_sequence": "SHLVEALYLVCGERG",
"peptide_reagent_lot_id": wt15_reagent_lot_id,
"replicates_n": 3,
"expression_batch_ids": list(spr_c2_batch_ids),
"selectivity_l95_fold": 82.0,
"selectivity_u95_fold": 145.0,
},
],
"comp2_comparators_screened": [
{
"comparator_id": cid,
"screened": True,
"replicates_n": 3,
"expression_batch_ids": list(spr_c2_batch_ids) if cid == _SHIELD_COMP2_LEAD else [comparator_batch_map[cid]],
"register_control_screens": {
"native_wt_insb9_23_15aa": {
"screened": True,
"peptide_sequence": "SHLVEALYLVCGERG",
"peptide_reagent_lot_id": wt15_reagent_lot_id,
"expression_batch_ids": list(spr_c2_batch_ids) if cid == _SHIELD_COMP2_LEAD else [comparator_batch_map[cid]],
"replicates_n": 3,
"evidence_record_id": f"SPR-COMP-{cid}-WT15",
},
"engineered_6dfx_p8e9e_12aa": {
"screened": True,
"peptide_sequence": "VEELYLVAGEEG",
"peptide_reagent_lot_id": r6dfx_reagent_lot_id,
"expression_batch_ids": list(spr_c2_batch_ids) if cid == _SHIELD_COMP2_LEAD else [comparator_batch_map[cid]],
"replicates_n": 3,
"evidence_record_id": f"SPR-COMP-{cid}-6DFX",
},
},
}
for cid in _SHIELD_MANDATORY_COMP2_COMPARATORS
],
"register_qc_records": register_qc,
"sec_mals_dls_monomer_coformulation": {
"expression_batch_ids": list(sec_all_lead_batch_ids),
"comp1_qf09_pi2_alone_monomer_qc_passed": True,
"comp2_t006_alone_monomer_qc_passed": True,
"cocktail_1to1_coformulation_qc_passed": True,
"protenix_homodimer_flag_iptm_addressed": 0.6691,
"comp1_monomer_pct": 98.2,
"comp2_monomer_pct": 97.5,
"cocktail_1to1_monomer_pct": 96.8,
"dls_pdi": 0.08,
"no_aggregates_or_precipitation": True,
"qualified_coformulation_mixtures": qualified_mixtures,
},
"tcell_blockade_and_apc_cytotoxicity_donors": donors,
}
if include_preregistered_roster:
if roster_donor_ids is not None:
r_ids = [str(x) for x in roster_donor_ids]
else:
r_n = max(n_donors, int(planned_t1d_donor_family_n) if planned_t1d_donor_family_n is not None else n_donors)
r_ids = [f"T1D_DONOR_{i + 1:02d}" for i in range(r_n)]
obs_out["preregistered_donor_family_roster"] = _shield_build_preregistered_roster(
r_ids,
roster_id=roster_id,
preregistration_timestamp_utc=preregistration_timestamp_utc,
predeclared_per_donor_unit_count_n=int(n_eff_per_donor),
)
if planned_t1d_donor_family_n is not None:
obs_out["planned_t1d_donor_family_n"] = int(planned_t1d_donor_family_n)
if excluded_donor_records is not None:
obs_out["excluded_donor_records"] = list(excluded_donor_records)
return obs_out
def evaluate_gate30_shield_spr(observation: dict[str, Any]) -> dict[str, Any]:
"""Executable typed fail-first Gate 30-SHIELD-SPR adjudicator synchronized 100% identically
across verify_iip0044_foundry_v1_3_biologics.py and verify_iip0042_master_multilayer_portfolio_crosswalk.py.
Pre-adjudication input integrity:
Non-dict payloads or ANY non-finite (NaN/Inf) or overflowing (IEEE-754 binary64 abs(x) > 1e300
for float; exact abs(x) > 10**300 for int) numeric anywhere in the input tree raise ValueError
BEFORE decision precedence (and strict JSON text decoding rejects raw decimal literals with |d| > 10^300).
Unique 6-level fail-first decision precedence:
FAIL > HOLD_INVALID_OR_MISSING_INPUT > HOLD_CYTOTOXICITY_U95_EXCEEDS_5PCT
> HOLD_OBSERVED_NONZERO_CYTOTOXICITY > HOLD > PASS
Requires all typed evidence blocks with construct-bound expression_batch_ids linkage (rejecting empty
construct_ids batches; binding Comp1 assays to IsletSHIELD_QF09_pI2, Comp2 assays + register QC to
IsletSHIELD_Comp2_T006, each comparator to its own construct, and cocktail assays to BOTH leads with
>= 3 distinct Comp1 and >= 3 distinct Comp2 batches linked across assay evidence), all 4 mandatory
on-target analytes (requiring peptide_sequence='SHLVEALYLVCGERG' and matching peptide_reagent_lot_id
between the WT15 on-target analyte and register_qc_records.native_wt_insb9_23_15aa), all 7 off-target
controls (4 Comp1 + 3 Comp2), all 6 Comp2 comparators, mandatory register QC (HIP11, 15-aa WT InsB:9-23,
12-aa 6DFX; optional physical 14-aa 1JK8 omitted OR null -> PASS, any non-null value validated strictly),
quantitative SEC-MALS/DLS (>= 95.0% monomer, PDI <= 0.15, no_aggregates_or_precipitation=True reconciled
with boolean QC flags), mandatory typed donor_sampling_and_independence_design + per-donor assay_run_id,
mandatory typed T1D donor eligibility (t1d_diagnosis_confirmed=True, donor_clinical_cohort='T1D',
non-empty unpadded t1d_prequalification_ref, rejecting contradictory non-T1D donor tokens even if flags
are forged), qualifying donor hla_genotype allowlist, mandatory authorization-grade typed +