pub struct AntiLexHasher<const CANONICAL: bool> { /* private fields */ }Expand description
A hash function that compares strings reverse-lexicographically, with the last (most significant) character inverted.
Only supports 2-bit DNA sequences (packed_seq::AsciiSeq and packed_seq::PackedSeq).
The canonical version (with CANONICAL=true) returns the minimum of the forward and reverse-complement hashes.
TODO: Test minimum vs maximum.
Implementations§
Source§impl<const CANONICAL: bool> AntiLexHasher<CANONICAL>
impl<const CANONICAL: bool> AntiLexHasher<CANONICAL>
Sourcepub const fn new(k: usize) -> Self
pub const fn new(k: usize) -> Self
Create a new AntiLexHasher for kmers of length k.
Trait Implementations§
Source§impl KmerHasher for AntiLexHasher<false>
impl KmerHasher for AntiLexHasher<false>
Source§const CANONICAL: bool = false
const CANONICAL: bool = false
True when the hash function is invariant under reverse-complement.
fn new(k: usize) -> Self
Source§fn 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. Read moreSource§fn 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. Read moreSource§fn mapper<'s>(&self, seq: impl Seq<'s>) -> impl FnMut(u8) -> u32
fn mapper<'s>(&self, seq: impl Seq<'s>) -> impl FnMut(u8) -> u32
Hash a sequence one character at a time. Ignores
k. Read moreSource§fn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Helper function returning
Self::CANONICAL.Source§fn 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
Source§fn 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.Source§fn 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.Source§fn 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.Source§fn 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.Source§fn 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. Read moreSource§fn 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.Source§impl KmerHasher for AntiLexHasher<true>
impl KmerHasher for AntiLexHasher<true>
Source§const CANONICAL: bool = true
const CANONICAL: bool = true
True when the hash function is invariant under reverse-complement.
fn new(k: usize) -> Self
Source§fn delay(&self) -> Delay
fn delay(&self) -> Delay
The delay of the ‘out’ character passed to the
in_out_mapper functions.
Defaults to k-1.Source§fn mapper<'s>(&self, seq: impl Seq<'s>) -> impl FnMut(u8) -> u32
fn mapper<'s>(&self, seq: impl Seq<'s>) -> impl FnMut(u8) -> u32
Hash a sequence one character at a time. Ignores
k. Read moreSource§fn 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. Read moreSource§fn 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. Read moreSource§fn is_canonical(&self) -> bool
fn is_canonical(&self) -> bool
Helper function returning
Self::CANONICAL.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
Source§fn 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.Source§fn 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.Source§fn 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.Source§fn 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.Source§fn 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. Read moreSource§fn 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.Auto Trait Implementations§
impl<const CANONICAL: bool> Freeze for AntiLexHasher<CANONICAL>
impl<const CANONICAL: bool> RefUnwindSafe for AntiLexHasher<CANONICAL>
impl<const CANONICAL: bool> Send for AntiLexHasher<CANONICAL>
impl<const CANONICAL: bool> Sync for AntiLexHasher<CANONICAL>
impl<const CANONICAL: bool> Unpin for AntiLexHasher<CANONICAL>
impl<const CANONICAL: bool> UnwindSafe for AntiLexHasher<CANONICAL>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more