Skip to main content

SeqHashBuilder

Struct SeqHashBuilder 

Source
pub struct SeqHashBuilder { /* private fields */ }
Expand description

Builder for constructing a SeqHash index with custom configuration.

§Example

use seqhash::SeqHashBuilder;

let parents: Vec<&[u8]> = vec![b"ACGTACGT", b"GGGGCCCC"];

// Build with default settings (allows 1 mismatch, allows N bases, normalizes case)
let index = SeqHashBuilder::default().build(&parents).unwrap();

// Build with exact match only (no mismatch tolerance)
let exact_only = SeqHashBuilder::default()
    .exact()
    .build(&parents)
    .unwrap();

// Build rejecting N bases in sequences
let no_n = SeqHashBuilder::default()
    .exclude_n()
    .build(&parents)
    .unwrap();

// Build preserving lowercase bases (useful when case has special meaning)
let keep_case = SeqHashBuilder::default()
    .keep_case()
    .build(&parents)
    .unwrap();

Implementations§

Source§

impl SeqHashBuilder

Source

pub fn exact(self) -> Self

Configure for exact matching only (no mismatch tolerance).

When set, the index will only match sequences that exactly match a parent. This reduces memory usage since no mutation entries are generated.

Source

pub fn exclude_n(self) -> Self

Reject N bases in sequences.

By default, sequences containing N are accepted (N positions are skipped when generating mismatch entries). When this is set, sequences containing N will be rejected with an InvalidBase error.

Source

pub fn keep_case(self) -> Self

Preserve the case of input sequences.

By default, sequences are converted to uppercase before indexing. When this is set, sequences are kept as-is, preserving lowercase bases. This is useful when lowercase bases have special meaning in your data.

Source

pub fn threads(self, num_threads: usize) -> Self

Number of threads to use when building the index.

By default, uses a single thread. Setting this to 0 will use all available threads.

Parallel construction is most beneficial for large parent sets (>100,000 sequences) or long sequences. The number of threads is automatically capped by the number of available CPU cores and the number of parent sequences.

§Example
use seqhash::SeqHashBuilder;

let parents: Vec<&[u8]> = vec![b"ACGTACGT", b"GGGGCCCC"];

// Use 4 threads
let index = SeqHashBuilder::default()
    .threads(4)
    .build(&parents)
    .unwrap();

// Use all available CPU cores
let index = SeqHashBuilder::default()
    .threads(0)
    .build(&parents)
    .unwrap();
Source

pub fn build<S: AsRef<[u8]>>( self, parents: &[S], ) -> Result<SeqHash, SeqHashError>

Build the SeqHash index from the given parent sequences.

§Errors

Returns an error if:

  • No parent sequences are provided
  • Sequences have inconsistent lengths
  • Sequence length exceeds 16383
  • Duplicate parent sequences exist
  • Sequences contain invalid bases (unless allow_n() is set for N)

Trait Implementations§

Source§

impl Clone for SeqHashBuilder

Source§

fn clone(&self) -> SeqHashBuilder

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SeqHashBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for SeqHashBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Copy for SeqHashBuilder

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.