Skip to content

Commit

Permalink
Merge pull request #64 from Roco-scientist/flate2
Browse files Browse the repository at this point in the history
moved back to flate2 using multigzDecoder for blocked gzip files
  • Loading branch information
Roco-scientist authored Sep 26, 2023
2 parents 9620a74 + 17cb985 commit c6e9fce
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "barcode-count"
description = "NGS barcode counter for DEL, CRISPR-seq, and Barcode-seq"
version = "0.11.0"
version = "0.11.1"
edition = "2021"
license = "Apache-2.0"
readme = "README.md"
Expand All @@ -25,4 +25,4 @@ itertools = "0.10"
num_cpus = "1.0"
chrono = "0.4"
num-format = "0.4"
rust-htslib = "0.44"
flate2= "1.0"
7 changes: 3 additions & 4 deletions src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
Arc, Mutex,
},
};
use rust_htslib::bgzf;
use flate2::read::MultiGzDecoder;

use crate::parse::RawSequenceRead;

Expand All @@ -30,10 +30,9 @@ pub fn read_fastq(

// Create a fastq line reader which keeps track of line number, reads, and posts the sequence to the shared vector
let mut fastq_line_reader = FastqLineReader::new(seq_clone, exit_clone);

let fastq_file = File::open(&fastq).context(format!("Failed to open file: {}", fastq))?; // open file
// If the file is not gzipped use BufReader to read in lines
if !fastq.ends_with("fastq.gz") {
let fastq_file = File::open(&fastq).context(format!("Failed to open file: {}", fastq))?; // open file
// If the file does not end with fastq, return with an error
if !fastq.ends_with("fastq") {
bail!("This program only works with *.fastq files and *.fastq.gz files. The latter is still experimental")
Expand Down Expand Up @@ -61,7 +60,7 @@ pub fn read_fastq(
println!("If this program stops reading before the expected number of sequencing reads, unzip the gzipped fastq and rerun.");
println!();
// stream in first by decoding with GzDecoder, the reading into buffer
let mut reader = BufReader::new(bgzf::Reader::from_path(fastq)?);
let mut reader = BufReader::new(MultiGzDecoder::new(fastq_file));

let mut stdout = std::io::stdout();
let mut lock = stdout.lock();
Expand Down

0 comments on commit c6e9fce

Please sign in to comment.