SeqVec

Trait SeqVec 

Source
pub trait SeqVec:
    Default
    + Sync
    + SerializeInner
    + DeserializeInner
    + MemSize
    + MemDbg
    + Clone
    + 'static {
    type Seq<'s>: Seq<'s>;

Show 14 methods // Required methods fn as_slice(&self) -> Self::Seq<'_>; fn len(&self) -> usize; fn is_empty(&self) -> bool; fn clear(&mut self); fn into_raw(self) -> Vec<u8> ; fn random(n: usize) -> Self; fn push_seq(&mut self, seq: Self::Seq<'_>) -> Range<usize>; fn push_ascii(&mut self, seq: &[u8]) -> Range<usize>; // Provided methods fn slice(&self, range: Range<usize>) -> Self::Seq<'_> { ... } fn read_kmer(&self, k: usize, pos: usize) -> u64 { ... } fn read_revcomp_kmer(&self, k: usize, pos: usize) -> u64 { ... } fn read_kmer_u128(&self, k: usize, pos: usize) -> u128 { ... } fn read_revcomp_kmer_u128(&self, k: usize, pos: usize) -> u128 { ... } fn from_ascii(seq: &[u8]) -> Self { ... }
}
Expand description

An owned sequence. Can be constructed from either ASCII input or the underlying non-owning Seq type.

Implemented for:

  • A Vec<u8> of ASCII characters, returning 8-bit values.
  • An AsciiSeqVec of DNA characters ACGT, interpreted as 2-bit values.
  • A PackedSeqVec of packed DNA characters (4 per byte), returning 2-bit values.

Required Associated Types§

Source

type Seq<'s>: Seq<'s>

Required Methods§

Source

fn as_slice(&self) -> Self::Seq<'_>

Get a non-owning slice to the underlying sequence.

Unfortunately, Deref into a Seq can not be supported.

Source

fn len(&self) -> usize

The length of the sequence in characters.

Source

fn is_empty(&self) -> bool

Returns true if the sequence is empty.

Source

fn clear(&mut self)

Empty the sequence.

Source

fn into_raw(self) -> Vec<u8>

Convert into the underlying raw representation.

Source

fn random(n: usize) -> Self

Generate a random sequence with the given number of characters.

Source

fn push_seq(&mut self, seq: Self::Seq<'_>) -> Range<usize>

Append the given sequence to the underlying storage.

This may leave gaps (padding) between consecutively pushed sequences to avoid re-aligning the pushed data. Returns the range of indices corresponding to the pushed sequence. Use self.slice(range) to get the corresponding slice.

Source

fn push_ascii(&mut self, seq: &[u8]) -> Range<usize>

Append the given ASCII sequence to the underlying storage.

This may leave gaps (padding) between consecutively pushed sequences to avoid re-aligning the pushed data. Returns the range of indices corresponding to the pushed sequence. Use self.slice(range) to get the corresponding slice.

Provided Methods§

Source

fn slice(&self, range: Range<usize>) -> Self::Seq<'_>

Get a sub-slice of the sequence. Indices are character offsets.

Source

fn read_kmer(&self, k: usize, pos: usize) -> u64

Extract a k-mer from this sequence.

Source

fn read_revcomp_kmer(&self, k: usize, pos: usize) -> u64

Extract a k-mer from this sequence.

Source

fn read_kmer_u128(&self, k: usize, pos: usize) -> u128

Extract a k-mer from this sequence.

Source

fn read_revcomp_kmer_u128(&self, k: usize, pos: usize) -> u128

Extract a k-mer from this sequence.

Source

fn from_ascii(seq: &[u8]) -> Self

Create a SeqVec from ASCII input.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SeqVec for Vec<u8>

Source§

fn into_raw(self) -> Vec<u8>

Get the underlying ASCII text.

Source§

type Seq<'s> = &'s [u8]

Source§

fn as_slice(&self) -> Self::Seq<'_>

Source§

fn len(&self) -> usize

Source§

fn is_empty(&self) -> bool

Source§

fn clear(&mut self)

Source§

fn push_seq(&mut self, seq: &[u8]) -> Range<usize>

Source§

fn push_ascii(&mut self, seq: &[u8]) -> Range<usize>

Source§

fn random(n: usize) -> Self

Implementors§