#noodles #writer

noodles-bgzf

Blocked gzip format (BGZF) reader and writer

39 breaking releases

0.40.0 May 16, 2025
0.38.0 Apr 6, 2025
0.37.0 Mar 8, 2025
0.34.0 Dec 12, 2024
0.2.0 Jul 21, 2021

#227 in Compression

Download history 3909/week @ 2025-02-03 3931/week @ 2025-02-10 2145/week @ 2025-02-17 2430/week @ 2025-02-24 2497/week @ 2025-03-03 2314/week @ 2025-03-10 2378/week @ 2025-03-17 1596/week @ 2025-03-24 1695/week @ 2025-03-31 1950/week @ 2025-04-07 2021/week @ 2025-04-14 1663/week @ 2025-04-21 3272/week @ 2025-04-28 1869/week @ 2025-05-05 2106/week @ 2025-05-12 1495/week @ 2025-05-19

8,897 downloads per month
Used in 101 crates (18 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
~50K SLoC