Struct bam::bam_reader::BamReader[][src]

pub struct BamReader<R: Read> { /* fields omitted */ }

BAM file reader. In contrast to IndexedReader the BamReader allows to read all records consecutively, but does not allow random access.

You can iterate over records:

extern crate bam;

fn main() {
    // Read "in.bam" using 4 additional threads (5 total).
    let reader = bam::BamReader::from_path("in.bam", 4).unwrap();
    for record in reader {
        let record = record.unwrap();
        // Do something.
    }
}

Alternatively, you can skip excessive record allocation using read_into:

extern crate bam;

// You need to import RecordReader trait
use bam::RecordReader;

fn main() {
    let mut reader = bam::BamReader::from_path("in.bam", 4).unwrap();
    let mut record = bam::Record::new();
    loop {
        match reader.read_into(&mut record) {
            Ok(true) => {},
            Ok(false) => break,
            Err(e) => panic!("{}", e),
        }
        // Do something.
    }
}

Implementations

impl BamReader<File>[src]

pub fn from_path<P: AsRef<Path>>(
    path: P,
    additional_threads: u16
) -> Result<Self>
[src]

Creates BAM file reader from path.

Additional threads are used to decompress bgzip blocks, while the main thread reads the blocks from a file. If additional_threads is 0, the main thread will decompress blocks itself.

impl<R: Read> BamReader<R>[src]

pub fn from_stream(stream: R, additional_threads: u16) -> Result<Self>[src]

Creates BAM file reader from stream. The stream does not have to support random access.

See from_path for more information about additional_threads.

pub fn header(&self) -> &Header[src]

Returns header.

Trait Implementations

impl<R: Read> Iterator for BamReader<R>[src]

Iterator over records.

type Item = Result<Record>

The type of the elements being iterated over.

impl<R: Read> RecordReader for BamReader<R>[src]

Auto Trait Implementations

impl<R> !RefUnwindSafe for BamReader<R>

impl<R> Send for BamReader<R> where
    R: Send

impl<R> !Sync for BamReader<R>

impl<R> Unpin for BamReader<R> where
    R: Unpin

impl<R> !UnwindSafe for BamReader<R>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<I> IntoIterator for I where
    I: Iterator
[src]

type Item = <I as Iterator>::Item

The type of the elements being iterated over.

type IntoIter = I

Which kind of iterator are we turning this into?

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.