pub struct Alignment {
pub score: i32,
pub ystart: usize,
pub xstart: usize,
pub yend: usize,
pub xend: usize,
pub ylen: usize,
pub xlen: usize,
pub operations: Vec<AlignmentOperation, Global>,
pub mode: AlignmentMode,
}
Expand description
We consider alignment between two sequences x and y. x is the query or read sequence and y is the reference or template sequence. An alignment, consisting of a score, the start and end position of the alignment on sequence x and sequence y, the lengths of sequences x and y, and the alignment edit operations. The start position and end position of the alignment does not include the clipped regions. The length of clipped regions are already encapsulated in the Alignment Operation.
Fields
score: i32
Smith-Waterman alignment score
ystart: usize
Start position of alignment in reference
xstart: usize
Start position of alignment in query
yend: usize
End position of alignment in reference
xend: usize
End position of alignment in query
ylen: usize
Length of the reference sequence
xlen: usize
Length of the query sequence
operations: Vec<AlignmentOperation, Global>
Vector of alignment operations
mode: AlignmentMode
Implementations
sourceimpl Alignment
impl Alignment
sourcepub fn cigar(&self, hard_clip: bool) -> String
pub fn cigar(&self, hard_clip: bool) -> String
Calculate the cigar string from the alignment struct. x is the target string
Example
use bio_types::alignment::{Alignment,AlignmentMode};
use bio_types::alignment::AlignmentOperation::{Match, Subst, Ins, Del};
let alignment = Alignment {
score: 5,
xstart: 3,
ystart: 0,
xend: 9,
yend: 10,
ylen: 10,
xlen: 10,
operations: vec![Match, Match, Match, Subst, Ins, Ins, Del, Del],
mode: AlignmentMode::Semiglobal
};
assert_eq!(alignment.cigar(false), "3S3=1X2I2D1S");
sourcepub fn pretty(&self, x: &[u8], y: &[u8]) -> String
pub fn pretty(&self, x: &[u8], y: &[u8]) -> String
Return the pretty formatted alignment as a String. The string contains sets of 3 lines of length 100. First line is for the sequence x, second line is for the alignment operation and the the third line is for the sequence y. A ‘-’ in the sequence indicates a blank (insertion/deletion). The operations follow the following convention: ‘|’ for a match, ‘\’ (a single backslash) for a mismatch, ‘+’ for an insertion, ‘x’ for a deletion and ’ ’ for clipping
Example
If we align the strings “CCGTCCGGCAAGGG” and “AAAAACCGTTGACGGCCAA” in various modes, we will get the following output:
Semiglobal:
CCGTCCGGCAAGGG
||||++++\\|\||
AAAAACCGT----TGACGGCCAA
Local:
CCGTCCGGCAAGGG
||||
AAAAACCGT TGACGGCCAA
Global:
-----CCGT--CCGGCAAGGG
xxxxx||||xx\||||\|++\
AAAAACCGTTGACGGCCA--A
sourcepub fn path(&self) -> Vec<(usize, usize, AlignmentOperation), Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn path(&self) -> Vec<(usize, usize, AlignmentOperation), Global>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Returns the optimal path in the alignment matrix
Example
use bio_types::alignment::{Alignment,AlignmentMode};
use bio_types::alignment::AlignmentOperation::*;
let alignment = Alignment {
score: 5,
xstart: 3,
ystart: 0,
xend: 9,
yend: 10,
ylen: 10,
xlen: 10,
operations: vec![Match, Match, Match, Subst, Ins, Ins, Del, Del],
mode: AlignmentMode::Semiglobal,
};
assert_eq!(alignment.path(),[
(4, 5, Match),
(5, 6, Match),
(6, 7, Match),
(7, 8, Subst),
(8, 8, Ins),
(9, 8, Ins),
(9, 9, Del),
(9, 10, Del)])
sourcepub fn filter_clip_operations(&mut self)
pub fn filter_clip_operations(&mut self)
Filter out Xclip and Yclip operations from the list of operations. Useful when invoking the standard modes.
Trait Implementations
impl Eq for Alignment
impl StructuralEq for Alignment
impl StructuralPartialEq for Alignment
Auto Trait Implementations
impl RefUnwindSafe for Alignment
impl Send for Alignment
impl Sync for Alignment
impl Unpin for Alignment
impl UnwindSafe for Alignment
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
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
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.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more