Skip to main content

FracMinHash

Struct FracMinHash 

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

Scaled (FracMinHash) sketch for rapid genome comparison.

Keeps all canonical k-mer hash values below u64::MAX / scale. This gives a predictable sampling fraction regardless of genome size, making containment estimation more accurate for genomes of different sizes.

Implementations§

Source§

impl FracMinHash

Source

pub fn new(k: usize, scale: u64) -> Result<Self>

Create a new empty FracMinHash sketch.

§Errors

Returns an error if k == 0 or scale == 0.

Source

pub fn from_sequence(seq: &[u8], k: usize, scale: u64) -> Result<Self>

Build a FracMinHash sketch from a DNA sequence.

§Errors

Returns an error if k == 0 or scale == 0.

Source

pub fn add_sequence(&mut self, seq: &[u8])

Add k-mers from a DNA sequence to this sketch.

Non-ACGT bases act as k-mer break points.

Source

pub fn jaccard(&self, other: &FracMinHash) -> Result<f64>

Estimate Jaccard similarity between this sketch and another.

Jaccard = |A intersect B| / |A union B|, computed exactly over the hashes below the shared threshold.

§Errors

Returns an error if the sketches have different k or scale values.

Source

pub fn containment(&self, other: &FracMinHash) -> Result<f64>

Estimate containment of self in other.

Containment C(A, B) = |A intersect B| / |A|.

§Errors

Returns an error if the sketches have different k or scale values.

Source

pub fn ani(&self, other: &FracMinHash) -> Result<f64>

Estimate average nucleotide identity (ANI) from Jaccard similarity.

§Errors

Returns an error if the sketches are incompatible or Jaccard is zero.

Source

pub fn len(&self) -> usize

Number of hash values in the sketch.

Source

pub fn is_empty(&self) -> bool

Whether the sketch is empty.

Source

pub fn k(&self) -> usize

The k-mer size used by this sketch.

Source

pub fn scale(&self) -> u64

The scale factor.

Source

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

Return a reference to the sorted hash values.

Trait Implementations§

Source§

impl Clone for FracMinHash

Source§

fn clone(&self) -> FracMinHash

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 FracMinHash

Source§

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

Formats the value using the given formatter. Read more

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> Same for T

Source§

type Output = T

Should always be Self
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.