Skip to content

feat(count): add --reverse-complement to also match RC of guides#30

Open
werner291 wants to merge 1 commit into
fulcrumgenomics:mainfrom
werner291:wk/reverse-complement
Open

feat(count): add --reverse-complement to also match RC of guides#30
werner291 wants to merge 1 commit into
fulcrumgenomics:mainfrom
werner291:wk/reverse-complement

Conversation

@werner291

@werner291 werner291 commented May 7, 2026

Copy link
Copy Markdown

Closes #19.

Adds --reverse-complement / -r to guide-counter count for assays whose sequencing primer reads the antisense strand. Off by default; output schema unchanged.

Each guide is stored under its canonical form (lex-min of fwd and RC), keeping the lookup the same size as forward-only. Each read window is then looked up under both its forward and reverse-complement forms; if the two probes return different guides, the read counts as ambiguous (None), otherwise the matching guide wins. (One probe isn't enough because a 1-mismatch hit can live in the 1-mm neighbourhood of either orientation, not just canonical.) Palindromes collapse to one entry; canonical collisions across guides (fwd_A == rc(fwd_B)) evict both. Windows with non-ACGT bytes skip the RC probe.

One asymmetry: in forward-only mode, an exact match beats a 1-mismatch via insertion order. In RC mode, an exact fwd-orientation hit on guide A and a 1-mismatch rc-orientation hit on guide B resolve as ambiguous (None) rather than letting the exact win. Internally consistent, slight sensitivity loss vs. forward-only; happy to add an exact-beats-mismatch tiebreak across orientations if you'd prefer.

The matching logic has a few subtle cases (palindromic guides; reads that could plausibly belong to two different guides once you allow a one-base mismatch). I worked through each and added regression tests, but maintainer eyes on the algorithm would be welcome.

Open question

Whether to add a strand-aware count column. The issue does not ask for it and it would break consumers of *.counts.txt, so v1 keeps the schema; happy to follow up.

@werner291 werner291 requested a review from tfenne as a code owner May 7, 2026 19:55
@werner291 werner291 marked this pull request as draft May 18, 2026 12:07
Stores guides under canonical form (lex-min of fwd, RC) and probes both
orientations on lookup; reads resolving to different guides across
orientations count as ambiguous. Palindromes collapse to one entry;
canonical collisions across guides evict both. Off by default; output
schema unchanged.
@werner291 werner291 force-pushed the wk/reverse-complement branch from 54fee3c to b6df941 Compare May 18, 2026 13:10
@werner291 werner291 marked this pull request as ready for review May 18, 2026 13:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Allow reverse complement matching?

1 participant