Struct bio_seq::seq::SeqSlice

source ·
pub struct SeqSlice<A: Codec> { /* private fields */ }
Expand description

A lightweight, read-only window into part of a sequence

Implementations§

source§

impl<'a, A: Codec> SeqSlice<A>

source

pub fn chain( self: &'a SeqSlice<A>, second: &'a SeqSlice<A> ) -> Chain<SeqIter<'a, A>, SeqIter<'a, A>>

source§

impl<A: Codec> SeqSlice<A>

source

pub fn kmers<const K: usize>(&self) -> KmerIter<'_, A, K>

Iterate over sliding windows of size K

source

pub fn rev(&self) -> RevIter<'_, A>

Iterate over the sequence in reverse order

source

pub fn windows(&self, width: usize) -> SeqChunks<'_, A>

Iterate over the sequence in overlapping windows of a specified width

This will panic if the length of the window is greater than the length of the sequence.

Example:

use bio_seq::prelude::*;

let seq: Seq<Dna> = "ACTGATCG".try_into().unwrap();
let windows: Vec<Seq<Dna>> = seq.windows(3).collect();
assert_eq!(windows, vec!["ACT", "CTG", "TGA", "GAT", "ATC", "TCG"]);
source

pub fn chunks(&self, width: usize) -> SeqChunks<'_, A>

Iterate over the sequence in non-overlapping chunks of a specified width

The last incomplete chunk will be excluded if the sequence length is not divisible by the specified width.

Example:

use bio_seq::prelude::*;

let seq: Seq<Dna> = "ACTGATCG".try_into().unwrap();
let chunks: Vec<Seq<Dna>> = seq.chunks(3).collect();
assert_eq!(chunks, vec!["ACT", "GAT"]);
source§

impl<A: Codec> SeqSlice<A>

source

pub fn nth(&self, i: usize) -> A

source

pub fn len(&self) -> usize

source

pub fn is_empty(&self) -> bool

source

pub fn contains(&self, _other: &SeqSlice<A>) -> bool

source

pub fn bit_and(&self, rhs: &SeqSlice<A>) -> Seq<A>

source

pub fn bit_or(&self, rhs: &SeqSlice<A>) -> Seq<A>

Trait Implementations§

source§

impl<A: Codec> AsRef<SeqSlice<A>> for Seq<A>

A Seq can be borrowed as a SeqSlice through generic constraints.

use bio_seq::prelude::*;

fn count_bases<S: AsRef<SeqSlice<Dna>>>(s: S) -> usize {
   s.as_ref().len()
}

let seq: Seq<Dna> = dna!("CATCGATCGATC");
let count = count_bases(seq); // the AsRef implementation allows us to directly pass a Seq
assert_eq!(count, 12);
source§

fn as_ref(&self) -> &SeqSlice<A>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl BitAnd for &SeqSlice<Iupac>

§

type Output = Seq<Iupac>

The resulting type after applying the & operator.
source§

fn bitand(self, rhs: Self) -> Self::Output

Performs the & operation. Read more
source§

impl BitOr for &SeqSlice<Iupac>

§

type Output = Seq<Iupac>

The resulting type after applying the | operator.
source§

fn bitor(self, rhs: Self) -> Self::Output

Performs the | operation. Read more
source§

impl<A: Codec> Borrow<SeqSlice<A>> for Seq<A>

Borrow a Seq<A> as a SeqSlice<A>.

The Borrow trait to is used to obtain a reference to a SeqSlice from a Seq, allowing it to be used wherever a SeqSlice is expected.

use bio_seq::prelude::*;
use std::borrow::Borrow;

let seq: Seq<Dna> = dna!("CTACGTACGATCATCG");
let slice: &SeqSlice<Dna> = seq.borrow();
source§

fn borrow(&self) -> &SeqSlice<A>

Immutably borrows from an owned value. Read more
source§

impl<A: Debug + Codec> Debug for SeqSlice<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A: Codec> Display for SeqSlice<A>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<A: Codec, const K: usize> From<&SeqSlice<A>> for Kmer<A, K>

source§

fn from(slice: &SeqSlice<A>) -> Self

Converts to this type from the input type.
source§

impl<A: Codec> From<&SeqSlice<A>> for Seq<A>

source§

fn from(slice: &SeqSlice<A>) -> Self

Converts to this type from the input type.
source§

impl<A: Codec> From<&SeqSlice<A>> for String

source§

fn from(seq: &SeqSlice<A>) -> Self

Converts to this type from the input type.
source§

impl<A: Codec> From<&SeqSlice<A>> for u8

source§

fn from(slice: &SeqSlice<A>) -> u8

Converts to this type from the input type.
source§

impl<A: Codec> From<&SeqSlice<A>> for usize

source§

fn from(slice: &SeqSlice<A>) -> usize

Converts to this type from the input type.
source§

impl<'a, A: Codec> FromIterator<&'a SeqSlice<A>> for Vec<Seq<A>>

source§

fn from_iter<T: IntoIterator<Item = &'a SeqSlice<A>>>(iter: T) -> Self

Creates a value from an iterator. Read more
source§

impl<A: Codec> Hash for SeqSlice<A>

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
source§

impl<A: Codec> Index<Range<usize>> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, range: Range<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<A: Codec> Index<RangeFrom<usize>> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, range: RangeFrom<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<A: Codec> Index<RangeFull> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, _range: RangeFull) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<A: Codec> Index<RangeInclusive<usize>> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, range: RangeInclusive<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<A: Codec> Index<RangeTo<usize>> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, range: RangeTo<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<A: Codec> Index<RangeToInclusive<usize>> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, range: RangeToInclusive<usize>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<A: Codec> Index<usize> for SeqSlice<A>

§

type Output = SeqSlice<A>

The returned type after indexing.
source§

fn index(&self, i: usize) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
source§

impl<'a, A: Codec> IntoIterator for &'a SeqSlice<A>

§

type Item = A

The type of the elements being iterated over.
§

type IntoIter = SeqIter<'a, A>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
source§

impl<A: Ord + Codec> Ord for SeqSlice<A>

source§

fn cmp(&self, other: &SeqSlice<A>) -> Ordering

This method returns an Ordering between self and other. Read more
source§

impl<A: Codec> PartialEq<&Seq<A>> for SeqSlice<A>

source§

fn eq(&self, other: &&Seq<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq<&SeqSlice<A>> for Seq<A>

source§

fn eq(&self, other: &&SeqSlice<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq<&SeqSlice<A>> for SeqSlice<A>

source§

fn eq(&self, other: &&SeqSlice<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq<Seq<A>> for &SeqSlice<A>

source§

fn eq(&self, other: &Seq<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq<Seq<A>> for SeqSlice<A>

source§

fn eq(&self, other: &Seq<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq<SeqSlice<A>> for &SeqSlice<A>

source§

fn eq(&self, other: &SeqSlice<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq<SeqSlice<A>> for Seq<A>

source§

fn eq(&self, other: &SeqSlice<A>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: Codec> PartialEq for SeqSlice<A>

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<A: PartialOrd + Codec> PartialOrd for SeqSlice<A>

source§

fn partial_cmp(&self, other: &SeqSlice<A>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<A: Codec + Complement> ReverseComplement for SeqSlice<A>

§

type Output = Seq<A>

source§

fn revcomp(&self) -> Seq<A>

Reverse complement of a sequence
source§

impl<A: Codec> ToOwned for SeqSlice<A>

Clone a borrowed slice of a sequence into an owned version.

use bio_seq::prelude::*;

let seq = dna!("CATCGATCGATCG");
let slice = &seq[2..7]; // TCGAT
let owned = slice.to_owned();

assert_eq!(&owned, &seq[2..7]);
§

type Owned = Seq<A>

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> Self::Owned

Creates owned data from borrowed data, usually by cloning. Read more
1.63.0 · source§

fn clone_into(&self, target: &mut Self::Owned)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<A: Eq + Codec> Eq for SeqSlice<A>

Auto Trait Implementations§

§

impl<A> Freeze for SeqSlice<A>

§

impl<A> RefUnwindSafe for SeqSlice<A>
where A: RefUnwindSafe,

§

impl<A> Send for SeqSlice<A>
where A: Send,

§

impl<A> !Sized for SeqSlice<A>

§

impl<A> Sync for SeqSlice<A>
where A: Sync,

§

impl<A> Unpin for SeqSlice<A>
where A: Unpin,

§

impl<A> UnwindSafe for SeqSlice<A>
where A: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Pipe for T
where T: ?Sized,

source§

fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
where Self: Sized,

Pipes by value. This is generally the method you want to use. Read more
source§

fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R
where R: 'a,

Borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R
where R: 'a,

Mutably borrows self and passes that borrow into the pipe function. Read more
source§

fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
where Self: Borrow<B>, B: 'a + ?Sized, R: 'a,

Borrows self, then passes self.borrow() into the pipe function. Read more
source§

fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R ) -> R
where Self: BorrowMut<B>, B: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
source§

fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
where Self: AsRef<U>, U: 'a + ?Sized, R: 'a,

Borrows self, then passes self.as_ref() into the pipe function.
source§

fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
where Self: AsMut<U>, U: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.as_mut() into the pipe function.
source§

fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
where Self: Deref<Target = T>, T: 'a + ?Sized, R: 'a,

Borrows self, then passes self.deref() into the pipe function.
source§

fn pipe_deref_mut<'a, T, R>( &'a mut self, func: impl FnOnce(&'a mut T) -> R ) -> R
where Self: DerefMut<Target = T> + Deref, T: 'a + ?Sized, R: 'a,

Mutably borrows self, then passes self.deref_mut() into the pipe function.
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more