Skip to content

Commit

Permalink
add indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
angelovangel committed Feb 23, 2024
1 parent 55089eb commit 9d7b7af
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 2 deletions.
124 changes: 122 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ clap = "~2.33.3"
rand = "0.7.3"
regex = "1"
rayon = "1.5"
indicatif = "0.17.8"

[dev-dependencies]
assert_cmd = "0.10"
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ use flate2::bufread;
use regex::{bytes::RegexSet, Regex};
//use std::io::Read;
use std::{fs, io, io::BufRead, io::BufReader, process};
use indicatif::ProgressBar;
use std::time::Duration;

extern crate clap;
use clap::{App, Arg, ArgGroup};
Expand Down Expand Up @@ -419,6 +421,8 @@ fn main() {
let mut minlen: i64 = i64::MAX;
let mut maxlen = 0;
let mut len_vector: Vec<i64> = Vec::new();
let pb = ProgressBar::new_spinner();
pb.enable_steady_tick(Duration::from_millis(120));

while !record.is_empty() {
//let seq = record.seq();
Expand All @@ -432,6 +436,7 @@ fn main() {
minlen = len.min(minlen);
maxlen = len.max(maxlen);
len_vector.push(len);
pb.set_message("Calculating...");

reader
.read(&mut record)
Expand All @@ -445,6 +450,7 @@ fn main() {
let n50 = modules::get_nx(&mut len_vector, 0.5); // use 0.1 for N90!!!
let q20 = qual20 as f64 / bases as f64 * 100.0;
let q30 = qual30 as f64 / bases as f64 * 100.0;
pb.finish_and_clear();

if !matches.is_present("skip_header") {
println!("file\treads\tbases\tn_bases\tmin_len\tmax_len\tmean_len\tQ1\tQ2\tQ3\tN50\tQ20_percent\tQ30_percent");
Expand Down

0 comments on commit 9d7b7af

Please sign in to comment.