Repository navigation
fix(zipper)!: rename sort-key tag from pa to tc to avoid bwa-mem pa:f collision - #270
Conversation
… collision `fgumi zipper` wrote a `pa:B:i,<6 int32s>` tag on secondary/supplementary records to carry the primary alignments' template-coordinate sort key. bwa-mem already uses `pa:f:<float>` (primary-alignment score fraction), so fgumi-zippered BAMs carried the same tag name with two different types — readers that pick the wrong interpretation silently returned wrong values. Rename the tag from `pa` to `tc` (template-coordinate) everywhere it appears: in the zipper writer (both RecordBuf and raw-byte paths) and the dedup existence check. `tc` names what the tag actually stores and is lowercase per the SAM-spec convention for non-standard program tags. Additionally, move TC_TAG and TemplateCoordinateInfo (formerly PA_TAG and PrimaryAlignmentInfo) out of src/lib/sort/ and into crates/fgumi-sam/ alongside SamTag, since they encode a SAM tag and its on-disk layout, not sort-pipeline internals. Breaking changes: - Zipper CLI flag --skip-pa-tags renamed to --skip-tc-tags. - Dedup metric field missing_pa_tag renamed to missing_tc_tag. - Public Rust items PA_TAG and PrimaryAlignmentInfo renamed to TC_TAG and TemplateCoordinateInfo, and moved from the sort module to fgumi_sam (re-exported through crate::sam). - Existing fgumi-zippered BAMs must be re-zippered (or the tag manually renamed) before fgumi dedup will accept them. Fixes #268.
📝 WalkthroughWalkthroughThis pull request systematically renames the SAM auxiliary tag emitted by 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #270 +/- ##
==========================================
- Coverage 89.84% 89.84% -0.01%
==========================================
Files 120 120
Lines 61359 61170 -189
==========================================
- Hits 55127 54956 -171
+ Misses 6232 6214 -18 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
🧹 Nitpick comments (1)
crates/fgumi-raw-bam/src/tags.rs (1)
2285-2293: Avoid hardcoded source line references in test comments.“exact check from dedup.rs:932-934” will drift quickly; prefer a symbolic description of the logic.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@crates/fgumi-raw-bam/src/tags.rs` around lines 2285 - 2293, The comment in test_dedup_tc_tag_check_fails_on_b_array should not reference a hardcoded source line ("dedup.rs:932-934"); instead update it to describe the logic symbolically (e.g., "this replicates the same TC tag existence check used by the dedup logic") so future code moves won't break the comment; locate the test function test_dedup_tc_tag_check_fails_on_b_array and replace the line mentioning dedup.rs with a short description referencing the involved symbols find_string_tag and find_int_tag (or the dedup check function name if one exists) so the intent is clear without file/line numbers.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@crates/fgumi-raw-bam/src/tags.rs`:
- Around line 2285-2293: The comment in test_dedup_tc_tag_check_fails_on_b_array
should not reference a hardcoded source line ("dedup.rs:932-934"); instead
update it to describe the logic symbolically (e.g., "this replicates the same TC
tag existence check used by the dedup logic") so future code moves won't break
the comment; locate the test function test_dedup_tc_tag_check_fails_on_b_array
and replace the line mentioning dedup.rs with a short description referencing
the involved symbols find_string_tag and find_int_tag (or the dedup check
function name if one exists) so the intent is clear without file/line numbers.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 6dfc4170-af5c-4d0a-80a6-6e4ce8f71f73
📒 Files selected for processing (11)
CHANGELOG.mdcrates/fgumi-raw-bam/src/tags.rscrates/fgumi-sam/src/lib.rscrates/fgumi-sam/src/tag.rscrates/fgumi-sam/src/template_coordinate.rsdocs/src/guide/best-practices.mdsrc/lib/commands/dedup.rssrc/lib/commands/zipper.rssrc/lib/sam/mod.rssrc/lib/sort/keys.rssrc/lib/sort/mod.rs
💤 Files with no reviewable changes (1)
- src/lib/sort/keys.rs
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
… remaining 48-commit work (#296) The final PR in the stacked series closes the full delta against the 48-commit backup. In addition to the original scope (vendored bam_codec deletion + simulate migration), this amends to include: - Missing new files: sort/keys.rs, 4 raw-bam bench files - compare/bams.rs RawRecord migration - codec_caller.rs cascade simplification - group/filter/correct/extract/clip/bam_io.rs simplifications - overlapping.rs raw-only API - Test suite updates for test_compare_bams, test_group_command, test_e2e_regression - Doc touch-ups in best-practices/performance-tuning Verified: tree matches backup except for 6 main-only files (prefetch_reader, os_hints, test_async_reader, template_coordinate, and two benches) that came from main PRs #258/#261/#265/#270/#282 merged after our branch point. Part 8 of 8 in the series closing #272. Stacks on #295.
Summary
Fixes #268.
fgumi zipperwrote apa:B:i,<6 int32s>tag on secondary/supplementary records to carry the primary alignments' template-coordinate sort key. bwa-mem already usespa:f:<float>(primary-alignment score fraction), so fgumi-zippered BAMs carried the same tag name with two different types — readers that pick the wrong interpretation silently returned wrong values, and strict validators rejected the file.This PR renames the tag from
patotc(template-coordinate) everywhere it appears: the zipper writer (bothRecordBufand raw-byte paths) and the dedup existence check.tcnames what the tag actually stores and is lowercase per the SAM-spec convention for non-standard program tags.While in the area,
TC_TAGandTemplateCoordinateInfo(formerlyPA_TAGandPrimaryAlignmentInfo) also moved out ofsrc/lib/sort/and intocrates/fgumi-sam/alongsideSamTag, since they encode a SAM tag and its on-disk layout, not sort-pipeline internals. No behavior change in the sort pipeline itself.Breaking changes
pa:B:i,...→tc:B:i,...on secondary/supplementary records emitted byfgumi zipper.fgumi zipper --skip-pa-tags→fgumi zipper --skip-tc-tags.missing_pa_tag→missing_tc_tagin JSON/TSV metrics output.PA_TAG/PrimaryAlignmentInfo→TC_TAG/TemplateCoordinateInfo, moved fromfgumi_lib::sorttofgumi_sam(re-exported viafgumi_lib::sam).Migration
patag renamed totcwith a one-off pass — beforefgumi dedupwill accept them.pa:B:ifrom fgumi output must switch totc:B:i.pa:ftag is no longer touched and passes through unchanged.Test plan
cargo ci-test(2479 passed, 19 skipped)cargo ci-fmtcargo ci-lint