Skip to content

feat: pair orientation, MQ, discordant count, fixmate-exact TLEN - #5

Open
jayhesselberth wants to merge 1 commit into
mainfrom
feat/pair-orientation-mq-fixmate
Open

jayhesselberth wants to merge 1 commit into
mainfrom
feat/pair-orientation-mq-fixmate

Conversation

@jayhesselberth

Copy link
Copy Markdown
Member

Closes #4

Most of #4 already landed in #3 (-1/-2, --interleaved, paired uBAM, joint pair scoring on the existing score rows for CPU and GPU, pair-aware chunking, proper-pair flags, MC, --sort coordinate, --secondary). This PR closes the remaining gaps against the issue.

Changes

  • --pair-orientation fr|rf|ff (default fr), carried as PairOrientation in PairOptions. fr is the existing behaviour. rf: opposite strands, reverse mate starts at or before the forward mate. ff: same strand, mate 1 upstream.
  • MQ (mate MAPQ) is now written next to MC. MC:Z:* is written when the mate is unmapped, as samtools fixmate does.
  • TLEN now follows samtools fixmate (partner 5' end minus own 5' end) so a fixmate round trip is a no-op. It is identical to the old span for ordinary FR pairs, and differs for same-strand and overhanging pairs.
  • Discordant pairs (mates whose best references differ, each reported at its own) are counted in the run summary.
  • A non-adjacent paired BAM says to run samtools collate / samtools sort -n.
  • Tests: expected names from the issue in align_paired.rs (renamed or split from the existing ones), plus joint_score_breaks_tie_a_mate_cannot, discordant_pair_flags_and_counts, non_adjacent_bam_mates_say_to_collate, pair_orientation_ff_makes_same_strand_pair_proper, and library orientation_rf_and_ff. The single-end golden test moved from align_unpaired.rs to align_paired::single_end_output_unchanged (golden file untouched, so single-end output is byte-identical). Fixture: one extra discordant pair appended to the synthesized pairs files (gen_pair_fixture.py, no real data).

How the equality tests were checked to fail

Each was run against a deliberately broken implementation and failed, then the break was reverted:

Test Breakage
joint_score_breaks_tie_a_mate_cannot pair score = mate 1 only
fastq_pair_matches_interleaved_and_ubam interleaved reader drops mate-1 qualities
sort_coordinate_matches_samtools_and_fixmate TLEN off by one
single_end_output_unchanged unique MAPQ 59
discordant_pair_flags_and_counts discordant counter not incremented
mate_name_mismatch_is_an_error name check disabled
orientation_rf_and_ff ff geometry always true

device_gpu_output_is_byte_identical compiles under --features gpu (clippy clean) but was not run: no GPU here.

Checks

cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings (also with --features gpu), cargo nextest run --workspace (126 passed), cargo test --doc --workspace.

🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

feat: paired-end alignment (two FASTQs, interleaved, paired uBAM) with proper BAM pair records

1 participant