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…
s9_panel_completeness_tier = 'HOLD_MCB_CLONOGENIC_TRIALS_BELOW_299573228_MINIMUM'
resolved_arch['variant_safety_status'] = 'HOLD_MCB_CLONOGENIC_TRIALS_BELOW_299573228_MINIMUM'
resolved_arch['lot_maturation_status'] = 'HOLD_MCB_CLONOGENIC_TRIALS_BELOW_299573228_MINIMUM'
elif residual_psc_trials_underpowered:
safety_status = 'HOLD_RESIDUAL_PSC_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
s9_panel_completeness_tier = 'HOLD_RESIDUAL_PSC_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
resolved_arch['variant_safety_status'] = 'HOLD_RESIDUAL_PSC_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
resolved_arch['lot_maturation_status'] = 'HOLD_RESIDUAL_PSC_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
elif hazard_prolif_trials_underpowered:
safety_status = 'HOLD_HAZARD_STATE_PROLIF_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
s9_panel_completeness_tier = 'HOLD_HAZARD_STATE_PROLIF_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
resolved_arch['variant_safety_status'] = 'HOLD_HAZARD_STATE_PROLIF_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
resolved_arch['lot_maturation_status'] = 'HOLD_HAZARD_STATE_PROLIF_EFFECTIVE_TRIALS_BELOW_299573228_MINIMUM'
elif ap1903_step1_trials_underpowered:
safety_status = 'HOLD_AP1903_STEP1_EFFECTIVE_TRIALS_BELOW_29957323_MINIMUM'
s9_panel_completeness_tier = 'HOLD_AP1903_STEP1_EFFECTIVE_TRIALS_BELOW_29957323_MINIMUM'
resolved_arch['variant_safety_status'] = 'HOLD_AP1903_STEP1_EFFECTIVE_TRIALS_BELOW_29957323_MINIMUM'
resolved_arch['lot_maturation_status'] = 'HOLD_AP1903_STEP1_EFFECTIVE_TRIALS_BELOW_29957323_MINIMUM'
elif observations.get('obs_vascularized_explant_en_bloc_recovery_verified') is False:
safety_status = 'HOLD_VASCULARIZED_EXPLANT_EN_BLOC_RECOVERY_UNVERIFIED'
s9_panel_completeness_tier = 'HOLD_VASCULARIZED_EXPLANT_EN_BLOC_RECOVERY_UNVERIFIED'
resolved_arch['variant_safety_status'] = 'HOLD_VASCULARIZED_EXPLANT_EN_BLOC_RECOVERY_UNVERIFIED'
resolved_arch['lot_maturation_status'] = 'HOLD_S9_EXPLANT_EN_BLOC_RECOVERY_BELOW_99PCT'
elif not required_panel_complete:
safety_status = 'HOLD_UNMEASURED_MANDATORY_SAFETY_PANEL'
s9_panel_completeness_tier = (
'HOLD_INCOMPLETE_5ENDPOINT_S9_PANEL'
if (require_full_5endpoint_s9_panel and mandatory_s9_safety_panel_complete)
else 'HOLD_INCOMPLETE_CORE_3ENDPOINT_S9_PANEL'
)
resolved_arch['variant_safety_status'] = 'HOLD_UNMEASURED_MANDATORY_SAFETY_PANEL'
if not s8_promoted and not str(resolved_arch.get('lot_maturation_status', '')).startswith(('HOLD_', 'NO_GO_')):
resolved_arch['lot_maturation_status'] = 'HOLD_INCOMPLETE_SAFETY_PANEL'
else:
safety_status = 'CLEARED'
s9_panel_completeness_tier = (
'FULL_5ENDPOINT_S9_PANEL_CLEARED'
if full_5endpoint_s9_panel_complete
else 'CORE_3ENDPOINT_GENOMIC_SUICIDE_CLEARED_ER_GATE0E_PENDING'
)
resolved_arch['variant_safety_status'] = 'CLEARED'
if prior_s9_reset_history_retained and resolved_arch.get('lot_maturation_status') == 'READY_FOR_ENCAPSULATION':
resolved_arch['lot_maturation_status'] = 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'
# Pivotal combined-stress Stage-0 coupon gate evaluation (STAGE0_COMBINED_STRESS_KILL_CHAIN_COUPON_MUSE_R4; AUDIT-REF, AUDIT-REF, AUDIT-REF, AUDIT-REF, MW-R5-S2-F04 & AUDIT-REF; DEC-043..050):
# Prohibits positive defaults: PROMOTE of ISLET1_COMP_R4_X_BFB_DXB_LOWLOAD1500 ALWAYS requires all 4 COMP_R4 secondary metrics, and single-arm RETAIN of Embodiment A* accepts either COMP_R4 or Embodiment A* 4-endpoint secondary panels.
combined_stress_spec = dict(tree_doc.get('pivotal_combined_stress_stage0_coupon_gate_muse_r4', {}))
has_a_star_cs = 'obs_combined_stress_embodiment_a_star_lysis_pct' in validated_stage0
has_comp_cs_lysis = 'obs_combined_stress_comp_r4_lysis_pct' in validated_stage0
has_comp_cs_si = 'obs_combined_stress_comp_r4_gsis_si' in validated_stage0
has_all_4_comp_cs_secondary = bool(
'obs_combined_stress_comp_r4_viable_beta_mass_pct' in validated_stage0
and 'obs_combined_stress_comp_r4_shutoff_t90_min' in validated_stage0
and 'obs_combined_stress_comp_r4_max_h2o2_uM' in validated_stage0
and 'obs_combined_stress_comp_r4_max_ph' in validated_stage0
)
has_all_4_a_star_cs_secondary = bool(
'obs_combined_stress_embodiment_a_star_viable_beta_mass_pct' in validated_stage0
and 'obs_combined_stress_embodiment_a_star_shutoff_t90_min' in validated_stage0
and 'obs_combined_stress_embodiment_a_star_max_h2o2_uM' in validated_stage0
and 'obs_combined_stress_embodiment_a_star_max_ph' in validated_stage0
)
has_all_4_cs_secondary = bool(has_all_4_comp_cs_secondary or has_all_4_a_star_cs_secondary)
cs_secondary_failed = bool(
('obs_combined_stress_comp_r4_viable_beta_mass_pct' in validated_stage0 and _lower95('obs_combined_stress_comp_r4_viable_beta_mass_pct') < 85.0)
or ('obs_combined_stress_comp_r4_shutoff_t90_min' in validated_stage0 and _upper95('obs_combined_stress_comp_r4_shutoff_t90_min') > 3.0)
or ('obs_combined_stress_comp_r4_max_h2o2_uM' in validated_stage0 and _upper95('obs_combined_stress_comp_r4_max_h2o2_uM') > 5.0)
or ('obs_combined_stress_comp_r4_max_ph' in validated_stage0 and _upper95('obs_combined_stress_comp_r4_max_ph') > 7.50)
or ('obs_combined_stress_embodiment_a_star_viable_beta_mass_pct' in validated_stage0 and _lower95('obs_combined_stress_embodiment_a_star_viable_beta_mass_pct') < 85.0)
or ('obs_combined_stress_embodiment_a_star_shutoff_t90_min' in validated_stage0 and _upper95('obs_combined_stress_embodiment_a_star_shutoff_t90_min') > 3.0)
or ('obs_combined_stress_embodiment_a_star_max_h2o2_uM' in validated_stage0 and _upper95('obs_combined_stress_embodiment_a_star_max_h2o2_uM') > 5.0)
or ('obs_combined_stress_embodiment_a_star_max_ph' in validated_stage0 and _upper95('obs_combined_stress_embodiment_a_star_max_ph') > 7.50)
)
has_combined_stress_obs = bool(
has_a_star_cs
or has_comp_cs_lysis
or has_comp_cs_si
or 'obs_combined_stress_comp_r4_viable_beta_mass_pct' in validated_stage0
or 'obs_combined_stress_comp_r4_shutoff_t90_min' in validated_stage0
or 'obs_combined_stress_comp_r4_max_h2o2_uM' in validated_stage0
or 'obs_combined_stress_comp_r4_max_ph' in validated_stage0
or 'obs_combined_stress_embodiment_a_star_viable_beta_mass_pct' in validated_stage0
or 'obs_combined_stress_embodiment_a_star_shutoff_t90_min' in validated_stage0
or 'obs_combined_stress_embodiment_a_star_max_h2o2_uM' in validated_stage0
or 'obs_combined_stress_embodiment_a_star_max_ph' in validated_stage0
or observations.get('combined_stress_coupon_cleared_lysis_le_8pct_and_si_ge_2p5') is not None
)
combined_stress_spec['full_7metric_panel_complete'] = bool(
(has_a_star_cs and has_comp_cs_lysis and has_comp_cs_si and has_all_4_comp_cs_secondary)
or (has_a_star_cs and has_all_4_a_star_cs_secondary)
)
combined_stress_spec['secondary_panel_provenance'] = (
'EXPLICIT_4SECONDARY_ENDPOINTS_OBSERVED'
if has_all_4_cs_secondary
else 'CORE_3COMPARATOR_ONLY_SECONDARY_VIABILITY_SHUTOFF_H2O2_PH_PENDING'
)
combined_stress_promoted = False
if has_combined_stress_obs:
if observations.get('combined_stress_coupon_cleared_lysis_le_8pct_and_si_ge_2p5') is False or cs_secondary_failed:
combined_stress_coupon_status = 'HOLD_COMBINED_STRESS_COUPON_FAILED'
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = 'HOLD_COMBINED_STRESS_COUPON_FAILED'
elif observations.get('require_full_7metric_combined_stress_panel') is True and not has_all_4_cs_secondary:
combined_stress_coupon_status = 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
elif has_a_star_cs and has_comp_cs_lysis and has_comp_cs_si:
a_star_cs_lysis_u95 = _upper95('obs_combined_stress_embodiment_a_star_lysis_pct')
comp_cs_lysis_u95 = _upper95('obs_combined_stress_comp_r4_lysis_pct')
comp_cs_si_l95 = _lower95('obs_combined_stress_comp_r4_gsis_si')
if resolved_arch.get('lot_maturation_status') not in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
combined_stress_coupon_status = 'HOLD_COMPONENT_GATE_FAILURE_BLOCKS_COMPOSITE_PROMOTION'
elif a_star_cs_lysis_u95 > 8.0 and comp_cs_lysis_u95 <= 8.0 and comp_cs_si_l95 >= 2.5:
# Composite promotion ALWAYS requires all 4 COMP_R4 secondary endpoints (no waiver via require_full_7metric_combined_stress_panel=False; AUDIT-REF & AUDIT-REF; DEC-050/051):
if not has_all_4_comp_cs_secondary:
hold_cs_tok = (
'HOLD_COMP_R4_PROMOTION_REQUIRES_COMPLETE_4METRIC_SECONDARY_PANEL'
if observations.get('require_full_7metric_combined_stress_panel') is False
else 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
)
combined_stress_coupon_status = hold_cs_tok
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = hold_cs_tok
else:
combined_stress_coupon_status = 'PROMOTE_ISLET1_COMP_R4_X_BFB_DXB_LOWLOAD1500'
combined_stress_promoted = True
resolved_arch['combined_stress_coupon_promoted_variant'] = 'ISLET1_COMP_R4_X_BFB_DXB_LOWLOAD1500'
elif a_star_cs_lysis_u95 <= 8.0 and comp_cs_lysis_u95 <= 8.0 and comp_cs_si_l95 >= 2.5:
if observations.get('require_full_7metric_combined_stress_panel', True) is not False and not has_all_4_cs_secondary:
combined_stress_coupon_status = 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
else:
combined_stress_coupon_status = 'RETAIN_EMBODIMENT_A_STAR_4143BP'
else:
combined_stress_coupon_status = 'HOLD_COMBINED_STRESS_COUPON_FAILED'
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = 'HOLD_COMBINED_STRESS_COUPON_FAILED'
elif has_a_star_cs and _upper95('obs_combined_stress_embodiment_a_star_lysis_pct') <= 8.0 and not has_comp_cs_lysis and not has_comp_cs_si:
if observations.get('require_full_7metric_combined_stress_panel', True) is not False and not has_all_4_cs_secondary:
combined_stress_coupon_status = 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = 'HOLD_COMBINED_STRESS_INCOMPLETE_SECONDARY_PANEL'
else:
combined_stress_coupon_status = 'RETAIN_EMBODIMENT_A_STAR_4143BP'
else:
combined_stress_coupon_status = 'HOLD_COMBINED_STRESS_INCOMPLETE_COMPARATOR_EVIDENCE'
if resolved_arch.get('lot_maturation_status') in ('READY_FOR_ENCAPSULATION', 'READY_WITH_RETAINED_PRIOR_S9_INVESTIGATION_HISTORY'):
resolved_arch['lot_maturation_status'] = 'HOLD_COMBINED_STRESS_INCOMPLETE_COMPARATOR_EVIDENCE'
else:
combined_stress_coupon_status = 'PENDING_COMBINED_STRESS_COUPON_EXECUTION'
combined_stress_spec['evaluation_status'] = combined_stress_coupon_status
has_explicit_maturity_obs = bool(
'obs_gate0m_shutoff_t90_min' in validated_stage0
and 'obs_basal_insulin_frac_peak' in validated_stage0
and 'obs_glucose_threshold_mM' in validated_stage0
)
has_explicit_immune_and_ocr_core_obs = bool(
'obs_hlae_hour0_molecules' in validated_stage0
and 'obs_cd47_hour0_molecules' in validated_stage0
and 'obs_nkg2a_lysis_pct' in validated_stage0
and ('obs_serpinb9_hour0_uM' in validated_stage0 or 'obs_gate0c_hour0_serpinb9_uM' in validated_stage0)
and ('obs_regimeII_lysis_2h_pct' in validated_stage0 or 'obs_gate0c_2h_lysis_pct' in validated_stage0)
and 'obs_lot_ocr_ratio' in validated_stage0
)
has_explicit_indirect_apc_gate0d_obs = bool(
(
has_complete_arm2_6endpoint_panel
and not arm2_depletion_verification_incomplete
and not arm2_rebound_injury_or_function_failed
)
if adjunct_conditioning_history_arm == 'ARM2_CONDITIONED_DEPLETED'
else (
adjunct_conditioning_history_arm == 'ARM3_CONTINUOUSLY_ACTIVE'
and 'obs_indirect_apc_dq2_dq8_cd4_stimulation_index' in validated_stage0
and 'obs_indirect_apc_cd4_ifng_si' in validated_stage0
and 'obs_gate0d_activated_cd4_fasl_apoptosis_pct' in validated_stage0
and 'obs_gate0d_transwell_beta_annexin_v_pct' in validated_stage0
and not indirect_apc_cd4_failed
and not arm3_ongoing_bioactivity_explicit_false
)
)
has_explicit_exogenous_b2m_obs = bool(
'obs_exogenous_b2m_w632_surface_fold_isotype' in validated_stage0
and 'obs_exogenous_b2m_t1d_ctl_lysis_pct' in validated_stage0
and not exogenous_b2m_class1_rescue_failed
)
has_explicit_glucagon_and_perfusion_obs = bool(
('obs_gate0m_glucagon_2mM_fold_increase' in validated_stage0 or 'obs_alpha_glucagon_low_glc_fold' in validated_stage0)
and 'obs_outer_band_kperf_s_inv' in validated_stage0
and _lower95('obs_outer_band_kperf_s_inv') >= 0.10
)
has_explicit_dec046_astra_r5_obs = bool(
'obs_cd47_cc2c6_over_b6h12_ratio' in validated_stage0
and 'obs_complement_c3b_opsonized_phagocytosis_pct' in validated_stage0
and 'obs_iec_vascular_support_viability_pct' in validated_stage0
and 'obs_nkg2a_neg_kir2dl_neg_nkg2c_pos_nk_lysis_pct' in validated_stage0
and 'obs_12pulse_unprimed_hypoxic_serial_lysis_pct' in validated_stage0
and 'obs_recipient_insulin_clearance_tau_min' in validated_stage0
and 'obs_hlae_nkg2c_over_nkg2a_kd_ratio' in validated_stage0
and 'obs_il12_il18_sirpa_low_nk_lysis_pct' in validated_stage0
and 'obs_immaturity_corner_min_glucose_mM' in validated_stage0
and 'obs_alpha_counterregulatory_gain_ratio' in validated_stage0
and 'obs_ucn3_maturity_ratio' in validated_stage0
)
has_explicit_dec047_tumour_and_retention_obs = bool(
'obs_residual_psc_effective_fraction' in validated_stage0
and residual_psc_trials_supplied
and residual_psc_trials >= 299573228.0
and 'obs_20q11_bcl2l1_cnv_ratio' in validated_stage0
and 'obs_20q11_bcl2l1_single_cell_mosaic_fraction' in validated_stage0
and 'obs_hazard_state_prolif_survivor_count_k' in validated_stage0
and hazard_prolif_trials_supplied
and hazard_prolif_trials >= 299573228.0
and 'obs_cd47_p10_single_cell_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_cd47_p10_single_cell_molecules') == 'EXPLICIT_SE_SUPPLIED'
and validated_stage0['obs_cd47_p10_single_cell_molecules'] >= 180000.0
and _lower95('obs_cd47_p10_single_cell_molecules') >= 180000.0
and 'obs_hypoxic_72h_cd47_p10_single_cell_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_hypoxic_72h_cd47_p10_single_cell_molecules') == 'EXPLICIT_SE_SUPPLIED'
and validated_stage0['obs_hypoxic_72h_cd47_p10_single_cell_molecules'] >= 180000.0
and _lower95('obs_hypoxic_72h_cd47_p10_single_cell_molecules') >= 180000.0
and 'obs_hypoxic_72h_hlae_p10_single_cell_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_hypoxic_72h_hlae_p10_single_cell_molecules') == 'EXPLICIT_SE_SUPPLIED'
and validated_stage0['obs_hypoxic_72h_hlae_p10_single_cell_molecules'] >= 15000.0
and _lower95('obs_hypoxic_72h_hlae_p10_single_cell_molecules') >= 15000.0
and 'obs_hypoxic_72h_cd47_retention_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_hypoxic_72h_cd47_retention_molecules') == 'EXPLICIT_SE_SUPPLIED'
and validated_stage0['obs_hypoxic_72h_cd47_retention_molecules'] >= 180000.0
and _lower95('obs_hypoxic_72h_cd47_retention_molecules') >= 180000.0
and 'obs_hypoxic_72h_hlae_retention_molecules' in validated_stage0
and se_provenance_by_mean.get('obs_hypoxic_72h_hlae_retention_molecules') == 'EXPLICIT_SE_SUPPLIED'
and validated_stage0['obs_hypoxic_72h_hlae_retention_molecules'] >= 15000.0
and _lower95('obs_hypoxic_72h_hlae_retention_molecules') >= 15000.0
and 'obs_periimplant_fluid_film_um' in validated_stage0
and 'obs_explant_en_bloc_recovery_fraction' in validated_stage0
and 'obs_gate0s_ap1903_supernatant_insulin_dump_fraction_24h' in validated_stage0
and 'obs_gate0s_ap1903_1h_insulin_burst_iu' in validated_stage0
and _upper95('obs_gate0s_ap1903_1h_insulin_burst_iu') <= 2.8
and not residual_psc_failed
and not chr20q11_bcl2l1_cnv_failed
and not hazard_state_prolif_survivor_detected
and not periimplant_fluid_film_failed
and not explant_retrieval_failed