Skip to main content

FastaReader

Struct FastaReader 

Source
pub struct FastaReader<R> { /* private fields */ }
Expand description

Slab-style streaming FASTA reader over any Read input.

The reader accepts ordinary multiline FASTA. Header lines must begin with >, sequence lines are concatenated without newline bytes, and blank lines before the first record or between records are ignored.

Implementations§

Source§

impl<R: Read> FastaReader<R>

Source

pub fn new(reader: R) -> Self

Create a reader with FastaConfig::default.

Source

pub fn with_config(reader: R, config: FastaConfig) -> Self

Create a reader with explicit configuration.

Source

pub fn into_inner(self) -> R

Return the wrapped reader.

Source

pub fn next_batch(&mut self) -> Result<Option<FastaBatch<'_>>>

Read the next batch of FASTA records.

Returns Ok(None) at EOF. A malformed non-empty line before the first header is reported as a format error.

Source

pub fn next_owned_batch(&mut self) -> Result<Option<OwnedFastaBatch>>

Read the next FASTA batch into an owned transferable buffer.

Source

pub fn visit_records<F>(&mut self, visit: F) -> Result<()>
where F: FnMut(FastaVisitRecord<'_>) -> Result<()>,

Visit every FASTA record in the stream.

This is a convenience path for single-pass consumers. It avoids the batch record and identifier side tables used by next_batch.

Source

pub fn visit_records_with_sink<S>(&mut self, sink: &mut S) -> Result<()>
where S: FastaRecordSink,

Visit every FASTA record using a sink implementation.

Source

pub fn stats(&mut self) -> Result<FastaStats>

Count all records and bases in an ordinary FASTA stream.

This uses the robust multiline FASTA parser, so it accepts wrapped sequence records and blank lines in the same way as next_batch.

Trait Implementations§

Source§

impl<R: Debug> Debug for FastaReader<R>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<R> Freeze for FastaReader<R>
where R: Freeze,

§

impl<R> RefUnwindSafe for FastaReader<R>
where R: RefUnwindSafe,

§

impl<R> Send for FastaReader<R>
where R: Send,

§

impl<R> Sync for FastaReader<R>
where R: Sync,

§

impl<R> Unpin for FastaReader<R>
where R: Unpin,

§

impl<R> UnsafeUnpin for FastaReader<R>
where R: UnsafeUnpin,

§

impl<R> UnwindSafe for FastaReader<R>
where R: 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.