[−][src]Struct multi_seq_align::Alignment
An alignment of DNA or amino acids sequences
Aligned sequences should all have the same length. Each sequence is stored as one vector of char
s. This allows an easy access to columns and rows of the alignment.
Implementations
impl<T> Alignment<T>
[src]
#[must_use]pub const fn length(&self) -> &usize
[src]
Returns the fixed length
of the Alignment self
#[must_use]pub const fn n_sequences(&self) -> &usize
[src]
Returns the number of sequences contained in self
pub fn iter_positions(
&self
) -> impl Iterator<Item = Vec<&T>> + ExactSizeIterator<Item = Vec<&T>> where
T: Clone,
[src]
&self
) -> impl Iterator<Item = Vec<&T>> + ExactSizeIterator<Item = Vec<&T>> where
T: Clone,
Returns an Iterator over the positions of the alignment
Examples
let align = Alignment::with_sequences( &[ b"AVEQTPRK".to_vec(), b"SVEQTPRK".to_vec(), b"SVEQTPKK".to_vec(), ], ) .unwrap(); for position in align.iter_positions() { assert_eq!(position.len(), 3) }
pub fn iter_sequences(
&self
) -> impl Iterator<Item = Vec<&T>> + ExactSizeIterator<Item = Vec<&T>> where
T: Clone,
[src]
&self
) -> impl Iterator<Item = Vec<&T>> + ExactSizeIterator<Item = Vec<&T>> where
T: Clone,
Returns an Iterator over the sequences of the alignment
Examples
let align = Alignment::with_sequences( &[ b"AVEQTPRK".to_vec(), b"SVEQTPRK".to_vec(), b"SVEQTPKK".to_vec(), ], ) .unwrap(); for sequence in align.iter_sequences() { assert_eq!(sequence.len(), 8) }
#[must_use]pub const fn new(length: usize) -> Self
[src]
Returns an empty Alignment
of fixed length
Examples
let alignment = Alignment::<char>::new(42); assert_eq!(*alignment.length(), 42 as usize); assert_eq!(*alignment.n_sequences(), 0 as usize);
#[must_use]pub const fn is_empty(&self) -> bool
[src]
Returns true
if self
doesn't contains any sequence
Examples
let alignment = Alignment::<char>::new(42); assert!(alignment.is_empty())
pub fn with_sequences(sequences: &[Vec<T>]) -> Result<Self, MultiSeqAlignError> where
T: Clone,
[src]
T: Clone,
Create an Alignment
from same length vectors of names, descriptions, sequences
Examples
let align = Alignment::with_sequences( &[ b"AVEQTPRK".to_vec(), b"SVEQTPRK".to_vec(), b"SVEQTPKK".to_vec(), ], ) .unwrap(); assert_eq!(*align.length(), 8); assert_eq!(*align.n_sequences(), 3);
Errors
Will return an error if names
, descriptions
and sequences
have different lengths, and also if the sequences have different lengths (based on the first sequence).
pub fn add<'a>(
&'a mut self,
sequence: Vec<T>
) -> Result<&'a mut Self, MultiSeqAlignError>
[src]
&'a mut self,
sequence: Vec<T>
) -> Result<&'a mut Self, MultiSeqAlignError>
Add a sequence to self
The new sequence must have the same length than self.length
.
Examples
let mut align = Alignment::new(8); assert_eq!(*align.n_sequences(), 0); align .add(b"AVEQTPRK".to_vec()) .unwrap(); assert_eq!(*align.n_sequences(), 1); align .add(b"SVEQTPRK".to_vec()) .unwrap(); assert_eq!(*align.n_sequences(), 2);
Errors
Will return an error if the length of sequence
is different from the one of the alignment.
#[must_use]pub fn nth_position(&self, n: usize) -> Option<Vec<&T>>
[src]
Returns all amino acids / bases at a position
in the alignment self
. The returned vector has a length equal of number of sequences in self
.
Examples
let align = Alignment::<u8>::with_sequences( &[b"ELK".to_vec(), b"ILK".to_vec()], ) .unwrap(); assert_eq!(align.nth_position(0).unwrap(), &[&b'E', &b'I']);
Panics
Panics if n
is greater or equal to the length
of the Alignment.
#[must_use]pub fn nth_sequence(&self, index: usize) -> Option<Vec<&T>>
[src]
Returns all amino acids / bases of the sequence at the index
of the Alignment self
. The returned vector has a length equal to the length of the Alignment self
.
Examples
let align = Alignment::<u8>::with_sequences( &[b"ELK".to_vec(), b"ILK".to_vec()], ) .unwrap(); assert_eq!(align.nth_sequence(1).unwrap(), &[&b'I', &b'L', &b'K']);
Panics
Panics if index
is greater or equal to the n_sequences
of the Alignment.
Trait Implementations
impl<T: Clone> Clone for Alignment<T>
[src]
impl<T: Debug> Debug for Alignment<T>
[src]
impl<T> Default for Alignment<T> where
T: Clone,
[src]
T: Clone,
impl<T: Eq> Eq for Alignment<T>
[src]
impl<A> FromIterator<Vec<A>> for Alignment<A> where
A: Clone,
[src]
A: Clone,
fn from_iter<I: IntoIterator<Item = Vec<A>>>(iter: I) -> Self
[src]
Panics
Panics if sequences are of different lengths
impl<T: Hash> Hash for Alignment<T>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord> Ord for Alignment<T>
[src]
fn cmp(&self, other: &Alignment<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<Alignment<T>> for Alignment<T>
[src]
impl<T: PartialOrd> PartialOrd<Alignment<T>> for Alignment<T>
[src]
fn partial_cmp(&self, other: &Alignment<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Alignment<T>) -> bool
[src]
fn le(&self, other: &Alignment<T>) -> bool
[src]
fn gt(&self, other: &Alignment<T>) -> bool
[src]
fn ge(&self, other: &Alignment<T>) -> bool
[src]
impl<T> StructuralEq for Alignment<T>
[src]
impl<T> StructuralPartialEq for Alignment<T>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Alignment<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Alignment<T> where
T: Send,
T: Send,
impl<T> Sync for Alignment<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Alignment<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Alignment<T> where
T: UnwindSafe,
T: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,