NtHash

Struct NtHash 

Source
pub struct NtHash<'a> { /* private fields */ }
Expand description

Rolling k‑mer hasher over a contiguous DNA sequence.

  • Initialization is deferred until the first valid k‑mer (skips any windows containing N).
  • roll() / roll_back() advance by one base, handling skips transparently.
  • Each valid k‑mer emits num_hashes values: the canonical hash plus extra mixes.

Implementations§

Source§

impl<'a> NtHash<'a>

Source

pub fn new(seq: &'a [u8], k: u16, num_hashes: u8, pos: usize) -> Result<Self>

Create a new NtHash starting at pos.

§Arguments
  • seq – full DNA sequence (A,C,G,T,N recognized; others treated as N)
  • k – k‑mer length (> 0)
  • num_hashes – how many hash values per k‑mer
  • pos – starting index
§Errors

Returns if k == 0, seq.len() < k, or pos too large.

Source

pub fn roll(&mut self) -> bool

Advance forward by one base, skipping over k‑mers with N. Returns true if a new valid hash was produced.

Source

pub fn roll_back(&mut self) -> bool

Move backward by one base, skipping over k‑mers with N.

Source

pub fn peek(&mut self) -> bool

Peek the next k‑mer without mutating self.

Source

pub fn peek_char(&mut self, incoming: u8) -> bool

Peek with an explicit incoming byte.

Source

pub fn peek_back(&mut self) -> bool

Peek the previous k‑mer without mutating self.

Source

pub fn peek_back_char(&mut self, incoming: u8) -> bool

Peek backward with explicit incoming byte.

Source

pub fn hashes(&self) -> &[u64]

Returns the most recent hash buffer.

Source

pub fn pos(&self) -> usize

Returns the current k‑mer start index.

Source

pub fn forward_hash(&self) -> u64

Returns the forward‑strand hash.

Source

pub fn reverse_hash(&self) -> u64

Returns the reverse‑complement hash.

Auto Trait Implementations§

§

impl<'a> Freeze for NtHash<'a>

§

impl<'a> RefUnwindSafe for NtHash<'a>

§

impl<'a> Send for NtHash<'a>

§

impl<'a> Sync for NtHash<'a>

§

impl<'a> Unpin for NtHash<'a>

§

impl<'a> UnwindSafe for NtHash<'a>

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.