Struct rust_htslib::bam::Reader[][src]

pub struct Reader { /* fields omitted */ }
Expand description

A BAM reader.

Implementations

Create a new Reader from path.

Arguments

  • path - the path to open.

Create a new Reader from STDIN.

Create a new Reader from URL.

Iterator over the records between the (optional) virtual offsets start and end

Arguments

  • start - Optional starting virtual offset to seek to. Throws an error if it is not a valid virtual offset.

  • end - Read until the virtual offset is less than end

Set the reference path for reading CRAM files.

Arguments

  • path - path to the FASTA reference

Trait Implementations

Formats the value using the given formatter. Read more

Executes the destructor for this type. Read more

Read the next BAM record into the given Record. Returns None if there are no more records.

This method is useful if you want to read records as fast as possible as the Record can be reused. A more ergonomic approach is to use the records iterator.

Errors

If there are any issues with reading the next record an error will be returned.

Examples

use rust_htslib::errors::Error;
use rust_htslib::bam::{Read, Reader, Record};

let mut bam = Reader::from_path(&"test/test.bam")?;
let mut record = Record::new();

// Print the TID of each record
while let Some(r) = bam.read(&mut record) {
   r.expect("Failed to parse record");
   println!("TID: {}", record.tid())
}

Iterator over the records of the fetched region. Note that, while being convenient, this is less efficient than pre-allocating a Record and reading into it with the read method, since every iteration involves the allocation of a new Record.

Records iterator using an Rc to avoid allocating a Record each turn. This is about 1% slower than the read based API in micro benchmarks, but has nicer ergonomics (and might not actually be slower in your applications). Read more

Iterator over pileups.

Return the htsFile struct

Return the header.

Use a shared thread-pool for writing. This permits controlling the total thread count when multiple readers and writers are working simultaneously. A thread pool can be created with crate::tpool::ThreadPool::new(n_threads) Read more

Seek to the given virtual offset in the file

Report the current virtual offset

Activate multi-threaded BAM read support in htslib. This should permit faster reading of large BAM files. Read more

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

Performs the conversion.

Performs the conversion.

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.