Struct debruijn::dna_string::DnaString [−][src]
pub struct DnaString { /* fields omitted */ }
Expand description
A container for sequence of DNA bases.
use debruijn::dna_string::DnaString;
use debruijn::kmer::Kmer8;
use debruijn::{Mer, Vmer};
let dna_string = DnaString::from_dna_string("ATCGTACGTACGTAGTC");
// Iterate over 8-mers
for k in dna_string.iter_kmers::<Kmer8>() {
println!("{:?}", k);
}
// Get a base, encoded as a byte in 0-3 range
assert_eq!(dna_string.get(0), 0);
assert_eq!(dna_string.get(1), 3);
// Make a read-only 'slice' of a DnaString
let slc = dna_string.slice(1, 10);
assert_eq!(slc.iter_kmers::<Kmer8>().next(), dna_string.iter_kmers::<Kmer8>().skip(1).next());
Implementations
Create a new instance with a given capacity.
Create a DnaString corresponding to an ACGT-encoded str.
Create a DnaString corresponding to an ACGT-encoded str.
Create a DnaString from an ASCII ACGT-encoded byte slice. Non ACGT positions will be converted to ‘A’
Create a DnaString from an ACGT-encoded byte slice, Non ACGT positions will be converted to repeatable random base determined by a hash of the read name and the position within the string.
Convert sequence to a Vector of ascii-encoded bytes
Push 0-4 encoded bases from a byte array.
Arguments
bytes
: byte array to read values from
seq_length
: how many values to read from the byte array. Note that this
is number of values not number of elements of the byte array.
pub fn iter(&self) -> DnaStringIter<'_>ⓘNotable traits for DnaStringIter<'a>impl<'a> Iterator for DnaStringIter<'a> type Item = u8;
pub fn iter(&self) -> DnaStringIter<'_>ⓘNotable traits for DnaStringIter<'a>impl<'a> Iterator for DnaStringIter<'a> type Item = u8;
impl<'a> Iterator for DnaStringIter<'a> type Item = u8;
Iterate over stored values (values will be unpacked into bytes).
Get the length k
prefix of the DnaString
Get the length k
suffix of the DnaString
Get slice containing the interval [start
, end
) of self
Compute Hamming distance between this DnaString and another DnaString. The two strings must have the same length.
Trait Implementations
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
type IntoIter = DnaStringIter<'a>
type IntoIter = DnaStringIter<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> DnaStringIter<'a>ⓘNotable traits for DnaStringIter<'a>impl<'a> Iterator for DnaStringIter<'a> type Item = u8;
fn into_iter(self) -> DnaStringIter<'a>ⓘNotable traits for DnaStringIter<'a>impl<'a> Iterator for DnaStringIter<'a> type Item = u8;
impl<'a> Iterator for DnaStringIter<'a> type Item = u8;
Creates an iterator from a value. Read more
Set nbases
positions in the sequence, starting at pos
.
Values must be packed into the upper-most bits of value
. Read more
Iterate over the bases in the sequence
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Create a Vmer from a sequence of bytes
Get the first Kmer from the sequence
Get the terminal kmer of the sequence, on the both side of the sequence
Get the terminal kmer of the sequence, on the side of the sequence given by dir
Iterate over the kmers in the sequence
fn iter_kmer_exts<K: Kmer>(&self, seq_exts: Exts) -> KmerExtsIter<'_, K, Self>ⓘNotable traits for KmerExtsIter<'a, K, D>impl<'a, K: Kmer, D: Mer> Iterator for KmerExtsIter<'a, K, D> type Item = (K, Exts);
fn iter_kmer_exts<K: Kmer>(&self, seq_exts: Exts) -> KmerExtsIter<'_, K, Self>ⓘNotable traits for KmerExtsIter<'a, K, D>impl<'a, K: Kmer, D: Mer> Iterator for KmerExtsIter<'a, K, D> type Item = (K, Exts);
impl<'a, K: Kmer, D: Mer> Iterator for KmerExtsIter<'a, K, D> type Item = (K, Exts);
Iterate over the kmers and their extensions, given the extensions of the whole sequence
Auto Trait Implementations
impl RefUnwindSafe for DnaString
impl UnwindSafe for DnaString
Blanket Implementations
Mutably borrows from an owned value. Read more