Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with reverse complement not being normalized. #65

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions lib/src/sketch_schemes/mash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ impl MashSketcher {

impl SketchScheme for MashSketcher {
fn process(&mut self, seq: &SequenceRecord) {
self.total_bases += seq.sequence().len() as u64;
let rc = seq.reverse_complement();
for (_, kmer, is_rev_complement) in
seq.normalize(false).canonical_kmers(self.kmer_length, &rc)
let norm_seq = seq.normalize(false);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think in practice this trait is not well thought. The process function should take a &Sequence since we do not need anything from the &SequenceRecord and normalizing it here implicitly would allocate twice for normalized sequence if you need that elsewhere. In that case you would still need to call normalize before calling process though.

self.total_bases += norm_seq.sequence().len() as u64;
let rc = norm_seq.reverse_complement();
for (_, kmer, is_rev_complement) in norm_seq.canonical_kmers(self.kmer_length, &rc)
{
let rc_count = u8::from(is_rev_complement);
self.push(kmer, rc_count);
Expand Down
8 changes: 4 additions & 4 deletions lib/src/sketch_schemes/scaled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ impl ScaledSketcher {

impl SketchScheme for ScaledSketcher {
fn process(&mut self, seq: &SequenceRecord) {
self.total_bases += seq.sequence().len() as u64;
let rc = seq.reverse_complement();
for (_, kmer, is_rev_complement) in
seq.normalize(false).canonical_kmers(self.kmer_length, &rc)
let norm_seq = seq.normalize(false);
self.total_bases += norm_seq.sequence().len() as u64;
let rc = norm_seq.reverse_complement();
for (_, kmer, is_rev_complement) in norm_seq.canonical_kmers(self.kmer_length, &rc)
{
let rc_count = u8::from(is_rev_complement);
self.push(kmer, rc_count);
Expand Down