Skip to content

Commit

Permalink
fix out of order output in process_paired_reads (#22)
Browse files Browse the repository at this point in the history
* fix out of order output in process_paired_reads by collecting the ParIter prior to writing

Co-authored-by: SheaML <[email protected]>
  • Loading branch information
slambert-git and slambert-git authored Jan 24, 2023
1 parent 49882dc commit 2fa7584
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ fn process_paired_reads(
writer: &FastqWriter,
progress_logger: &Option<ProgLog>,
) {
reads
let matched_reads = reads
.into_par_iter()
.map(|(mut read1, mut read2)| {
if let Some(progress) = progress_logger {
Expand All @@ -520,15 +520,16 @@ fn process_paired_reads(
}
})
.flatten()
.fold(std::vec::Vec::new, |mut matched_reads, (r1, r2)| {
matched_reads.push(r1);
matched_reads.push(r2);
matched_reads
.fold(std::vec::Vec::new, |mut _matched_reads, (r1, r2)| {
_matched_reads.push(r1);
_matched_reads.push(r2);
_matched_reads
})
.for_each(|matched_read| {
let _lock = writer.lock.lock();
writer.tx.send(matched_read).expect("Failed to send read");
});
.flatten()
.collect();

let _lock = writer.lock.lock();
writer.tx.send(matched_reads).expect("Failed to send read");
}

/// Parse args and set up logging / tracing
Expand Down

0 comments on commit 2fa7584

Please sign in to comment.