Crate strobemers

Crate strobemers 

Source
Expand description

Strobemers is a crate to generate strobemers. It aims to provide a toolkit for reproducing existing strobemer implementations while allowing individual components to be easily swapped out (e.g. hash function, window generator, or strobe selector). Here is a simple example:

 use strobemers::StrobemerBuilder;
 let reference = b"ACGCGTACGAATCACGCCGGGTGTGTGTGATCG";
 let n: usize = 2;
 let k: usize = 15;
 let w_min: usize = 16;
 let w_max: usize = 30;

 let mut randstrobe_iter = StrobemerBuilder::new()
     .reference(reference)
     .n(n)
     .k(k)
     .w_min(w_min)
     .build()
     .unwrap();
 for strobe in randstrobe_iter {
     println!("randstrobe start positions: {:?}", strobe);
 }

You can also begin with a specific implementation (consisting of hasher, window, and strobe selector) and swap individual components out with your own. For example using a provided randstrobe implementation with a custom hash function:

 use strobemers::StrobemerBuilder;
 use strobemers::implementations::{RandstrobeSahlin2021, StrobeHasher};
 use wyhash::wyhash;
 let reference = b"ACGCGTACGAATCACGCCGGGTGTGTGTGATCG";
 let n: usize = 2;
 let k: usize = 15;
 let w_min: usize = 16;
 let w_max: usize = 30;

 struct WyHasher;
 impl StrobeHasher for WyHasher {
     fn hash(&self, input: &[u8], k: usize) -> Vec<u64> {
         let mut input_hashes = Vec::new();
         for i in 0..input.len() - k {
             input_hashes.push(wyhash(&input[i..i + k], 42));
         }
         input_hashes
     }
 }

 let mut randstrobe_iter = StrobemerBuilder::from_implementation(RandstrobeSahlin2021)
     .reference(reference)
     .n(n)
     .k(k)
     .w_min(w_min)
     .hasher(Box::new(WyHasher))
     .build()
     .unwrap();
 for strobe in randstrobe_iter {
     println!("randstrobe start positions: {:?}", strobe);
 }

Re-exports§

pub use strobemer::StrobemerBuilder;

Modules§

implementations
strobemer

Enums§

StrobemerError