Skip to content

fix: pair fa:Z extras with correct annotations on reverse-strand reads#103

Merged
mrvollger merged 1 commit intomainfrom
fix/fibertig-reverse-strand-fa
Apr 22, 2026
Merged

fix: pair fa:Z extras with correct annotations on reverse-strand reads#103
mrvollger merged 1 commit intomainfrom
fix/fibertig-reverse-strand-fa

Conversation

@mrvollger
Copy link
Copy Markdown
Member

Summary

  • Fix fibertig fa:Z / fs / fl tag pairing on reverse-strand (supplementary rev-comp) reads, where FiberAnnotations::new flips fs/fl via positions_on_aligned_sequence but from_bam_tags left the auxiliary fa:Z vector in tag-storage order — causing extras to be paired with the wrong annotation (symmetric peak swap) whenever multiple peaks were present.
  • Reverse ann_vals before zipping when record.is_reverse() so extras align with the already-flipped annotations.
  • Add regression tests covering forward-strand (4 peaks) and reverse-strand (5 peaks, including overlapping peaks) pairing.

Test plan

  • cargo test passes with the fix
  • Confirmed new reverse-strand test fails without the fix (annotations[0] gets peakA extras instead of peakE)
  • Spot-check on the real fibertig CRAM from the bug report

FiberAnnotations::new re-orders fs/fl into aligned (reference) order when
the record is reverse-complement aligned, but from_bam_tags was pairing the
fa:Z extras in their original tag-storage order. Result: on reverse-strand
reads the extras of adjacent annotations were silently swapped. ref_start
/ref_end remained correct; only the extra columns were mis-paired, so the
symptom looked like peak-size labels getting swapped between overlapping
peaks.

Fix: reverse the split fa:Z values when record.is_reverse() so they match
FiberAnnotations::new's already-flipped order.

Adds two regression tests covering a forward-strand baseline and a
reverse-strand case with 5 peaks (last two overlapping) to catch any
off-by-one pairing error. Confirmed the reverse-strand test fails without
the fix.
@mrvollger mrvollger merged commit c870005 into main Apr 22, 2026
8 checks passed
@mrvollger mrvollger mentioned this pull request Apr 22, 2026
5 tasks
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.

1 participant