AntiLexHasher

Struct AntiLexHasher 

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

Source

pub const fn new(k: usize) -> Self

Create a new AntiLexHasher for kmers of length k.

Trait Implementations§

Source§

impl KmerHasher for AntiLexHasher<false>

Source§

const CANONICAL: bool = false

True when the hash function is invariant under reverse-complement.
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. Read more
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. Read more
Source§

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

Hash a sequence one character at a time. Ignores k. Read more
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. Read more
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.
Source§

impl KmerHasher for AntiLexHasher<true>

Source§

const CANONICAL: bool = true

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

fn new(k: usize) -> Self

Source§

fn k(&self) -> usize

The value of k for this hasher.
Source§

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

Hash a sequence one character at a time. Ignores k. Read more
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. Read more
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. Read more
Source§

fn is_canonical(&self) -> bool

Helper function returning Self::CANONICAL.
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. Read more
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.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V