Repository navigation
fix(clip): keep MM/ML in step with hard-clipped and unmapped reads - #1012
Conversation
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedUse the following commands to manage reviews:
Use the checkboxes below for quick actions:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (6)
Included review availability: This review used your included allowance. 1 included review remains after this review. Your included PR review attempts over the past 7 days set your current allowance at 2 reviews per hour. WalkthroughClipping now reconciles modification tags with the resulting sequence. The clip command counts records whose tags are removed, and the pipeline warns when that count is nonzero. ChangesModification-tag clipping
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Sequence Diagram(s)sequenceDiagram
participant ClipParams
participant RawRecordClipper
participant trim_clipped_modifications_raw
participant BatchCounts
ClipParams->>RawRecordClipper: Clip records
ClipParams->>trim_clipped_modifications_raw: Reconcile tags with clipped sequence
trim_clipped_modifications_raw-->>ClipParams: Return tag-removal result
ClipParams->>BatchCounts: Add removal count to clipping outcome
Merge Risk: ⚪ Minimal · up to No identified modification-tag clipping issue remains to address before merging. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
Comment |
|
@coderabbitai pause |
✅ Action performedReviews paused. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #1012 +/- ##
==========================================
- Coverage 96.42% 96.42% -0.01%
==========================================
Files 299 299
Lines 151026 151142 +116
==========================================
+ Hits 145623 145733 +110
- Misses 5403 5409 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
9808fa6 to
f170a27
Compare
05d0ab2 to
bc5091f
Compare
f170a27 to
e671d5e
Compare
bc5091f to
a5a7eeb
Compare
a5a7eeb to
f1756cb
Compare
Hard clipping removes bases from SEQ, but clip left MM/ML (and am/bm) as they were. The skips then pointed past the end of the read or at the wrong cytosines, and MN no longer matched SEQ, so MM/ML consumers skipped the record and a later filter removed the tags. A read that clipping unmapped was also mishandled: unmapping a reverse-mapped read reverse-complements SEQ, and the soft-with-mask edit compared it with the pre-clip SEQ in the other orientation, dropping valid calls. Add trim_clipped_modifications_raw. It puts SEQ before and after clipping into MM's original read orientation, each by its own reverse flag, checks that SEQ is now a window of the old SEQ (apart from bases masked to N), drops the calls outside the window or on masked bases, recomputes the skips over the window, and sets MN to the new length when present. An unmapped reverse read, whose SEQ only changed orientation, keeps its tags. clip_template snapshots SEQ, the reverse and unmapped flags and the leading hard clip (all leading H ops) of each record with modification tags; bases removed from the start show up as added leading hard clip, except when clipping then unmapped the read and cleared its CIGAR, where the offset is unknown and the tags are removed rather than misplaced. Tags that did not fit before clipping or cannot be placed are removed, a record without SEQ is left alone, and clip now counts the records that lost their tags and warns at the end of the run. --auto-clip-attributes no longer slices MM/ML/am/bm when their length happens to equal the read's: they are not per-base, and clip trims them itself. The methylation guide and the option's help say so.
f1756cb to
3770c87
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
Stacked on #1010 (base
nh/em-seq-meth-rev3).Summary
#1010 made
clip --clipping-mode soft-with-maskdrop the masked bases' calls fromMM/ML. Two cases were still wrong:MM/ML(andam/bm) as they were, so the skips pointed past the end of the read or at the wrong cytosines andMNno longer matched SEQ.This adds
trim_clipped_modifications_raw, which puts SEQ before and after clipping intoMM's original read orientation (each by its own reverse flag), checks that SEQ is now a window of the old SEQ (apart from bases masked to N), drops the calls outside the window or on masked bases, recomputes the skips, and setsMNto the new length when present.clip_templatesnapshots SEQ, the reverse/unmapped flags and the leading hard clip (all leadingHops) of each record with modification tags. Bases removed from the start show up as added leading hard clip, except when clipping then unmapped the read and cleared its CIGAR: that offset is unknown, so the tags are removed rather than misplaced.*) is left alone. clip now counts the records that lost their tags and warns at the end of the run.--auto-clip-attributesno longer slicesMM/ML/am/bmwhen their length happens to equal the read's: they are not per-base, and clip trims them itself.Testing
MN, anNgroup, masking, unknown offset, staleMN, a SEQ that is not a window, a reverse read trimmed and unmapped, no SEQ).clip_templatetests across the clipper's paths: an existing leading hard clip, upgraded soft clips, auto-clipped attributes, a reverse read clipped completely, a read hard-clipped then unmapped, and a read with a leading hard clip clipped completely.cargo ci-test(11,038 tests),ci-lint,ci-fmt,ci-tag-literals,ci-doc,cargo check -p fgumi-consensus --no-default-features.Risk verdict: The
clipcommand can now change MM/ML/am/bm and MN output to keep modification calls aligned with clipped SEQ; the new clipping tests pin this behavior. Nounsafechange; no CLAUDE.md allowlist update is indicated. No memory-bound, queue-capacity, or thread/backpressure change.cliptrims modification calls that fall outside the retained sequence or on masked bases. It recomputes MM skips and updates an existing MN when possible. If tag placement cannot be established, it removes the affected tags and reports the number of records in a warning. Records without SEQ remain unchanged.--auto-clip-attributesno longer treats MM/ML/am/bm as per-base attributes based on matching read length. The methylation guide documents the clipping behavior.Test and CI results are reported in the supplied PR objectives; they were not independently verified here.