Core API
pen_compare.core.certify
Hierarchical TrueWriter tier classifier (v3.2).
Applies the 5 TrueWriterScore gates per config/gates_v3.yaml (SHA-256 locked). G1 is the necessary gate: failing it auto-classifies as NOT_WRITER regardless of all other gates. G2–G5 are qualifying gates; tier depends on how many pass and whether cell_based is in the evidence set.
- class pen_compare.core.certify.TrueWriterResult(editor_id: 'str', tier: 'str', necessary_gates_passed: 'int', qualifying_gates_passed: 'int', has_cell_based_evidence: 'bool', gate_results: 'tuple[GateResult, ...]', auto_demoted: 'bool', auto_demote_reason: 'str | None')[source]
Bases:
object- Parameters:
- gate_results: tuple[GateResult, ...]
- pen_compare.core.certify.certify(editor_id, s_dsb, s_prog, s_cargo, length_aa, evidence_sources, intrinsic_cargo_mechanism, split_aav_eligible=False, g1_threshold=None, g2_threshold=None, g3_threshold=None, g4_size_max=900)[source]
Apply 5-gate hierarchical certification.
- Tier ladder (v3.2):
TRUE_WRITER — G1 pass + all 4 qualifying pass + cell_based in evidence PROBABLE_WRITER — G1 pass + (4 qualifying, no cell_based) OR (3 qualifying + cell_based) EMERGING_WRITER — G1 pass + 1–2 qualifying pass NOT_WRITER — G1 FAILS (auto-demote, final) OR 0 qualifying pass
- Parameters:
- Return type:
pen_compare.core.gates
5 TrueWriterScore gate functions: 1 necessary + 4 qualifying.
All thresholds come from config/gates_v3.yaml (SHA-256 locked at pre-registration).
- class pen_compare.core.gates.GateRole(value)[source]
Bases:
EnumAn enumeration.
- NECESSARY = 'necessary'
- QUALIFYING = 'qualifying'
- class pen_compare.core.gates.GateResult(gate_id: 'str', name: 'str', role: 'GateRole', passes: 'bool', observed_value: 'float | None', threshold: 'float | None', rationale: 'str')[source]
Bases:
object- Parameters:
- pen_compare.core.gates.gate_1_dsb(s_dsb, threshold=None)[source]
NECESSARY gate — DSB Avoidance. Failing auto-classifies as NOT_WRITER.
- Parameters:
- Return type:
- pen_compare.core.gates.gate_2_programmability(s_prog, threshold=None)[source]
QUALIFYING gate — Programmability.
- Parameters:
- Return type:
- pen_compare.core.gates.gate_3_native_cargo(s_cargo, intrinsic_cargo_mechanism, threshold=None)[source]
QUALIFYING gate — Native Cargo Capability.
Requires BOTH S_Cargo >= threshold AND intrinsic_cargo_mechanism=True. HDR-template-based cargo (SpCas9) does not satisfy intrinsic_cargo_mechanism.
- Parameters:
- Return type:
- pen_compare.core.gates.gate_4_deliverability(length_aa, split_aav_eligible=False, size_max=900)[source]
QUALIFYING gate — Deliverability (AAV-compatible size).
Passes if length_aa <= size_max OR split_aav_eligible. When length_aa is None (not yet annotated), passes if split_aav_eligible=True.
- Parameters:
- Return type:
pen_compare.core.sensitivity
Sensitivity analysis — 18,000 threshold combinations per entity.
Replaces fabricated-sigma bootstrap. Each entity is certified under every combination of the pre-registered sensitivity grid and a robustness fraction is reported: fraction of combinations that agree with the modal tier.
- pen_compare.core.sensitivity.sensitivity_for_entity(row, grid={'g1_threshold': [0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0], 'g2_threshold': [0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0], 'g3_threshold': [0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95], 'g4_size_max': [600, 750, 900, 1050, 1200]})[source]
Run 18,000 certifications for one entity; return robustness metrics.
- pen_compare.core.sensitivity.build_sensitivity_rows(universe, scorecard)[source]
Merge universe + scorecard into flat dicts ready for sensitivity_for_entity.
- pen_compare.core.sensitivity.run_sensitivity_parallel(universe, scorecard, n_jobs=24, grid={'g1_threshold': [0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0], 'g2_threshold': [0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1.0], 'g3_threshold': [0.8, 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9, 0.91, 0.92, 0.93, 0.94, 0.95], 'g4_size_max': [600, 750, 900, 1050, 1200]})[source]
Run sensitivity analysis in parallel; return results DataFrame.