Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(progress-logger): added a progress logger #10

Merged
merged 1 commit into from
Aug 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 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 @@ -21,6 +21,7 @@ log = "0.4.14"
mimalloc = {version = "0.1.26", default-features = false}
num_cpus = "1.13.0"
parking_lot = "0.11.2"
proglog = "0.2.0"
rayon = "1.5.1"
regex = "1.5.4"
seq_io = "0.3.1"
Expand Down
13 changes: 11 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use itertools::{self, izip, Itertools};
use lazy_static::lazy_static;
use log::info;
use parking_lot::Mutex;
use proglog::ProgLogBuilder;
use rayon::prelude::*;
use regex::{Regex, RegexBuilder};
use seq_io::fastq::{self, OwnedRecord};
Expand Down Expand Up @@ -333,6 +334,13 @@ struct Barcode<'a>(&'a [u8], &'a [u8]);
#[allow(clippy::too_many_lines)]
fn main() -> Result<()> {
let opts = setup();
let progress_logger = ProgLogBuilder::new()
.name("fqgrep-progress")
.noun("reads")
.verb("Searched")
.unit(50_000_000)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we separate with comma's (there's a crate for that)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! I'll put it behind a feature flag I think to keep proglog low dependency by default, but agree tidier numbers would be nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not going to hold this PR up, thank-you @sstadick !

.build();

let ref_sample = Sample::from_r1_path(&opts.r1_fastq, REF_PREFIX)?;
let alt_sample = Sample::from_r1_path(&opts.r1_fastq, ALT_PREFIX)?;
let both_sample = Sample::from_r1_path(&opts.r1_fastq, BOTH_PREFIX)?;
Expand Down Expand Up @@ -379,6 +387,7 @@ fn main() -> Result<()> {
(false, true) => Matches::Alt,
(false, false) => Matches::None,
};
progress_logger.record();
(m, (r1, r2))
})
.filter(|(m, _)| *m != Matches::None)
Expand Down Expand Up @@ -406,7 +415,7 @@ fn main() -> Result<()> {
)
.for_each(
|(ref_reads, alt_reads, both_reads): MatchedReads| {
// Aquire lock to ensure R1 and R2 are enqueued at the same time
// Acquire lock to ensure R1 and R2 are enqueued at the same time
{
let _lock = ref_writer.lock.lock();
ref_writer.r1.tx.as_ref().unwrap().send(ref_reads.0).expect("Failed to send R1s");
Expand Down Expand Up @@ -475,7 +484,7 @@ fn main() -> Result<()> {
.handle
.join()
.expect("Error joining r2 handle");

drop(progress_logger);
info!(
"{} reads matched input ref sequence",
ref_r1_stats.reads_written
Expand Down