Skip to content

Commit

Permalink
naming and length hist update
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Aug 23, 2023
1 parent fc58ca1 commit 5b3043e
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/bin/commands/trimmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use std::path::PathBuf;

#[derive(ValueEnum, Clone, Debug)]
enum Operation {
ClipQual,
Clip,
Overlap,
Osc,
FilterLen,
Expand Down Expand Up @@ -60,7 +60,7 @@ pub(crate) struct TrimmerOpts {
#[clap(long, default_value = "4")]
osc_max_oscillations: usize,

/// Difference between adjacent bases to be considered on oscilation.
/// Difference between adjacent bases to be considered on oscillation.
#[clap(long, default_value = "10")]
osc_delta: usize,

Expand Down Expand Up @@ -152,11 +152,10 @@ impl Command for TrimmerOpts {
stats.update_length(r1.seq.len(), stats::When::Pre, stats::ReadI::R1);
stats.update_length(r2.seq.len(), stats::When::Pre, stats::ReadI::R2);

// TODO: implement qual-masking vs clipping with enum
for operation in &self.operations {
match operation {
Operation::ClipQual => {
for (i, r) in [&mut r1, &mut r2].iter_mut().enumerate() {
Operation::Clip => {
for r in [&mut r1, &mut r2].iter_mut() {
let hq_range = base_quality::find_high_quality_bases(
r.qual(),
self.clip_tail_quality,
Expand All @@ -165,11 +164,6 @@ impl Command for TrimmerOpts {
);
// this is hard clip so we send None
base_quality::mask_read(r, hq_range, None);
stats.update_length(
r.seq.len(),
stats::When::Post,
stats::ReadI::from(i),
);
}
}
Operation::Overlap => {
Expand Down Expand Up @@ -226,11 +220,14 @@ impl Command for TrimmerOpts {
}
}

stats.update_length(r1.seq.len(), stats::When::Post, stats::ReadI::R1);
stats.update_length(r2.seq.len(), stats::When::Post, stats::ReadI::R2);

r1.write(&mut writers[0])?;
r2.write(&mut writers[1])?;
}

write!(std::io::stderr(), "{}\n", stats)?;
writeln!(std::io::stderr(), "{}", stats)?;

writers.into_iter().try_for_each(|w| w.close())?;
pool.stop_pool()?;
Expand Down

0 comments on commit 5b3043e

Please sign in to comment.