Skip to main content

ReaderBuilder

Struct ReaderBuilder 

Source
pub struct ReaderBuilder { /* private fields */ }
Expand description

Configuration for a FastxReader.

use fastx::{Format, ReaderBuilder};

let data = b">a\nACGT\n";
let mut reader = ReaderBuilder::new()
    .format(Format::Fasta)
    .buffer_size(64 * 1024)
    .build(&data[..]);
assert_eq!(reader.next().unwrap()?.id, "a");

Implementations§

Source§

impl ReaderBuilder

Source

pub fn new() -> ReaderBuilder

A builder with default settings.

Source

pub fn format(self, format: Format) -> Self

Force a format instead of detecting it.

Source

pub fn buffer_size(self, bytes: usize) -> Self

Size of the internal read buffer, in bytes.

Source

pub fn quality_encoding(self, encoding: QualityEncoding) -> Self

The quality encoding of the input.

Old Illumina 1.3–1.7 files are Phred+64. Set this and the reader will convert quality strings to Phred+33 as it parses, so every Sequence this crate produces uses one encoding.

use fastx::{qual::QualityEncoding, ReaderBuilder};

// 'h' is Q40 in Phred+64.
let data = b"@old\nACGT\n+\nhhhh\n";
let record = ReaderBuilder::new()
    .quality_encoding(QualityEncoding::Phred64)
    .build(&data[..])
    .read_record()?
    .unwrap();

assert_eq!(record.quality.as_deref(), Some(&b"IIII"[..])); // now Phred+33
assert_eq!(record.mean_quality(), Some(40.0));
Source

pub fn max_line_length(self, bytes: usize) -> Self

Refuse lines longer than bytes instead of growing the buffer.

Unlimited by default, because a chromosome legitimately arrives on a single line. Set it when reading files you do not control: without a limit, one unterminated line can grow the buffer until the process is killed.

Source

pub fn max_record_length(self, bytes: usize) -> Self

Refuse records whose sequence exceeds bytes.

Unlimited by default. This bounds a record assembled from many short lines, which max_line_length alone does not catch.

Source

pub fn build<R: Read>(&self, inner: R) -> FastxReader<R>

Build a reader around any Read.

Source

pub fn open<P: AsRef<Path>>( &self, path: P, ) -> Result<FastxReader<Box<dyn Read + Send>>>

Open a path, transparently decompressing gzip and inferring the format.

Trait Implementations§

Source§

impl Clone for ReaderBuilder

Source§

fn clone(&self) -> ReaderBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ReaderBuilder

Source§

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

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

impl Default for ReaderBuilder

Source§

fn default() -> Self

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

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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 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.