scripts/wetlab_contract.py
Use this file in any AI chat (paste-only or attachment-capable):
Pinned raw file: https://openislet.org/files/gen-eb955f8266035aba/scripts/wetlab_contract.py · SHA-256: 6bb3955530f8f05d…
iip0031_hold_status = 'FAIL_TIER6B_OUTGROWTH_DETECTED'
elif iip0031_s11_eval.get('gate_pass') is not True:
iip0031_hold_status = str(iip0031_s11_eval.get('status'))
elif iip0031_tier6b_eval is not None and iip0031_tier6b_eval.get('gate_pass') is not True:
iip0031_hold_status = str(iip0031_tier6b_eval.get('status'))
resolved_arch = dict(tree_doc.get('default_architecture_assignments', {}))
if product_def is not None:
_pvid_canon = str(product_def['product_variant_id'])
resolved_arch['product_variant_id'] = _pvid_canon
resolved_arch['product_execution_supported'] = bool(product_def.get('execution_supported', False))
if _pvid_canon in _staged_l2_v3_ids:
_l2b_ra = product_def.get('staged_locus2_modeb_donor_binding') or {}
resolved_arch['locus2_construct'] = str(_l2b_ra.get('locus2_donor_id', _pvid_canon))
if product_def.get('family') == 'B':
resolved_arch['locus1_construct'] = f'{_pvid_canon}_HLAA_KO_HLAB_KO_ENDOGENOUS_HLAC'
elif _pvid_canon.startswith('ISLET1_B_SCT_'):
resolved_arch['locus1_construct'] = f'{_pvid_canon}_B2M_ARM1B_PLUS_CIITA_HLAC_SCT'
resolved_arch['locus2_construct'] = f'{_pvid_canon}_CIITA_HLAC_SCT'
elif _pvid_canon in ('ISLET1_B2_5LOCUS_BASE', 'ISLET1_B2_5LOCUS_TYK2_PE', 'ISLET1_B1_6LOCUS_TYK2_KO_INS'):
resolved_arch['locus1_construct'] = f'{_pvid_canon}_HLAA_KO_HLAB_KO_ENDOGENOUS_HLAC'
elif _pvid_canon == 'ISLET1_Z_X_MOL_140UM_ZERO_CAO2':
resolved_arch['locus1_construct'] = 'ISLET1_A4_X_MOL_RNLS_WT_ON_Z_140UM_ZERO_CAO2'
if iip0024_eval_summary is not None:
resolved_arch['stage0_atomic_provenance_and_bank_guardrails_iip_0024'] = iip0024_eval_summary['status']
resolved_arch['stage0_atomic_provenance_and_bank_evaluation_iip_0024'] = iip0024_eval_summary
else:
resolved_arch['stage0_atomic_provenance_and_bank_guardrails_iip_0024'] = 'NOT_TESTED'
if iip0025_eval_summary is not None:
resolved_arch['hurdle4_spatial_oxygen_catalase_and_route_challengers_iip_0025'] = iip0025_eval_summary['status']
resolved_arch['hurdle4_spatial_oxygen_catalase_and_route_evaluation_iip_0025'] = iip0025_eval_summary
else:
resolved_arch['hurdle4_spatial_oxygen_catalase_and_route_challengers_iip_0025'] = 'NOT_TESTED'
if knockin_splice_challenger_arm != 'PARENTAL_REFERENCE' or _chall_any_input:
resolved_arch['knockin_splice_challenger_arm'] = knockin_splice_challenger_arm
if knockin_locus4_orientation is not None:
resolved_arch['knockin_locus4_orientation'] = knockin_locus4_orientation
if challenger_umi_eff > 0.0:
resolved_arch['challenger_effective_umi_molecules'] = round(challenger_umi_eff, 3)
resolved_arch['knockin_splice_challenger_qualification_status'] = (
challenger_hold_status
if challenger_hold_status is not None
else 'CHALLENGER_SPLICE_AND_RECOVERY_ADJUSTED_UMI_PANEL_CLEARED'
)
if l3_multimir_gate_status is not None:
resolved_arch['locus3_multimir_modeb_gate_status'] = l3_multimir_gate_status
resolved_arch['locus3_multimir_modeb_evaluation'] = l3_multimir_eval_summary
if iip0019_eval_summary is not None:
resolved_arch['transport_3d_clumping_h2o2_and_design_z_evaluation'] = iip0019_eval_summary
if iip0019_s6_status is not None:
resolved_arch['s6_3d_lateral_spacing_gate_status'] = iip0019_s6_status
if iip0019_p05_status is not None:
resolved_arch['p05_microbead_catalase_barrier_gate_status'] = iip0019_p05_status
if iip0019_dz_status is not None:
resolved_arch['design_z_two_stage_optode_gate_status'] = iip0019_dz_status
if iip0020_eval_summary is not None:
resolved_arch['biomaterial_antigen_humoral_and_human_cuff_evaluation'] = iip0020_eval_summary
if iip0020_p05_species_status is not None:
resolved_arch['p05_catalase_species_gate_status'] = iip0020_p05_species_status
if iip0020_cuff_status is not None:
resolved_arch['cuff_humoral_and_hepatocyte_gate_status'] = iip0020_cuff_status
if iip0021_eval_summary is not None:
resolved_arch['metabolic_rest_ocr_and_conditioning_evaluation'] = iip0021_eval_summary
if iip0021_rest_status is not None:
resolved_arch['rest_120h_ocr_coupon_status'] = iip0021_rest_status
if iip0021_cond_status is not None:
resolved_arch['conditioning_4arm_nqo1_gate_status'] = iip0021_cond_status
if iip0022_eval_summary is not None:
resolved_arch['track2_nk_split_and_pvr_necroptosis_evaluation'] = iip0022_eval_summary
if iip0022_track2_status is not None:
resolved_arch['track2_split_route_status'] = iip0022_track2_status
if iip0023_eval_summary is not None:
resolved_arch['design_y_wildcard_evaluation'] = iip0023_eval_summary
resolved_arch['design_y_wildcard_status'] = iip0023_dy_status
if (
_adj_arm_raw is not None
or adjunct_depletion_mode is not None
or adjunct_sa_fhl1_status is not None
or adjunct_immune_responder_history is not None
or any(
observations.get(_k) is not None
for _k in (
'obs_arm2_bound_and_supernatant_fasl_bioactivity_depleted_verified',
'obs_arm2_sa_thbd_bioactivity_depleted_verified',
'obs_arm2_contemporaneous_sham_handling_matched',
'obs_arm3_ongoing_adjunct_bioactivity_verified',
)
)
or any(
_k in validated_stage0
for _k in (
'obs_arm2_post_depletion_viable_beta_recovery_pct',
'obs_arm2_post_depletion_perifusion_gsis_si',
'obs_arm2_post_depletion_nhs_c5b9_mac_pct',
)
)
):
resolved_arch['adjunct_conditioning_history_arm'] = adjunct_conditioning_history_arm
if adjunct_depletion_mode is not None:
resolved_arch['adjunct_depletion_mode'] = adjunct_depletion_mode
if adjunct_immune_responder_history is not None:
resolved_arch['adjunct_immune_responder_history'] = adjunct_immune_responder_history
if adjunct_sa_fhl1_status is not None:
resolved_arch['adjunct_sa_fhl1_status'] = adjunct_sa_fhl1_status
resolved_arch['adjunct_depletion_truth_in_labeling_status'] = (
'PARTIAL_FASL_THBD_DEPLETED_SA_FHL1_RETAINED_ACTIVE_NOT_COMPLETE_ADJUNCT_DEPLETION'
if adjunct_sa_fhl1_status == 'RETAINED_ACTIVE'
else (
'COMPLETE_DECLARED_ADJUNCT_BIOACTIVITY_DEPLETED'
if (
observations.get('obs_arm2_bound_and_supernatant_fasl_bioactivity_depleted_verified') is True
and observations.get('obs_arm2_sa_thbd_bioactivity_depleted_verified') is True
)
else 'UNVERIFIED_ADJUNCT_DEPLETION_STATE'
)
)
if adjunct_conditioning_history_arm == 'ARM2_CONDITIONED_DEPLETED':
resolved_arch['arm2_post_adjunct_depletion_qualification_status'] = (
'HOLD_GATE0D_ARM2_ADJUNCT_DEPLETION_OR_SHAM_VERIFICATION_INCOMPLETE'
if arm2_depletion_verification_incomplete
else (
'HOLD_GATE0D_ARM2_POST_ADJUNCT_DEPLETION_REBOUND_INJURY_OR_FUNCTION_LOSS'
if arm2_rebound_injury_or_function_failed
else (
'HOLD_GATE0D_ARM2_POST_ADJUNCT_DEPLETION_PANEL_INCOMPLETE'
if arm2_post_depletion_panel_incomplete
else 'ARM2_POST_ADJUNCT_DEPLETION_RECHALLENGE_CLEARED'
)
)
)
if prior_s9_reset_history_retained:
resolved_arch['prior_s9_safety_stop_history_retained'] = True
if 'obs_dxs_screened_cell_count' in validated_stage0:
resolved_arch['dxs_effective_clonogenic_trials'] = dxs_effective_clonogenic_n
resolved_arch['dxs_denominator_scope'] = (
'EXPLICIT_CLONOGENIC_AND_SPIKEIN_ADJUSTED'
if has_explicit_dxs_clonogenic_factors
else 'MISSING_EXPLICIT_CLONOGENIC_FRACTION_OR_SPIKEIN_DETECTION_EFFICIENCY'
)
if s1_promoted:
resolved_arch['locus3_construct'] = 'ISLET1_A4_L3_BFB_BASALFLOOR'
if s3_promoted:
resolved_arch['locus1_construct'] = 'ISLET1_A4_DXS_ARM1C_L4CD47'
elif catastrophic_nkg2a_lysis_exceeds_arm1x:
resolved_arch['locus1_construct'] = 'HOLD_CATASTROPHIC_NKG2A_LYSIS_EXCEEDS_ARM1X_RESCUE_ENVELOPE'
elif kir_nkg2a_neg_nk_failed:
resolved_arch['locus1_construct'] = 'HOLD_KIR_NKG2A_NEG_NK_OR_IL12_IL18_SIRPA_LOW_LYSIS_FAILED_REQUIRES_TRACK2_B_SCT_OR_HLAG1_CHALLENGER'
elif track2_hlag1_route_attempted:
resolved_arch['locus1_construct'] = 'HOLD_TRACK2_HLAG1_CHALLENGER_PENDING_PRODUCT_REGISTRATION'
resolved_arch['locus2_construct'] = 'HOLD_TRACK2_HLAG1_CHALLENGER_PENDING_PRODUCT_REGISTRATION'
resolved_arch['track2_kir_subbank_construct'] = 'HOLD_HLAG1_C42S_LILRB1_CHALLENGER_UNREGISTERED_PRODUCT'
resolved_arch['track1_mhc_null_kir_escape_status'] = 'HOLD_HLAG1_LILRB1_ROUTE_PENDING_PRODUCT_REGISTRATION'
elif track2_kir_or_hlag1_fallback_promoted:
resolved_arch['locus1_construct'] = 'PROMOTE_TRACK2_B_SCT_KIR_RESCUE' if (_bsct_flag or _t2_route == 'TRACK2_HLAC_B_SCT_KIR_RESCUE') else 'PROMOTE_TRACK2_B_SCT_OR_HLAG1_LILRB1_RESCUE'
resolved_arch['locus2_construct'] = 'ISLET1_B_SCT_C1_CIITA_OR_C2_CIITA_KIR_RESCUE'
resolved_arch['track2_kir_subbank_construct'] = 'ISLET1_B_SCT_C1_OR_C2_CIITA_KIR_RESCUE' if (_bsct_flag or _t2_route == 'TRACK2_HLAC_B_SCT_KIR_RESCUE') else 'ISLET1_B_SCT_C1_OR_C2_CIITA_OR_HLAG1_C42S_CHALLENGER'
resolved_arch['track1_mhc_null_kir_escape_status'] = 'PROMOTED_TO_TRACK2_HLAC_B_SCT_KIR_RESCUE' if (_bsct_flag or _t2_route == 'TRACK2_HLAC_B_SCT_KIR_RESCUE') else 'PROMOTED_TO_TRACK2_B_SCT_OR_HLAG1_LILRB1_CHALLENGER'
elif s2_promoted:
resolved_arch['locus1_construct'] = 'ISLET1_A4_X_MOL_RNLS_WT'
if observations.get('s2_arm1x_clears_15k_resting_hlae_and_cd47_c15g_noninferior') is not True:
resolved_arch['locus1_arm1x_qualification_status'] = 'CANDIDATE_PROMOTED_REQUIRES_ARM1X_GATE0A_QUALIFICATION'
elif cd47_or_phagocytosis_failed and not dxs_joint_retention_verified:
resolved_arch['locus1_construct'] = 'HOLD_LOCUS1_CD47_DEFICIENT_PENDING_DXS_QUALIFICATION'
elif unmitigated_cd47_or_hypoxic_retention_cliff_failed:
resolved_arch['locus1_construct'] = 'HOLD_PLAYBOOK_CD47_200K_OR_PHAGO_5PCT_OR_HYPOXIC_RETENTION_CLIFF_FAILED'
if s10_v3_eval is not None:
resolved_arch['s10_v3_functional_selectivity_evaluation'] = s10_v3_eval
if s10_nkg2c_triggered or (_s10_v3_active and s10_v3_eval is not None):
if _s10_v3_active and s10_v3_eval is not None:
if not s10_v3_eval['gate_pass']:
s10_status_val = str(s10_v3_eval['status'])
elif not s10_v3_release_qualified:
s10_status_val = 'CLEARED_S10_FUNCTIONAL_SELECTIVITY_SCREENING_15K_V3'
elif s10_kd_ratio_lower95_sub4 or float(s10_v3_eval['recorded_sct_kc_over_ka_mean']) < 4.0:
s10_status_val = 'CLEARED_S10_FUNCTIONAL_SELECTIVITY_SUB4_SCT_V3'
else:
s10_status_val = 'CLEARED_S10_STATIC_RATIO_AND_PAIRED_FUNCTIONAL_GATE_V3'
else:
s10_status_val = (
'CLEARED_SCT_SELECTIVITY_COUPON_KC_KA_GE_4'
if s10_coupon_cleared
else 'HOLD_S10_NKG2C_SELECTIVITY_FAILED_REQUIRES_SCT_PEPTIDE_SELECTIVITY_COUPON_OR_CMV_STRATIFIED_LABEL'
)
resolved_arch['nkg2c_selectivity_contingency_status'] = s10_status_val
resolved_arch['nkg2c_adaptive_nk_selectivity_status'] = s10_status_val
if s8_tyk2_epistasis_triggered:
if not s3_promoted and resolved_arch.get('locus1_construct') != 'HOLD_LOCUS1_CD47_DEFICIENT_PENDING_DXS_QUALIFICATION':
resolved_arch['locus1_construct'] = 'ISLET1_A4_X_MOL_RNLS_WT'
resolved_arch['locus3_construct'] = 'ISLET1_A4_L3_BFB_BASALFLOOR'
resolved_arch['tyk2_epistasis_contingency_status'] = 'COUPLE_TYK2_P1104A_STRICTLY_WITH_ARM1X_AND_L3_BFB_CONSTITUTIVE_BASAL_FLOOR'
elif (x14_trig or x34_trig or sat_trig) and not is_tyk2_product_or_unspecified:
resolved_arch['tyk2_epistasis_contingency_status'] = 'INACTIVE_NON_TYK2_PRODUCT_VARIANT'
if s4_promoted and 'obs_lot_ocr_ratio' in validated_stage0 and lot_ocr_upper95 > 1.097:
resolved_arch['lot_payload_derating_factor'] = round(1.0 / validated_stage0['obs_lot_ocr_ratio'], 4)
resolved_arch['pouch_areal_loading_cap_ieq_cm2'] = 1500.0
if s8_promoted or prolonged_insulin_clearance_failed or assembled_cluster_lineage_or_identity_failed:
resolved_arch['prescribed_functional_dose_cap_ieq'] = 150000.0
resolved_arch['sentinel_staged_cassette_dosing_status'] = 'STAGE1_SINGLE_100CM2_SENTINEL_CASSETTE_150K_IEQ_CAP_BEFORE_STEPUP'
if s6_promoted:
resolved_arch['er_rescue_genotype_pivot'] = (
'PROMOTE_ISLET1_A4_K6_HLAA_HLAB_KO_EXOGENOUS_B2M_SHIELD'
if exogenous_b2m_class1_rescue_failed
else 'REQUALIFY_ISLET1_A4_ARM1B_TYK2_PE_OR_K6_HLAA_HLAB_KO'
)
if s7_promoted:
resolved_arch['track2_kir_subbank_construct'] = 'ISLET1_B_SCT_C1_OR_C2_CIITA'
elif b_prime_sct_direct_cd8_failed:
resolved_arch['track2_kir_subbank_construct'] = 'HOLD_B_PRIME_SCT_DIRECT_CD8_ALLOREACTIVITY_FAILED'
elif s7_hold_unqualified_sct:
resolved_arch['track2_kir_subbank_construct'] = 'HOLD_PENDING_B_SCT_GATE0B_DENSITY_QUALIFICATION'
if b2_tyk2_gate_status is not None:
resolved_arch['design_b2_tyk2_p1104a_hlac_gate_status'] = b2_tyk2_gate_status
resolved_arch['design_b2_tyk2_p1104a_hlac_evaluation'] = b2_tyk2_eval_summary
if _b2_tyk2_stratum is not None:
resolved_arch['b2_tyk2_recipient_genotype_stratum'] = _b2_tyk2_stratum
if _b2_tyk2_allele is not None:
resolved_arch['b2_tyk2_hlac_allele'] = _b2_tyk2_allele
# Terminal NO-GO and unmitigated fallback HOLD states (AUDIT-REF, S2-01..03, AUDIT-REF, AUDIT-REF, AUDIT-REF, MW-R5-S2-F01..F06, AUDIT-REF & AUDIT-REF; DEC-041..050):
if prior_s9_flag:
resolved_arch['reset_current_batch_id_explicitly_supplied'] = bool(cur_batch_id_str)
resolved_arch['tp53_denominator_provenance'] = (
'EXPLICIT_OBSERVED_DEPTH'
if tp53_duplex_depth_explicitly_supplied
else 'ASSUMED_PROTOCOL_MINIMUM_62958_PENDING_EXPLICIT_TP53_DENOMINATOR'
)
resolved_arch['castseq_denominator_provenance'] = (
'EXPLICIT_OBSERVED_DEPTH'
if cast_duplex_depth_explicitly_supplied
else 'ASSUMED_PROTOCOL_MINIMUM_62958_PENDING_EXPLICIT_CAST_DENOMINATOR'
)
resolved_arch['mcb_clonogenic_escape_qualification_status'] = (
'HARD_SAFETY_STOP_MCB_CLONOGENIC_SURVIVOR_DETECTED'
if mcb_clonogenic_survivor_detected
else (
'CLEARED_MCB_CLONOGENIC_EFFECTIVE_TRIALS_GE_299573228'
if (
mcb_clonogenic_trials_explicitly_supplied
and mcb_clonogenic_trials >= 299573228.0
and mcb_survivors_k_explicitly_supplied
and mcb_survivors_k == 0.0
)
else (
'HOLD_MCB_CLONOGENIC_SURVIVOR_OUTCOME_MISSING'
if mcb_clonogenic_outcome_missing_when_trials_supplied
else (
'HOLD_MCB_CLONOGENIC_TRIALS_BELOW_299573228_MINIMUM'
if (mcb_clonogenic_trials_underpowered_below_299573228 or mcb_clonogenic_trials_missing_when_outcome_zero_supplied)
else 'BULK_4LOG_KILL_ONLY_REQUIRES_SEPARATE_MCB_3E8_CLONOGENIC_QUALIFICATION'
)