Crate noodles_bam

source ·
Expand description

noodles-bam handles the reading and writing of the BAM (Binary Alignment/Map) file format.

The BAM format contains the same information as SAM (Sequence Alignment/Map), namely a SAM header and a list of records.

§Examples

§Read all records

use noodles_bam as bam;

let mut reader = bam::io::reader::Builder::default().build_from_path("sample.bam")?;
let header = reader.read_header()?;

for result in reader.records() {
    let record = result?;
    // ...
}

§Query records

Querying allows filtering records by region. It requires an associated BAM index (BAI).

use noodles_bam as bam;

let mut reader = bam::io::indexed_reader::Builder::default().build_from_path("sample.bam")?;
let header = reader.read_header()?;

let region = "sq0:5-8".parse()?;
let query = reader.query(&header, &region)?;

for result in query {
    let record = result?;
    // ...
}

Re-exports§

  • pub use self::record::Record;
  • pub use self::async::io::Reader as AsyncReader;
  • pub use self::async::io::Writer as AsyncWriter;

Modules§