pub trait KmerHasher {
const CANONICAL: bool;
Show 15 methods
// Required methods
fn new(k: usize) -> Self;
fn k(&self) -> usize;
fn in_out_mapper_scalar<'s>(
&self,
seq: impl Seq<'s>,
) -> impl FnMut((u8, u8)) -> u32;
fn in_out_mapper_simd<'s>(
&self,
seq: impl Seq<'s>,
) -> impl FnMut((u32x8, u32x8)) -> u32x8;
fn mapper<'s>(&self, seq: impl Seq<'s>) -> impl FnMut(u8) -> u32;
// Provided methods
fn is_canonical(&self) -> bool { ... }
fn delay(&self) -> Delay { ... }
fn in_out_mapper_ambiguous_scalar<'s>(
&self,
nseq: PackedNSeq<'s>,
) -> impl FnMut((u8, u8)) -> u32 { ... }
fn in_out_mapper_ambiguous_simd<'s>(
&self,
nseq: PackedNSeq<'s>,
context: usize,
) -> impl FnMut((u32x8, u32x8)) -> u32x8 { ... }
fn hash_kmers_scalar<'s>(
&self,
seq: impl Seq<'s>,
) -> impl ExactSizeIterator<Item = u32> { ... }
fn hash_kmers_simd<'s>(
&self,
seq: impl Seq<'s>,
context: usize,
) -> PaddedIt<impl ChunkIt<u32x8>> { ... }
fn hash_valid_kmers_scalar<'s>(
&self,
nseq: PackedNSeq<'s>,
) -> impl ExactSizeIterator<Item = u32> { ... }
fn hash_valid_kmers_simd<'s, 't>(
&'t self,
nseq: PackedNSeq<'s>,
context: usize,
) -> PaddedIt<impl ChunkIt<u32x8> + use<'s, 't, Self>> { ... }
fn hash_seq<'s>(&self, seq: impl Seq<'s>) -> u32 { ... }
fn hash_prefixes<'s>(
&self,
seq: impl Seq<'s>,
) -> impl ExactSizeIterator<Item = u32> { ... }
}Expand description
A hasher that can hash all k-mers in a string.
Note that a KmerHasher must be initialized with a specific k,
so that it can precompute associated constants.
Required Associated Constants§
Required Methods§
fn new(k: usize) -> Self
Sourcefn in_out_mapper_scalar<'s>(
&self,
seq: impl Seq<'s>,
) -> impl FnMut((u8, u8)) -> u32
fn in_out_mapper_scalar<'s>( &self, seq: impl Seq<'s>, ) -> impl FnMut((u8, u8)) -> u32
A scalar mapper function that should be called with each (in, out) base.
The delay should be Self::delay(). The first delay calls should have out=0.
seq is only used to ensure that the hasher can handle the underlying alphabet.
Sourcefn in_out_mapper_simd<'s>(
&self,
seq: impl Seq<'s>,
) -> impl FnMut((u32x8, u32x8)) -> u32x8
fn in_out_mapper_simd<'s>( &self, seq: impl Seq<'s>, ) -> impl FnMut((u32x8, u32x8)) -> u32x8
A SIMD mapper function that should be called with a (in, out) base per lane.
The delay should be Self::delay(). The first delay calls should have out=u32x8::splat(0).
seq is only used to ensure that the hasher can handle the underlying alphabet.
Provided Methods§
Sourcefn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Helper function returning Self::CANONICAL.
Sourcefn delay(&self) -> Delay
fn delay(&self) -> Delay
The delay of the ‘out’ character passed to the in_out_mapper functions.
Defaults to k-1.
fn in_out_mapper_ambiguous_scalar<'s>( &self, nseq: PackedNSeq<'s>, ) -> impl FnMut((u8, u8)) -> u32
fn in_out_mapper_ambiguous_simd<'s>( &self, nseq: PackedNSeq<'s>, context: usize, ) -> impl FnMut((u32x8, u32x8)) -> u32x8
Sourcefn hash_kmers_scalar<'s>(
&self,
seq: impl Seq<'s>,
) -> impl ExactSizeIterator<Item = u32>
fn hash_kmers_scalar<'s>( &self, seq: impl Seq<'s>, ) -> impl ExactSizeIterator<Item = u32>
A scalar iterator over all k-mer hashes in seq.
Sourcefn hash_kmers_simd<'s>(
&self,
seq: impl Seq<'s>,
context: usize,
) -> PaddedIt<impl ChunkIt<u32x8>>
fn hash_kmers_simd<'s>( &self, seq: impl Seq<'s>, context: usize, ) -> PaddedIt<impl ChunkIt<u32x8>>
A SIMD-parallel iterator over all k-mer hashes in seq.
Sourcefn hash_valid_kmers_scalar<'s>(
&self,
nseq: PackedNSeq<'s>,
) -> impl ExactSizeIterator<Item = u32>
fn hash_valid_kmers_scalar<'s>( &self, nseq: PackedNSeq<'s>, ) -> impl ExactSizeIterator<Item = u32>
An iterator over all k-mer hashes in seq.
Ambiguous kmers get hash u32::MAX.
Sourcefn hash_valid_kmers_simd<'s, 't>(
&'t self,
nseq: PackedNSeq<'s>,
context: usize,
) -> PaddedIt<impl ChunkIt<u32x8> + use<'s, 't, Self>>
fn hash_valid_kmers_simd<'s, 't>( &'t self, nseq: PackedNSeq<'s>, context: usize, ) -> PaddedIt<impl ChunkIt<u32x8> + use<'s, 't, Self>>
A SIMD-parallel iterator over all k-mer hashes in seq.
Ambiguous kmers get hash u32::MAX.
Sourcefn hash_seq<'s>(&self, seq: impl Seq<'s>) -> u32
fn hash_seq<'s>(&self, seq: impl Seq<'s>) -> u32
Hash the given sequence. Ignores k.
This is slightly inefficient because it recomputes the constants based on the sequence length.
Sourcefn hash_prefixes<'s>(
&self,
seq: impl Seq<'s>,
) -> impl ExactSizeIterator<Item = u32>
fn hash_prefixes<'s>( &self, seq: impl Seq<'s>, ) -> impl ExactSizeIterator<Item = u32>
Hash all non-empty prefixes of the given sequence. Ignores k.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.