#gtf #nom #parser #bioinformatics #ensembl

yanked nom-gtf

A barebones GTF reader written with nom

0.1.3 Sep 23, 2022
0.1.2 Sep 23, 2022
0.1.1 Sep 23, 2022

#14 in #gtf

MIT license

13KB
308 lines

nom-gtf

a parser for gtf built using nom.

This achieves near wc -l throughput.

Usage

This is meant to be used as an iterator and receives any item implementing BufRead.

From File

use std::{fs::File, io::BufReader};
use nom_gtf::GtfReader;

let handle = File::open("data/example.gtf")
  .map(BufReader::new)
  .unwrap();

let num_records = GtfReader::from_bufread(handle)
  .filter_map(|x| x.ok())
  .count();

assert_eq!(num_records, 10);

From Gzip File

use std::{fs::File, io::BufReader};
use flate2::read::MultiGzDecoder;
use nom_gtf::GtfReader;

let handle = File::open("data/example.gtf.gz")
  .map(MultiGzDecoder::new)
  .map(BufReader::new)
  .unwrap();

let num_records = GtfReader::from_bufread(handle)
  .filter_map(|x| x.ok())
  .count();

assert_eq!(num_records, 10);

Dependencies

~1.5MB
~26K SLoC