#noodles #bioinformatics #gzip

noodles-bgzf

Blocked gzip format (BGZF) reader and writer

19 breaking releases

0.20.0 Mar 3, 2023
0.18.0 Nov 18, 2022
0.13.0 Jul 5, 2022
0.11.0 Mar 29, 2022
0.2.0 Jul 21, 2021

#59 in Compression

Download history 314/week @ 2022-11-29 264/week @ 2022-12-06 236/week @ 2022-12-13 248/week @ 2022-12-20 237/week @ 2022-12-27 166/week @ 2023-01-03 296/week @ 2023-01-10 346/week @ 2023-01-17 350/week @ 2023-01-24 453/week @ 2023-01-31 659/week @ 2023-02-07 940/week @ 2023-02-14 694/week @ 2023-02-21 438/week @ 2023-02-28 382/week @ 2023-03-07 328/week @ 2023-03-14

2,070 downloads per month
Used in 28 crates (12 directly)

MIT license

100KB
2.5K 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 std::{fs::File, io::{self, Read}};
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)?;
# Ok::<(), io::Error>(())

Write a BGZF file

# use std::{fs::File, io::{self, Write}};
use noodles_bgzf as bgzf;
let mut writer = File::create("data.gz").map(bgzf::Writer::new)?;
writer.write_all(b"noodles-bgzf")?;
# Ok::<(), io::Error>(())

Dependencies

~0.7–5.5MB
~79K SLoC