https://github.com/informationsea/vcf-rs
Rust implmentation of VCF parser
https://github.com/informationsea/vcf-rs
bioinformatics parser rust
Last synced: 3 months ago
JSON representation
Rust implmentation of VCF parser
- Host: GitHub
- URL: https://github.com/informationsea/vcf-rs
- Owner: informationsea
- License: apache-2.0
- Created: 2020-03-17T15:18:26.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-02T11:08:22.000Z (over 3 years ago)
- Last Synced: 2025-12-13T23:43:36.807Z (6 months ago)
- Topics: bioinformatics, parser, rust
- Language: Rust
- Size: 37.2 MB
- Stars: 25
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
vcf-rs
======
[](https://github.com/informationsea/vcf-rs/actions/workflows/build.yml)
[](https://crates.io/crates/vcf)
[](https://docs.rs/vcf)
[](https://github.com/informationsea/vcf-rs)
[](https://github.com/informationsea/vcf-rs)
Rust implementation of VCF parser.
License
-------
Apache 2.0
Example
-------
```rust
use vcf::*;
use flate2::read::MultiGzDecoder;
use std::fs::File;
fn usage_test() -> Result<(), VCFError> {
let mut reader = VCFReader::new(BufReader::new(MultiGzDecoder::new(File::open(
"./testfiles/NA12878-subset.vcf.gz",
)?)))?;
// access FILTER contents
assert_eq!(
Some(VCFHeaderFilterAlt {
id: b"PASS",
description: b"All filters passed"
}),
reader.header().filter(b"PASS")
);
// access INFO contents
assert_eq!(
b"Stop position of the interval",
reader.header().info(b"END").unwrap().description
);
// prepare VCFRecord object
let mut vcf_record = VCFRecord::new(reader.header());
// read one record
reader.next_record(&mut vcf_record)?;
// get record attributes
assert_eq!(vcf_record.chromosome, b"13");
assert_eq!(vcf_record.position, 32889968);
assert_eq!(vcf_record.id, Vec::::new());
assert_eq!(vcf_record.reference, b"G");
assert_eq!(vcf_record.alternative, vec![b"A"]);
assert_eq!(vcf_record.qual, Some(25743.5));
assert_eq!(vcf_record.info(b"AC"), Some(&vec![b"54".to_vec()]));
assert_eq!(
vcf_record.genotype(b"ERP001775_HiSeq2000_SAMEA1531955-1", b"GT"),
Some(&vec![b"1/1".to_vec()])
);
assert_eq!(
vcf_record.genotype(b"ERP001775_HiSeq2000_SAMEA1531955-1", b"AD"),
Some(&vec![b"0".to_vec(), b"14".to_vec()])
);
Ok(())
}
```