pub struct Sequence(_);
Expand description

A FASTA record sequence.

Implementations§

source§

impl Sequence

source

pub fn len(&self) -> usize

Returns the length of the sequence.

Examples
use noodles_fasta::record::Sequence;
let sequence = Sequence::default();
assert_eq!(sequence.len(), 0);
source

pub fn is_empty(&self) -> bool

Returns whether the sequence is empty.

Examples
use noodles_fasta::record::Sequence;
let sequence = Sequence::default();
assert!(sequence.is_empty());
source

pub fn get<I>(&self, index: I) -> Option<&I::Output>where I: SequenceIndex<u8>,

Returns a reference to a base at or slice of bases between the given index.

Examples
use noodles_core::Position;
use noodles_fasta::record::Sequence;

let sequence = Sequence::from(b"ACGT".to_vec());

let start = Position::try_from(2)?;
assert_eq!(sequence.get(start), Some(&b'C'));

assert_eq!(sequence.get(start..), Some(&b"CGT"[..]));

let end = Position::try_from(3)?;
assert_eq!(sequence.get(start..=end), Some(&b"CG"[..]));
source

pub fn slice<I>(&self, interval: I) -> Option<Self>where I: Into<Interval>,

Returns a subset of the sequence within the given range.

Unlike Self::get, this returns the slice as a Sequence.

Examples
use noodles_core::Position;
use noodles_fasta::record::Sequence;

let sequence = Sequence::from(b"ACGT".to_vec());

let start = Position::try_from(2)?;
let end = Position::try_from(3)?;
let actual = sequence.slice(start..=end);

let expected = Sequence::from(b"CG".to_vec());

assert_eq!(actual, Some(expected));
source

pub fn complement(&self) -> Complement<'_>

Returns an iterator that complements the sequence.

Examples
Complement a sequence
use noodles_fasta::record::Sequence;
let sequence = Sequence::from(b"ACGT".to_vec());
let actual: Sequence = sequence.complement().collect::<Result<_, _>>()?;
let expected = Sequence::from(b"TGCA".to_vec());
assert_eq!(actual, expected);
Reverse complement a sequence
use noodles_fasta::record::Sequence;
let sequence = Sequence::from(b"ACGT".to_vec());
let actual: Sequence = sequence.complement().rev().collect::<Result<_, _>>()?;
let expected = sequence.clone();
assert_eq!(actual, expected);

Trait Implementations§

source§

impl AsRef<[u8]> for Sequence

source§

fn as_ref(&self) -> &[u8]

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

impl Clone for Sequence

source§

fn clone(&self) -> Sequence

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Sequence

source§

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

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

impl Default for Sequence

source§

fn default() -> Sequence

Returns the “default value” for a type. Read more
source§

impl From<Bytes> for Sequence

source§

fn from(data: Bytes) -> Self

Converts to this type from the input type.
source§

impl From<Vec<u8, Global>> for Sequence

source§

fn from(data: Vec<u8>) -> Self

Converts to this type from the input type.
source§

impl FromIterator<u8> for Sequence

source§

fn from_iter<T>(iter: T) -> Selfwhere T: IntoIterator<Item = u8>,

Creates a value from an iterator. Read more
source§

impl<I> Index<I> for Sequencewhere I: SequenceIndex<u8>,

§

type Output = <I as SequenceIndex<u8>>::Output

The returned type after indexing.
source§

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

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

impl PartialEq<Sequence> for Sequence

source§

fn eq(&self, other: &Sequence) -> 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 Eq for Sequence

source§

impl StructuralEq for Sequence

source§

impl StructuralPartialEq for Sequence

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.