Skip to content

Commit

Permalink
Unify FASTX parsing functions & allow streaming gz/bz/etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Roderick Bovee committed Aug 22, 2019
1 parent 4559181 commit 0587cb3
Show file tree
Hide file tree
Showing 10 changed files with 490 additions and 501 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@ edition = "2018"

[features]
default = ["compression"]
compression = ["bzip2", "flate2", "xz2", "zip"]
compression = ["bzip2", "flate2", "xz2"]

[dependencies]
flate2 = { version="1.0.6", optional=true }
bzip2 = { version="0.3.3", optional=true }
xz2 = { version="0.1.6", optional=true }
zip = { version="0.5.0", optional=true }
memchr = "2.2.0"

[dev-dependencies]
bencher = "0.1.5"

[[bench]]
path = "tests/benchmark.rs"
name = "benchmark"
harness = false
4 changes: 2 additions & 2 deletions src/bitkmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,8 @@ pub fn bitmer_to_bytes(kmer: BitKmer) -> Vec<u8> {
// math to figure out where they start (this helps us just pop the bases on the end
// of the working buffer as we read them off "left to right")
let offset = (kmer.1 - 1) * 2;
let bitmask =
BitKmerSeq::pow(2, u32::from(2 * kmer.1 - 1)) + BitKmerSeq::pow(2, u32::from(2 * kmer.1 - 2));
let bitmask = BitKmerSeq::pow(2, u32::from(2 * kmer.1 - 1))
+ BitKmerSeq::pow(2, u32::from(2 * kmer.1 - 2));

for _ in 0..kmer.1 {
let new_char = (new_kmer & bitmask) >> offset;
Expand Down
4 changes: 2 additions & 2 deletions src/buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::marker::PhantomData;
use crate::util::ParseError;

pub struct RecReader<'a> {
file: &'a mut io::Read,
file: &'a mut dyn io::Read,
last: bool,
pub buf: Vec<u8>,
}
Expand All @@ -20,7 +20,7 @@ impl<'a> RecReader<'a> {
/// Under some very rare circumstances (setting a `buf_size` larger than 2 Gb
/// on Mac OS X) a panic can occur. Please use a smaller buffer in this case.
pub fn new(
file: &'a mut io::Read,
file: &'a mut dyn io::Read,
buf_size: usize,
header: &[u8],
) -> Result<RecReader<'a>, ParseError> {
Expand Down
Loading

0 comments on commit 0587cb3

Please sign in to comment.