Repository navigation
refactor(raw-bam): deduplicate aux iteration, use field accessors - #135
Conversation
📝 WalkthroughWalkthroughThis pull request refactors field access patterns across the BAM record handling crate by consolidating field extraction into helper functions, reducing code duplication, and removing redundant decoding tables. Changes include replacing manual byte offset calculations in sort.rs and tags.rs with accessor calls, removing BASE_DECODE in favor of existing BAM_BASE_TO_ASCII, introducing a RefPosMode enum for cleaner position calculation logic, and adjusting a u8 cast in builder.rs. Comprehensive unit test coverage is added across multiple modules (cigar.rs, fields.rs, sequence.rs, tags.rs) to exercise existing functionality. Public API signatures remain unchanged. 🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #135 +/- ##
==========================================
- Coverage 83.50% 83.49% -0.01%
==========================================
Files 126 126
Lines 51375 51375
==========================================
- Hits 42901 42898 -3
- Misses 8474 8477 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
1f7a048 to
1a35942
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@crates/fgumi-raw-bam/src/cigar.rs`:
- Around line 868-990: Several test functions in this module have duplicate
names and will fail compilation (E0428); locate the duplicated test functions
named test_query_length_from_cigar_empty,
test_read_pos_at_ref_pos_raw_before_alignment,
test_read_pos_at_ref_pos_raw_in_deletion,
test_read_pos_at_ref_pos_raw_with_insertion, and
test_read_pos_at_ref_pos_raw_with_soft_clip and either remove the redundant
copies or rename them to unique identifiers (e.g., append _2 or a descriptive
suffix) so each test function name is unique; ensure any renamed tests keep the
same assertions and references to helper functions like query_length_from_cigar
and read_pos_at_ref_pos_raw.
ℹ️ Review info
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (8)
crates/fgumi-raw-bam/src/builder.rscrates/fgumi-raw-bam/src/cigar.rscrates/fgumi-raw-bam/src/fields.rscrates/fgumi-raw-bam/src/overlap.rscrates/fgumi-raw-bam/src/sequence.rscrates/fgumi-raw-bam/src/sort.rscrates/fgumi-raw-bam/src/tags.rscrates/fgumi-raw-bam/src/testutil.rs
…nsolidate decode tables
1a35942 to
2ad9de6
Compare
Summary
Seven simplification fixes reducing code by ~208 lines:
BASE_DECODEandDECODEconstants, use singleBAM_BASE_TO_ASCIIeverywherefind_mc_tag: Rewrite as one-liner delegating tofind_string_taginstead of duplicating the aux iteration loopaux_data_sliceinfind_*_in_record: Replace manual offset computation infind_mc_tag_in_recordandfind_mi_tag_in_recordfields.rsaccessors insort.rs: Replace inline byte operations with named accessor functions (ref_id,pos,flags,read_name, etc.)compute_bases_past/before_ref_pos: ExtractRefPosModeenum and sharedcompute_read_pos_at_refimplementation, eliminating copy-pasted overlap logicbuilder.rs: Direct cast after length guardtags.rsfunctionsTest plan
cargo nextest run -p fgumi-raw-bam— all tests passcargo clippy -p fgumi-raw-bam --all-features -- -D warnings— no warningscargo check(full workspace) — cleancargo ci-fmt— clean