Skip to content

refactor(umi): remove redundant allocations, use byte comparison - #137

Merged
nh13 merged 1 commit into
mainfrom
refactor/nh/simplify-fgumi-umi
Feb 28, 2026
Merged

nh13 merged 1 commit into
mainfrom
refactor/nh/simplify-fgumi-umi

Conversation

@nh13

@nh13 nh13 commented Feb 28, 2026

Copy link
Copy Markdown
Member

Summary

  • Replace TagSets::consensus_reverse() and consensus_revcomp() methods (which allocated Vec<String> on every call) with CONSENSUS_REVERSE and CONSENSUS_REVCOMP static slice constants
  • Simplify IdentityUmiAssigner::assign to uppercase each UMI once instead of twice
  • Change count_mismatches from .chars().zip() to .as_bytes().iter().zip() for more efficient byte-level comparison on ASCII UMI sequences

Test plan

  • cargo nextest run -p fgumi-umi — all tests pass
  • cargo clippy -p fgumi-umi --all-features -- -D warnings — no warnings
  • cargo check (full workspace) — clean

- IdentityUmiAssigner::assign: uppercase each UMI once instead of twice,
  eliminate redundant unique_canonicals Vec by using HashSet directly,
  and use sort_unstable for deterministic ID assignment
- TagSets: replace consensus_reverse()/consensus_revcomp() methods that
  allocated Vec<String> on every call with CONSENSUS_REVERSE/CONSENSUS_REVCOMP
  static slice constants
- count_mismatches: use byte comparison instead of char iteration since
  UMI sequences are always ASCII
@nh13
nh13 temporarily deployed to github-actions February 28, 2026 21:42 — with GitHub Actions Inactive
@codecov

codecov Bot commented Feb 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.50%. Comparing base (fa96485) to head (d52f3f2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #137      +/-   ##
==========================================
- Coverage   83.50%   83.50%   -0.01%     
==========================================
  Files         126      126              
  Lines       51375    51375              
==========================================
- Hits        42901    42899       -2     
- Misses       8474     8476       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai

coderabbitai Bot commented Feb 28, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR refactors the UMI assignment logic to compare bytes instead of chars and improves canonical UMI deduplication by using HashSet for explicit deduplication. Two public helper functions are replaced with public constants, reducing allocations and simplifying the API. Tests and internal usage are updated accordingly to match the new constant-based approach.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The description clearly outlines all three key changes (constant vectors, simplified assign logic, and byte comparison) with test validation confirming implementation.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title accurately summarizes the main changes: removing redundant allocations and switching to byte comparison. It covers the primary refactoring goals.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/nh/simplify-fgumi-umi

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@nh13 nh13 added the enhancement New feature or request label Feb 28, 2026
@nh13 nh13 changed the title Simplify fgumi-umi: remove redundant allocations, use byte comparison refactor(umi): remove redundant allocations, use byte comparison Feb 28, 2026
@nh13
nh13 merged commit 58cd79b into main Feb 28, 2026
7 checks passed
@nh13
nh13 deleted the refactor/nh/simplify-fgumi-umi branch February 28, 2026 23:49
This was referenced Feb 28, 2026

This branch was previously deployed

1 inactive deployment
github-actions — d52f3f29 Deployed Feb 28, 2026 by nh13 via coverage #476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant