Skip to content

Commit

Permalink
actually correct based on overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
brentp committed Aug 17, 2023
1 parent 476ebfc commit 43aaddb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/bin/commands/trimmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use crate::commands::command::Command;
use anyhow::{Error, Result};
use clap::Parser;
use fgoxide::io::Io;
use fqtk_lib::pair_overlap;
use log::info;
use pooled_writer::{bgzf::BgzfCompressor, Pool, PoolBuilder, PooledWriter};
use seq_io::fastq::{OwnedRecord, Reader as FastqReader, Record};
Expand All @@ -25,7 +26,7 @@ pub(crate) struct Trimmer {
/// Minimum difference in base-quality for one read to correct an overlapping
/// base from the other read.
#[clap(long, short = 'd', default_value = "15")]
overlap_min_bq_delta: usize,
overlap_min_bq_delta: u8,

/// Minimum pair overlap length to attempt correction.
#[clap(long, short = 'l', default_value = "50")]
Expand Down Expand Up @@ -109,10 +110,20 @@ impl Command for Trimmer {
let f2 = readers.remove(0);

for (r1, r2) in f1.into_records().zip(f2.into_records()) {
let r1 = r1?;
let r2 = r2?;
let mut r1 = r1?;
let mut r2 = r2?;

if let Some(overlap) = pair_overlap::find_overlap(
r1.seq(),
r2.seq(),
self.overlap_min_len,
self.overlap_max_error_rate,
) {
overlap.correct(&mut r1, &mut r2, self.overlap_min_bq_delta, true);
}

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

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

0 comments on commit 43aaddb

Please sign in to comment.