pub struct Sequence(_);
Expand description

A FASTA record sequence.

Implementations

Returns the length of the sequence.

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

Returns whether the sequence is empty.

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

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"[..]));

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));

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

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

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Converts to this type from the input type.

Converts to this type from the input type.

Creates a value from an iterator. Read more

The returned type after indexing.

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

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.

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

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.