KmerHasher

Trait KmerHasher 

Source
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§

Source

const CANONICAL: bool

True when the hash function is invariant under reverse-complement.

Required Methods§

Source

fn new(k: usize) -> Self

Source

fn k(&self) -> usize

The value of k for this hasher.

Source

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.

Source

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.

Source

fn mapper<'s>(&self, seq: impl Seq<'s>) -> impl FnMut(u8) -> u32

Hash a sequence one character at a time. Ignores k.

seq is only used to ensure that the hasher can handle the underlying alphabet.

Provided Methods§

Source

fn is_canonical(&self) -> bool

Helper function returning Self::CANONICAL.

Source

fn delay(&self) -> Delay

The delay of the ‘out’ character passed to the in_out_mapper functions. Defaults to k-1.

Source

fn in_out_mapper_ambiguous_scalar<'s>( &self, nseq: PackedNSeq<'s>, ) -> impl FnMut((u8, u8)) -> u32

Source

fn in_out_mapper_ambiguous_simd<'s>( &self, nseq: PackedNSeq<'s>, context: usize, ) -> impl FnMut((u32x8, u32x8)) -> u32x8

Source

fn hash_kmers_scalar<'s>( &self, seq: impl Seq<'s>, ) -> impl ExactSizeIterator<Item = u32>

A scalar iterator over all k-mer hashes in seq.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Implementors§

Source§

impl KmerHasher for AntiLexHasher<false>

Source§

const CANONICAL: bool = false

Source§

impl KmerHasher for AntiLexHasher<true>

Source§

const CANONICAL: bool = true

Source§

impl<CH: CharHasher> KmerHasher for CH

Source§

const CANONICAL: bool = CH::CANONICAL