80 breaking releases
Uses new Rust 2024
| 0.81.0 | Dec 11, 2025 |
|---|---|
| 0.80.0 | Nov 13, 2025 |
| 0.79.0 | Aug 25, 2025 |
| 0.78.0 | Jul 12, 2025 |
| 0.2.0 | Jul 30, 2021 |
#409 in Biology
5,762 downloads per month
Used in 61 crates
(9 directly)
1MB
19K
SLoC
noodles-sam handles the reading and writing of the SAM (Sequence Alignment/Map) format.
SAM is a format typically used to store biological sequences, either mapped to a reference sequence or unmapped. It has two sections: a header and a list of records.
The header mostly holds meta information about the data: a header describing the file format version, reference sequences reads map to, read groups reads belong to, programs that previously manipulated the data, and free-form comments. The header is optional and may be empty.
Each record represents a read, a linear alignment of a segment. Records have fields describing how a read was mapped (or not) to a reference sequence.
Examples
Read all records from a file
use noodles_sam as sam;
let mut reader = sam::io::reader::Builder::default().build_from_path("sample.sam")?;
let header = reader.read_header()?;
for result in reader.records() {
let record = result?;
// ...
}
noodles
noodles attempts to provide specification-compliant (when applicable) implementations of libraries for handling various bioinformatics file formats. It currently supports BAM 1.6, BCF 2.2, BED, BGZF, CRAM 3.0/3.1, CSI, FASTA, FASTQ, GFF3, GTF 2.2, htsget 1.3, refget 2.0, SAM 1.6, tabix, and VCF 4.3/4.4.
Usage
noodles is published on crates.io. Early versions can be used in projects, but keep in mind that the API is still considered experimental.
noodles is split into multiple crates by file format. For convenience, a
top-level meta crate named noodles can be added to your project's dependency
list; and formats, listed as features. For example, to work with the BAM
format, add the noodles crate and enable the bam feature.
cargo add noodles --features bam
Each enabled feature can then be imported by its re-exported name, e.g.,
use noodles::bam;
Feature flags
Individual crates may have optional features that can be enabled using feature flags.
async: Enables asynchronous I/O with Tokio. (BAM, BCF, BGZF, CRAM, CSI, FASTA, FASTQ, GFF, SAM, tabix, and VCF)libdeflate: Use libdeflate to encode and decode DEFLATE streams. (BGZF and CRAM)
Examples
Each crate may have its own examples directory, and all examples are runnable
as an application. After cloning the repository, run cargo run --release --example for a list of available examples. Use the example name as the option
argument and append program arguments to the command, e.g.,
cargo run --release --example bam_write > sample.bam
cargo run --release --example bam_read_header sample.bam
Dependencies
~3.5–5MB
~81K SLoC