Skip to content

Cover the remaining paired-guide options, and stop retaining unmatched pairs - #35

Merged
davidliwei merged 1 commit into
mainfrom
test/paired-guide-coverage
Aug 25, 2026
Merged

Cover the remaining paired-guide options, and stop retaining unmatched pairs#35
davidliwei merged 1 commit into
mainfrom
test/paired-guide-coverage

Conversation

@davidliwei

Copy link
Copy Markdown
Owner

Closes the remaining scope of #29: the four uncovered paired-guide options, and the ctab_umi[None] accumulation.

Tests

Case Test
misplaced --pg-start-2/--pg-end-2 test_wrong_second_read_window_yields_no_pairs
--reverse-complement-2, both orientations test_reverse_complement_2_matches_only_the_orientation_it_is_given
--pg-min-read, including the boundary test_pg_min_read_excludes_pairs_below_the_threshold
--pg-pair-only omitted test_all_pairs_are_reported_when_pg_pair_only_is_omitted

All four options behave correctly on main — these are characterization tests, not bug fixes. That makes them worth nothing unless they can fail, so each was run against a deliberately broken build:

Mutation Result
window ignored, always slice [0:20] caught
--reverse-complement-2 made a no-op caught
totalr>=args.pg_min_read> caught
pair filter applied even when the option is absent caught

The window test also asserts count.txt still fills from read 1 while pg_count.txt is header-only — that asymmetry is the signature users actually report (#15), and it is what makes the failure so easy to miss.

A trap removed from the fixture

The fixture's second guide was TGCATGCATGCATGCATGCA, which is its own reverse complement. It matched in either orientation, so a --reverse-complement-2 test built on it would have passed whether the option worked or not. Replaced with a non-palindromic guide, with an assertion in the fixture so it stays that way.

The ctab_umi[None] accumulation

In secondpair mode the second-read window was recorded for every read, including those where read 1 matched no guide, under a None key. mageckcount_printpgdict skips that key, so output was never affected — but it retains one entry per distinct unmatched window, meaning memory grows with the unmapped fraction of the FASTQ rather than with the library.

Measured at a 2% mapping rate (100 matched, 5,000 unmatched):

before:  ctab_umi keys: 6   None present: True    entries under None: 5000
after:   ctab_umi keys: 5   None present: False   entries under None: —

test_unmatched_reads_do_not_accumulate_a_none_key asserts what is retained stays bounded by the library. It was written first and confirmed failing.

Also dropped the per-read umi-start/umi-end check at the firstpair extraction site — the same log-flood pattern fixed for secondpair in #33, now redundant since mageckcount_check_extraction_window validates once before any FASTQ is opened.

43 tests pass.

Closes #29.

…d pairs

Four options on the paired-guide path had no end-to-end test. All four behave
correctly today; these pin that down so the next change to the path cannot
quietly undo it. Each was checked against a deliberately broken build -- window
ignored, --reverse-complement-2 made a no-op, the --pg-min-read comparison
shifted by one, the pair filter forced on -- and each caught its mutant.

The fixture's second guide was TGCATGCATGCATGCATGCA, which is its own reverse
complement, so it matched in either orientation and could not have told a
working --reverse-complement-2 from a missing one. Replaced with a
non-palindromic guide, with an assertion so it stays that way.

Also fixes the accumulation noted in the issue: in secondpair mode the
second-read window was recorded even when read 1 matched no guide, under a None
key that mageckcount_printpgdict skips. Nothing reads it back, but it retains
one entry per distinct unmatched window, so memory grew with the unmapped
fraction of the FASTQ -- 5,000 entries against 100 useful ones at a 2% mapping
rate. Dropped the per-read umi-start check at the firstpair site too, now that
mageckcount_check_extraction_window validates it once up front.

Closes #29.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@davidliwei

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: bff2690bf6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@davidliwei
davidliwei merged commit 3b7046c into main Aug 25, 2026
6 checks passed
@davidliwei
davidliwei deleted the test/paired-guide-coverage branch August 25, 2026 20:03
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.

Remaining paired-guide test coverage, and the ctab_umi[None] accumulation

1 participant