From 038d55cbb63f234678d5804332dd15cc123b0321 Mon Sep 17 00:00:00 2001 From: Ken Youens-Clark Date: Mon, 24 Jun 2024 13:28:52 -0700 Subject: [PATCH] cleanup --- Makefile | 4 ++++ src/search.rs | 55 ++++++++++++++++++++++++++++----------------------- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index b9c63bb..c3d0d75 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ FIXTURES := fixtures/test-rna.fasta fixtures/test-dna.fasta REL_EXE := target/release/the_count RNA50 = tests/inputs/rna-50k.fasta +RNA100 = tests/inputs/rna-100k.fasta DNA_FA = tests/inputs/dna.fasta DNA_FQ = tests/inputs/dna.fastq BIG_DNA = fixtures/test-dna.fasta @@ -9,6 +10,9 @@ BIG_RNA = fixtures/test-rna.fasta fitty: cargo run -- -r $(RNA50) -d $(DNA_FA) -o - +hunna: + cargo run -- -r $(RNA100) -d $(DNA_FA) -o - + big: cargo run -- -v -r $(BIG_RNA) -d $(BIG_DNA) -o /dev/null diff --git a/src/search.rs b/src/search.rs index a524f63..dbef0c1 100644 --- a/src/search.rs +++ b/src/search.rs @@ -38,6 +38,7 @@ impl Search { } } + // Nothing seems to use the search results (which uses the id) pub fn search( &mut self, sequence: &str, @@ -107,34 +108,38 @@ impl Search { // results.push(result); //} - dbg!(&self.haystack_window); - if let Some(index) = self.needles.find_inc(self.haystack_window) { - dbg!(index); - //self.needles.inc_at(index); - //let result = SearchResult { - // haystack: id.to_string(), - // needle: self.haystack_window, - // offset: self.haystack_index - 32, - // index, - //}; - //results.push(result); - } + //dbg!(&self.haystack_window); + self.needles.inc_hits(self.haystack_window); + //if let Some(index) = self.needles.find_inc(self.haystack_window) { + // dbg!(index); + // self.needles.inc_at(index); + // let result = SearchResult { + // haystack: id.to_string(), + // needle: self.haystack_window, + // offset: self.haystack_index - 32, + // index, + // }; + // results.push(result); + //} - dbg!(&self.rev_haystack); - if let Some(index) = self.needles.find_inc(self.rev_haystack) { - dbg!(index); - //self.needles.inc_at(index); - //let result = SearchResult { - // haystack: id.to_string(), - // needle: self.rev_haystack, - // offset: self.haystack_index - 32, - // index, - //}; - //results.push(result); - } + //dbg!(&self.rev_haystack); + self.needles.inc_hits(self.rev_haystack); + //if let Some(index) = self.needles.find_inc(self.rev_haystack) { + // dbg!(index); + // self.needles.inc_at(index); + // let result = SearchResult { + // haystack: id.to_string(), + // needle: self.rev_haystack, + // offset: self.haystack_index - 32, + // index, + // }; + // results.push(result); + //} } } + // An attempt to remove mutable access to self to use in parallel + // But uses DashMap to update hits and I'm not positive this is great pub fn pure_search( &self, needles: &Hash, @@ -182,7 +187,7 @@ impl Search { if let Some(_index) = needles.find(*val) { //let index = index as u64; dbg!(val); - if let Some(mut count) = hits.get_mut(&val) { + if let Some(mut count) = hits.get_mut(val) { *count += 1; } else { hits.insert(*val, 1);