From 0629cfccfc88a8477203a622b55f3a0c2f68491b Mon Sep 17 00:00:00 2001 From: dparks1134 Date: Tue, 31 Jan 2023 01:58:34 +1000 Subject: [PATCH] Fix bug with reverse complement of sequence not being normalized during identification of canonical kmers. --- Cargo.lock | 2 +- lib/src/sketch_schemes/mash.rs | 8 ++++---- lib/src/sketch_schemes/scaled.rs | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index df805ff..186829a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -280,7 +280,7 @@ dependencies = [ [[package]] name = "finch" -version = "0.4.3" +version = "0.5.0" dependencies = [ "bincode", "capnp", diff --git a/lib/src/sketch_schemes/mash.rs b/lib/src/sketch_schemes/mash.rs index 94667ce..24d169d 100644 --- a/lib/src/sketch_schemes/mash.rs +++ b/lib/src/sketch_schemes/mash.rs @@ -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); + 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); diff --git a/lib/src/sketch_schemes/scaled.rs b/lib/src/sketch_schemes/scaled.rs index c835437..9313009 100644 --- a/lib/src/sketch_schemes/scaled.rs +++ b/lib/src/sketch_schemes/scaled.rs @@ -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);