Skip to main content

SparseDistanceMatrix

Struct SparseDistanceMatrix 

Source
pub struct SparseDistanceMatrix<'a> {
    pub n_distances: usize,
    pub knn: usize,
    /* private fields */
}
Expand description

A sparse distance matrix with a maximum of knn distances for each sample.

In self-query mode (one database), query_names is None and ref_names is used for both row iteration and column index lookup.

In cross-query mode (two databases), query_names holds the query genome names (one per row) and ref_names holds the reference genome names (indexed by the stored neighbour index inside each distance item).

Fields§

§n_distances: usize

Total number of distances

§knn: usize

Maximum number of distances kept per sample: k smallest distances

Implementations§

Source§

impl<'a> SparseDistanceMatrix<'a>

Source

pub fn new(ref_sketches: &'a MultiSketch, knn: usize, jaccard: DistType) -> Self

Self-query constructor: one database, rows and columns are the same set.

Source

pub fn new_cross_query( ref_sketches: &'a MultiSketch, query_sketches: &'a MultiSketch, knn: usize, jaccard: DistType, ) -> Self

Cross-query constructor: two databases. Rows are query genomes; column indices index into the reference genome list.

Source

pub fn dists_as_ref(&self) -> &DistVec

Reference/borrow of underlying distance storage

Source

pub fn dists_mut(&mut self) -> &mut DistVec

Mutable reference to the underlying distance storage

Trait Implementations§

Source§

impl Display for SparseDistanceMatrix<'_>

Source§

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

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

impl<'a> Distances<'a> for SparseDistanceMatrix<'a>

Source§

fn jaccard(&self) -> &DistType

Distance type
Source§

fn n_samples(&self) -> (usize, Option<usize>)

The number of reference and query (if set) samples
Source§

fn shape(&self) -> (usize, usize)

The (rows, columns) of the underlying data (C-order/row-major)
Source§

fn ani(&self) -> bool

Whether calculating ANI
Source§

fn k_vals(&self) -> Option<(usize, f64)>

If calcualting Jaccard distances, the index of the k-mer, and the k-mer as a float
Source§

fn n_dist_cols(&self) -> usize

Number of distance columns in the output
Source§

fn sketch_names(sketches: &'a MultiSketch) -> Vec<&'a str>

Names of the sketch files in the distance matrix

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.