#noodles #writer #bgzf

noodles-bgzf

Blocked gzip format (BGZF) reader and writer

36 breaking releases

0.37.0 Mar 8, 2025
0.35.0 Jan 19, 2025
0.34.0 Dec 12, 2024
0.33.0 Sep 4, 2024
0.2.0 Jul 21, 2021

#234 in Compression

Download history 1429/week @ 2024-12-04 1779/week @ 2024-12-11 1507/week @ 2024-12-18 579/week @ 2024-12-25 1338/week @ 2025-01-01 1681/week @ 2025-01-08 2437/week @ 2025-01-15 2121/week @ 2025-01-22 3513/week @ 2025-01-29 4653/week @ 2025-02-05 2660/week @ 2025-02-12 2255/week @ 2025-02-19 2128/week @ 2025-02-26 2599/week @ 2025-03-05 2315/week @ 2025-03-12 2154/week @ 2025-03-19

9,675 downloads per month
Used in 97 crates (17 directly)

MIT license

135KB
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::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::Writer::new)?;
writer.write_all(b"noodles-bgzf")?;

Dependencies

~1.4–7.5MB
~51K SLoC