#bgzf #noodles #writer

noodles-bgzf

Blocked gzip format (BGZF) reader and writer

38 breaking releases

new 0.39.0 Apr 13, 2025
0.37.0 Mar 8, 2025
0.34.0 Dec 12, 2024
0.33.0 Sep 4, 2024
0.2.0 Jul 21, 2021

#230 in Compression

Download history 826/week @ 2024-12-22 686/week @ 2024-12-29 1845/week @ 2025-01-05 2259/week @ 2025-01-12 2270/week @ 2025-01-19 2704/week @ 2025-01-26 3680/week @ 2025-02-02 4153/week @ 2025-02-09 2138/week @ 2025-02-16 2486/week @ 2025-02-23 2463/week @ 2025-03-02 2340/week @ 2025-03-09 2394/week @ 2025-03-16 1658/week @ 2025-03-23 1499/week @ 2025-03-30 1879/week @ 2025-04-06

7,791 downloads per month
Used in 98 crates (17 directly)

MIT license

140KB
3K SLoC

noodles-bgzf handles the reading and writing of the blocked gzip format (BGZF).

While the gzip format is typically a single stream, a BGZF is the concatenation of many gzip streams. Each stream is called a block, with its uncompressed data size being constrained to less than 64 KiB. This multistream gzip allows random access using virtual positions.

noodles-bgzf abstracts away the concept of blocks, implementing std::io::Read for the reader and std::io::Write for the writer.

Examples

Read an entire BGZF file

use noodles_bgzf as bgzf;
let mut reader = File::open("data.gz").map(bgzf::io::Reader::new)?;
let mut data = Vec::new();
reader.read_to_end(&mut data)?;

Write a BGZF file

use noodles_bgzf as bgzf;
let mut writer = File::create("data.gz").map(bgzf::io::Writer::new)?;
writer.write_all(b"noodles-bgzf")?;

Dependencies

~1.4–7.5MB
~51K SLoC