Repository navigation
fix(extract): support non-terminal + and reject over-long reads in read structures (R2-RS-01, R2-RS-02) - #496
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (4)
WalkthroughAdds a public local ChangesRead structure and FASTQ extraction
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant FASTQRecord
participant FastqSet
participant ReadStructure
FASTQRecord->>FastqSet: provide sequence and quality
FastqSet->>ReadStructure: check_read_length(read_len)
ReadStructure-->>FastqSet: LengthCheck result
FastqSet->>ReadStructure: span_of(segment_index, read_len)
ReadStructure-->>FastqSet: segment span
FastqSet-->>FASTQRecord: extracted segments
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #496 +/- ##
==========================================
+ Coverage 91.08% 91.18% +0.09%
==========================================
Files 78 79 +1
Lines 51726 52418 +692
==========================================
+ Hits 47116 47798 +682
- Misses 4610 4620 +10 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
a9e4a9a to
50f36c4
Compare
c8fba87 to
ab2eaf3
Compare
50f36c4 to
f165260
Compare
ab2eaf3 to
247488d
Compare
f165260 to
9879c95
Compare
247488d to
194e224
Compare
194e224 to
3b7125d
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/fastq.rs`:
- Around line 235-275: Update the public # Errors documentation for the affected
read-parsing method to document sequence/quality length mismatches and over-long
reads against fixed structures, and remove references to obsolete per-segment
extraction errors. Locate the documentation adjacent to the method containing
the LengthCheck match and ensure it accurately lists all errors returned by that
method.
In `@src/lib/read_structure.rs`:
- Around line 167-190: Reject arithmetic overflow throughout ReadStructure
parsing: update length parsing, fixed-length summation, and offset accumulation
in the structure parser (including the post-`+` reverse pass) to use
checked_mul/checked_add and propagate a dedicated ReadStructureError instead of
panicking or wrapping. Ensure overflow is detected before validation completes
so span_of cannot receive wrapped offsets.
- Around line 15-20: Correct the module documentation describing end-anchored
segment offsets: update the statement that offsets after the indefinite-length
segment are stored as negative numbers to state that they are represented by
positive distances from the read end via SegOffset::FromEnd(usize).
- Around line 341-349: Convert rejects_multiple_plus_and_bad_tokens into an
rstest parameterized test, adding one #[case] for each malformed structure and
passing the case value to ReadStructure::from_str so failures identify the exact
input; retain the separate assertion for the MissingOperator error on "8B+".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 42dd6d51-30ca-4d38-82f7-b45d42bc34bc
📒 Files selected for processing (4)
src/lib/commands/extract.rssrc/lib/fastq.rssrc/lib/mod.rssrc/lib/read_structure.rs
3b7125d to
402370d
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/lib/commands/extract.rs`:
- Line 310: Correct the user-facing CLI help text in the read-structure
documentation near the comment line by replacing “monotemplate” with “template”;
preserve the surrounding wording and formatting.
In `@src/lib/read_structure.rs`:
- Around line 348-447: Add proptest-based tests alongside the existing
read-structure tests, covering normalized parsing round trips through
ReadStructure::from_str and to_string, plus span_of invariants that each span
satisfies start <= end <= read_len and spans provide contiguous coverage.
Generate valid structures and read lengths, and ensure the properties exercise
variable and fixed segments beyond the current examples.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: 7a781ba7-c626-4381-b5b8-ead4333e12aa
📒 Files selected for processing (4)
src/lib/commands/extract.rssrc/lib/fastq.rssrc/lib/mod.rssrc/lib/read_structure.rs
…d structures (R2-RS-01, R2-RS-02)
fgumi consumes the read-structure 0.2.0 crate, which (a) rejects a `+` (any-length) segment in any position but the last, and (b) silently truncates trailing bases when a read is longer than a fully-fixed structure. Both diverge from fgbio 4.1.0 (ReadStructure #1157), the parity target.
Add a local read-structure implementation (the crate stays pinned at 0.2.0, reusing its SegmentType) that mirrors fgbio's model: a single `+` may appear in any position, with segments after it resolved by counting back from the read end; a fully-fixed structure requires an exact read length, so an over-long read is an error rather than a silent truncation. Wire it into `extract` and the FASTQ segmenter (structure-level extraction).
R2-RS-01 (non-terminal +): before, fgumi errored at parse ("non-terminal segment that has an indefinite length"); after, fgumi extracts identically to fgbio.
R2-RS-02 (over-long, fully-fixed): before, fgumi silently dropped trailing bases; after, fgumi errors, matching fgbio.
Parity evidence (fgbio FastqToBam oracle vs fgumi extract; read structure 8B+M10T on a 30bp read, 8M2T on a 12bp read):
R2-RS-01 before: fgumi exit=2 (parse error) after: fgumi exit=0 RX=ACGTACGTACGT out_seq=ACGTACGTAC (== fgbio)
R2-RS-02 before: fgumi exit=0 (truncated to AC) after: fgumi exit=1 rejected (== fgbio)
402370d to
8332e23
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Two
extractread-structure behaviors diverge from fgbio 4.1.0 (the parity target,ReadStructure#1157). Both stem from theread-structure = 0.2.0crate:+(any-length) segment in any position (e.g.8B+M10T,+M70T) and extracts segments after the+by counting back from the read end. The crate rejects all non-terminal+at parse time, sofgumi extracterred before it did any work.Fix
Add a small local read-structure implementation (
src/lib/read_structure.rs) that mirrors fgbio's model — a single+in any position, post-+segments anchored to the read end, and exact-length validation for fully-fixed structures (over-long ⇒ error, never a silent truncation). Theread-structurecrate stays pinned at 0.2.0 (itsSegmentTypeis reused); bumping to 0.3.0 would fix R2-RS-01 but change trailing-+from zero-or-more to one-or-more (a new parity break) and force a breaking API migration. Wired intoextractand the FASTQ segmenter (extraction is now structure-level).Parity evidence (§0 step 2 → step 4)
Oracle:
fgbio FastqToBamvsfgumi extract. Read structure8B+M10Ton a 30bp read;8M2Ton a 12bp read.+exit=2(parse error)exit=0RX=ACGTACGTACGTout_seq=ACGTACGTACexit=0(truncated toAC)exit=1(rejected)Repro script:
reports/fgbio-parity-fixtures/extract-read-structure-parity.sh(+.before.txt/.after.txt).Tests / CI
read_structure(parse of non-terminal+, multiple-+/ zero-length rejection,span_ofwalk-back, exact-length vs zero-or-more validation) andfastq(structure-level extraction of8B+M10T, over-long rejection incl. under theTooFewBasesskip reason).cargo ci-fmt/ci-lint/ci-testall clean (2233 passed).Stacking
Stacked on #489 (
nh/fix-extract-readname-umi-strict) — sharesextract.rs. Auto-retargets tomainwhen #489 merges. Merge order: #489 → this.Tracker: fgbio↔fgumi behavioral parity round 2 — R2-RS-01, R2-RS-02 (§R2.4, PR 2 addendum).
Summary by CodeRabbit
+) segment in any position.+.+positioning behavior.+boundaries and fixed-structure over-long rejection.