From 17cb9856dc46f29e7af63b6ec7de342313be0ff8 Mon Sep 17 00:00:00 2001 From: Rory Coffey Date: Tue, 26 Sep 2023 13:20:54 -0400 Subject: [PATCH] moved back to flate2 using multigzDecoder for blocked gzip files --- Cargo.toml | 4 ++-- src/input.rs | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 055b129..48f79c9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" @@ -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" diff --git a/src/input.rs b/src/input.rs index 45dbb62..06d9937 100644 --- a/src/input.rs +++ b/src/input.rs @@ -10,7 +10,7 @@ use std::{ Arc, Mutex, }, }; -use rust_htslib::bgzf; +use flate2::read::MultiGzDecoder; use crate::parse::RawSequenceRead; @@ -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") @@ -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();