71 breaking releases

0.72.0 Dec 20, 2024
0.70.0 Nov 7, 2024
0.65.0 Jul 14, 2024
0.58.0 Mar 28, 2024
0.2.1 Jul 30, 2021

#168 in Science

Download history 668/week @ 2024-09-20 562/week @ 2024-09-27 560/week @ 2024-10-04 1657/week @ 2024-10-11 670/week @ 2024-10-18 884/week @ 2024-10-25 750/week @ 2024-11-01 630/week @ 2024-11-08 473/week @ 2024-11-15 419/week @ 2024-11-22 623/week @ 2024-11-29 996/week @ 2024-12-06 683/week @ 2024-12-13 596/week @ 2024-12-20 236/week @ 2024-12-27 598/week @ 2025-01-03

2,464 downloads per month
Used in 44 crates (5 directly)

MIT license

1MB
27K SLoC

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?;
    // ...
}

Dependencies

~2.8–9.5MB
~80K SLoC