Struct ReusableReader

Source
pub struct ReusableReader<P, O>(/* private fields */);
Expand description

Wrapper for parallel::Reader instances allowing the output to be reused in order to save allocations. Used by parallel_fasta/parallel_fastq

use seq_io::fastq::{Reader,Record,RecordSet};
use seq_io::parallel::{read_parallel,ReusableReader};

let inner = Reader::from_path("seqs.fastq").unwrap();
let reader = ReusableReader::new(inner);

read_parallel(reader, 4, 2, |&mut (ref record_set, ref mut out): &mut (RecordSet, Vec<bool>)| {
    out.clear();
    for record in record_set {
        let found = record.seq().windows(3).position(|s| s == b"AAA").is_some();
        out.push(found);
    }
}, |record_sets| {
    while let Some(result) = record_sets.next() {
        let &(ref record_set, ref out) = &*result.unwrap().0;
        for (record, found) in record_set.into_iter().zip(out) {
            // ...
        }
    }
});

Implementations§

Source§

impl<P, O> ReusableReader<P, O>

Source

pub fn new(p: P) -> ReusableReader<P, O>

Trait Implementations§

Source§

impl<P, O> Reader for ReusableReader<P, O>
where P: Reader, O: Send,

Source§

type DataSet = (<P as Reader>::DataSet, O)

Source§

type Err = <P as Reader>::Err

Source§

fn fill_data(&mut self, data: &mut Self::DataSet) -> Option<Result<(), P::Err>>

Auto Trait Implementations§

§

impl<P, O> Freeze for ReusableReader<P, O>
where P: Freeze,

§

impl<P, O> RefUnwindSafe for ReusableReader<P, O>

§

impl<P, O> Send for ReusableReader<P, O>
where P: Send, O: Send,

§

impl<P, O> Sync for ReusableReader<P, O>
where P: Sync, O: Sync,

§

impl<P, O> Unpin for ReusableReader<P, O>
where P: Unpin, O: Unpin,

§

impl<P, O> UnwindSafe for ReusableReader<P, O>
where P: UnwindSafe, O: 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.