pub struct Aligner<F: MatchFunc> { /* private fields */ }
Expand description

A banded implementation of Smith-Waterman aligner (SWA). Unlike the full SWA, this implementation computes the alignment between a pair of sequences only inside a ‘band’ withing the dynamic programming matrix. The band is constructed using the Sparse DP routine (see sparse::sdpkpp), which uses kmer matches to build the best common subsequence (including gap penalties) between the two strings. The band is constructed around this subsequence (using the window length ‘w’), filling in the gaps.

In the case where there are no k-mer matches, the aligner will fall back to a full alignment, by setting the band to contain the full matrix.

Banded aligner will proceed to compute the alignment only when the total number of cells in the band is less than MAX_CELLS (currently set to 10 million), otherwise it returns an empty alignment

Implementations§

source§

impl<F: MatchFunc> Aligner<F>

source

pub fn new( gap_open: i32, gap_extend: i32, match_fn: F, k: usize, w: usize ) -> Self

Create new aligner instance with given gap open and gap extend penalties and the score function.

Arguments
  • gap_open - the score for opening a gap (should be negative)
  • gap_extend - the score for extending a gap (should be negative)
  • match_fn - function that returns the score for substitutions (also see bio::scores)
  • k - kmer length used in constructing the band
  • w - width of the band
source

pub fn with_capacity( m: usize, n: usize, gap_open: i32, gap_extend: i32, match_fn: F, k: usize, w: usize ) -> Self

Create new aligner instance. The size hints help to avoid unnecessary memory allocations.

Arguments
  • m - the expected size of x
  • n - the expected size of y
  • gap_open - the score for opening a gap (should be negative)
  • gap_extend - the score for extending a gap (should be negative)
  • match_fn - function that returns the score for substitutions (also see bio::scores)
  • k - kmer length used in constructing the band
  • w - width of the band
source

pub fn with_capacity_and_scoring( m: usize, n: usize, scoring: Scoring<F>, k: usize, w: usize ) -> Self

Create new aligner instance with scoring and size hint. The size hints help to avoid unnecessary memory allocations.

Arguments
  • m - the expected size of x
  • n - the expected size of y
  • scoring - the scoring struct
  • k - kmer length used in constructing the band
  • w - width of the band
source

pub fn with_scoring(scoring: Scoring<F>, k: usize, w: usize) -> Self

Create new aligner instance with scoring and size hint. The size hints help to avoid unnecessary memory allocations.

Arguments
  • m - the expected size of x
  • n - the expected size of y
  • scoring - the scoring struct
  • k - kmer length used in constructing the band
  • w - width of the band
source

pub fn get_mut_scoring(&mut self) -> &mut Scoring<F>

Return a mutable reference to scoring. Useful if you want to have a single aligner object but want to modify the scores within it for different cases

source

pub fn custom(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment

Compute the alignment with custom clip penalties

Arguments
  • x - Textslice
  • y - Textslice
source

pub fn custom_with_prehash( &mut self, x: TextSlice<'_>, y: TextSlice<'_>, y_kmer_hash: &HashMapFx<&[u8], Vec<u32>> ) -> Alignment

Compute the alignment with custom clip penalties with ‘y’ being pre-hashed (see sparse::hash_kmers)

Arguments
  • x - Textslice
  • y - Textslice
source

pub fn custom_with_matches( &mut self, x: TextSlice<'_>, y: TextSlice<'_>, matches: &[(u32, u32)] ) -> Alignment

Compute the alignment with custom clip penalties with the kmer matches between x and y being pre-computed as a Vector of pairs (xpos, ypos) and sorted.

Arguments
  • x - Textslice
  • y - Textslice
  • matches - Vector of kmer matching pairs (xpos, ypos)
source

pub fn custom_with_expanded_matches( &mut self, x: TextSlice<'_>, y: TextSlice<'_>, matches: Vec<(u32, u32)>, allowed_mismatches: Option<usize>, use_lcskpp_union: bool ) -> Alignment

Compute the alignment with custom clip penalties with the kmer matches between x and y being pre-computed as a Vector of pairs (xpos, ypos) and sorted. The matches are expanded diagonally in both directions allowing upto a user specified number of mismatches. This is useful in constructing the band correctly, particularly when a higher frequency of mismatches are expected.

Arguments
  • x - Textslice
  • y - Textslice
  • matches - Vector of kmer matching pairs (xpos, ypos)
  • allowed_mismatches - Extend the matches diagonally allowing upto the specified number of mismatches (Option)
  • use_lcskpp_union - Extend the results from sdpkpp using lcskpp
source

pub fn custom_with_match_path( &mut self, x: TextSlice<'_>, y: TextSlice<'_>, matches: &[(u32, u32)], path: &[usize] ) -> Alignment

Compute the alignment with custom clip penalties by constructing a band along the matches as defined by path. This is only for advanced uses, where one would want to control the kmer backbone that is used for creating the band.

Arguments
  • x - Textslice
  • y - Textslice
  • matches - Vector of kmer matching pairs (xpos, ypos)
  • path - Vector of indices pointing to matches vector which defines a path. The validity of the path is not checked.
source

pub fn global(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment

Calculate global alignment of x against y.

source

pub fn semiglobal(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment

Calculate semiglobal alignment of x against y (x is global, y is local).

source

pub fn semiglobal_with_prehash( &mut self, x: TextSlice<'_>, y: TextSlice<'_>, y_kmer_hash: &HashMapFx<&[u8], Vec<u32>> ) -> Alignment

Calculate semiglobal alignment of x against y (x is global, y is local). This function accepts the hash map of the kmers of y. This is useful in cases where we are interested in repeated alignment of different queries against the same reference. The user can precompute the HashMap using sparse::hash_kmers and invoke this function to speed up the alignment computation.

source

pub fn local(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment

Calculate local alignment of x against y.

source

pub fn visualize(&self, alignment: &Alignment)

Trait Implementations§

source§

impl<F: Clone + MatchFunc> Clone for Aligner<F>

source§

fn clone(&self) -> Aligner<F>

Returns a copy 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<F: Debug + MatchFunc> Debug for Aligner<F>

source§

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

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

impl<F: Default + MatchFunc> Default for Aligner<F>

source§

fn default() -> Aligner<F>

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

impl<'de, F> Deserialize<'de> for Aligner<F>where F: Deserialize<'de> + MatchFunc,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<F: Hash + MatchFunc> Hash for Aligner<F>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<F: PartialEq + MatchFunc> PartialEq<Aligner<F>> for Aligner<F>

source§

fn eq(&self, other: &Aligner<F>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F> Serialize for Aligner<F>where F: Serialize + MatchFunc,

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl<F: Eq + MatchFunc> Eq for Aligner<F>

source§

impl<F: MatchFunc> StructuralEq for Aligner<F>

source§

impl<F: MatchFunc> StructuralPartialEq for Aligner<F>

Auto Trait Implementations§

§

impl<F> RefUnwindSafe for Aligner<F>where F: RefUnwindSafe,

§

impl<F> Send for Aligner<F>where F: Send,

§

impl<F> Sync for Aligner<F>where F: Sync,

§

impl<F> Unpin for Aligner<F>where F: Unpin,

§

impl<F> UnwindSafe for Aligner<F>where F: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere 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<T> for T

§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SPwhere SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.
§

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

§

fn vzip(self) -> V

source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,

source§

impl<T> Scalar for Twhere T: 'static + Clone + PartialEq<T> + Debug,