6 releases

0.2.1 Jun 20, 2021
0.2.0 May 27, 2021
0.1.0 Jun 21, 2020
0.0.3 Sep 2, 2018

#27 in Compression

Download history 503/week @ 2021-04-08 165/week @ 2021-04-15 440/week @ 2021-04-22 181/week @ 2021-04-29 38/week @ 2021-05-06 56/week @ 2021-05-13 155/week @ 2021-05-20 65/week @ 2021-05-27 39/week @ 2021-06-03 32/week @ 2021-06-10 42/week @ 2021-06-17 32/week @ 2021-06-24 37/week @ 2021-07-01 27/week @ 2021-07-08 55/week @ 2021-07-15 124/week @ 2021-07-22

675 downloads per month
Used in niffler

MIT license

36KB
816 lines

bgzip-rs

Build Status Appveyor Build Creates.io doc-rs

Rust implementation of BGZF

Write Examples

use bgzip::{BGZFWriter, BGZFError};
use std::io::{self, Write};
fn main() -> Result<(), BGZFError> {
    let mut write_buffer = Vec::new();
    let mut writer = BGZFWriter::new(&mut write_buffer, flate2::Compression::default());
    writer.write_all(b"##fileformat=VCFv4.2\n")?;
    writer.write_all(b"#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n")?;
    writer.close()?;
    Ok(())
}

Read Examples

use bgzip::{BGZFReader, BGZFError};
use std::io::{self, BufRead};
use std::fs;
fn main() -> Result<(), BGZFError> {
    let mut reader =
    BGZFReader::new(fs::File::open("testfiles/common_all_20180418_half.vcf.gz")?);
    let mut line = String::new();
    reader.read_line(&mut line)?;
    assert_eq!("##fileformat=VCFv4.0\n", line);
    reader.bgzf_seek(4210818610)?;
    line.clear();
    reader.read_line(&mut line)?;
    assert_eq!("1\t72700625\trs12116859\tT\tA,C\t.\t.\tRS=12116859;RSPOS=72700625;dbSNPBuildID=120;SSR=0;SAO=0;VP=0x05010008000517053e000100;GENEINFO=LOC105378798:105378798;WGT=1;VC=SNV;SLO;INT;ASP;VLD;G5A;G5;HD;GNO;KGPhase1;KGPhase3;CAF=0.508,.,0.492;COMMON=1;TOPMED=0.37743692660550458,0.00608435270132517,0.61647872069317023\n", line);

    Ok(())
}

TODO

  • Multi-thread writer

Author

Yasunobu OKAMURA

License

MIT

Dependencies

~0.6–1.1MB
~25K SLoC