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
sourceimpl<F: MatchFunc> Aligner<F>
impl<F: MatchFunc> Aligner<F>
sourcepub fn new(
gap_open: i32,
gap_extend: i32,
match_fn: F,
k: usize,
w: usize
) -> Self
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 bandw
- width of the band
sourcepub fn with_capacity(
m: usize,
n: usize,
gap_open: i32,
gap_extend: i32,
match_fn: F,
k: usize,
w: usize
) -> Self
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 xn
- the expected size of ygap_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 bandw
- width of the band
sourcepub fn with_capacity_and_scoring(
m: usize,
n: usize,
scoring: Scoring<F>,
k: usize,
w: usize
) -> Self
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 xn
- the expected size of yscoring
- the scoring structk
- kmer length used in constructing the bandw
- width of the band
sourcepub fn with_scoring(scoring: Scoring<F>, k: usize, w: usize) -> Self
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 xn
- the expected size of yscoring
- the scoring structk
- kmer length used in constructing the bandw
- width of the band
sourcepub fn get_mut_scoring(&mut self) -> &mut Scoring<F>
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
sourcepub fn custom_with_prehash(
&mut self,
x: TextSlice<'_>,
y: TextSlice<'_>,
y_kmer_hash: &HashMapFx<&[u8], Vec<u32>>
) -> Alignment
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
- Textslicey
- Textslice
sourcepub fn custom_with_matches(
&mut self,
x: TextSlice<'_>,
y: TextSlice<'_>,
matches: &[(u32, u32)]
) -> Alignment
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
- Textslicey
- Textslicematches
- Vector of kmer matching pairs (xpos, ypos)
sourcepub fn custom_with_expanded_matches(
&mut self,
x: TextSlice<'_>,
y: TextSlice<'_>,
matches: Vec<(u32, u32)>,
allowed_mismatches: Option<usize>,
use_lcskpp_union: bool
) -> Alignment
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
- Textslicey
- Textslicematches
- 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
sourcepub fn custom_with_match_path(
&mut self,
x: TextSlice<'_>,
y: TextSlice<'_>,
matches: &[(u32, u32)],
path: &[usize]
) -> Alignment
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
- Textslicey
- Textslicematches
- Vector of kmer matching pairs (xpos, ypos)path
- Vector of indices pointing tomatches
vector which defines a path. The validity of the path is not checked.
sourcepub fn global(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment
pub fn global(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment
Calculate global alignment of x against y.
sourcepub fn semiglobal(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment
pub fn semiglobal(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment
Calculate semiglobal alignment of x against y (x is global, y is local).
sourcepub fn semiglobal_with_prehash(
&mut self,
x: TextSlice<'_>,
y: TextSlice<'_>,
y_kmer_hash: &HashMapFx<&[u8], Vec<u32>>
) -> Alignment
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.
sourcepub fn local(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment
pub fn local(&mut self, x: TextSlice<'_>, y: TextSlice<'_>) -> Alignment
Calculate local alignment of x against y.
pub fn visualize(&self, alignment: &Alignment)
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.