Skip to content

fix issues with olga heavy/light correction functions - #41

Open
psathyrella wants to merge 1 commit into
statbiophys:mainfrom
psathyrella:fix-corrections
Open

fix issues with olga heavy/light correction functions#41
psathyrella wants to merge 1 commit into
statbiophys:mainfrom
psathyrella:fix-corrections

Conversation

@psathyrella

Copy link
Copy Markdown

Fixes #40.

  1. In correct_olga_{heavy,light,paired}, rename the four
    qm.seq_gen_model (and seq_gen_model_{heavy,light}) assignments
    to match the qm.seqgen_model attribute the samplers actually read.
    See correct_olga_{heavy,light} doesn't reach the sequence generator #40 for a reproducer showing that the pre-fix writes land on a
    dead attribute so qm.seqgen_model.CPVJ never picks up the
    correction.

  2. In correct_olga_light (and correct_olga_paired, light half),
    replace the open-ended [:, 1:] / [:, 4:] column slice with an
    explicit [:, [1, 2]] / [:, [4, 5]] so the unpack still works
    when Sonia.__init__ has added a trailing sequence_id column.

  3. Persist the correction through save_model / load_model. When
    correct_olga_* has been called (tracked via a new
    qm._olga_corrected flag), _save_pgen_model now writes the
    corrected @v_choice (VDJ) or @v_choice + @j_choice (VJ) IGoR
    blocks into the saved model_marginals.txt instead of copying the
    OLGA defaults verbatim. Instances without the flag save
    byte-identically to before.

Test additions (all fail on the pre-fix source, pass after):

  • test_correct_olga_light_no_shape_error /
    test_correct_olga_paired_no_shape_error — cover the shape fix.
  • test_correct_olga_{heavy,light}_rebuilds_seqgen_model — cover the
    attribute-name fix by checking qm.seqgen_model and its CPVJ/CPV
    actually change.
  • test_correct_olga_light_biases_sampled_v — end-to-end check that
    post-correction sampling follows the biased V/J.
  • test_save_load_preserves_light_correction /
    test_save_load_preserves_paired_correction — round-trip via
    save_model + reload.
  • test_save_no_correction_byte_identical — baseline guaranteeing
    models without a correction still save byte-identically to the
    shipped defaults.

three issues in correct_olga_*, all covered by tests that fail on the
pre-fix source and pass after:

1. utils.py: rename the four `qm.seq_gen_model` writes
   to `qm.seqgen_model` (no underscore) so the rebuilt sampler
   reaches the attribute the samplers read.
2. utils.py: replace `[:, 1:]` / `[:, 4:]`
   with explicit `[:, [1, 2]]` / `[:, [4, 5]]` so the V/J unpack works
   when Sonia.__init__ has added a trailing `sequence_id` column.
3. sonia.py / sonia_paired.py `_save_pgen_model`: when correct_olga_* has
   set the new `_olga_corrected` flag, rewrite the corresponding IGoR
   blocks (@v_choice for VDJ; @v_choice + @j_choice for VJ) in the saved
   `model_marginals.txt` via a new `write_corrected_marginals` helper.
   Instances without the flag save byte-identically to before.

Fixes statbiophys#40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

correct_olga_{heavy,light} doesn't reach the sequence generator

1 participant