Skip to content

Commit

Permalink
review fixup
Browse files Browse the repository at this point in the history
  • Loading branch information
nh13 committed Sep 19, 2023
1 parent cee27d4 commit 50ca3d5
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions fg-stitch-lib/src/align/aligners/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -726,20 +726,20 @@ impl<'a, F: MatchFunc> SamRecordFormatter<'a, F> {
let min_score =
primary_alignment_score as f32 * self.opts.filter_secondary_pct / 100.0;

let mut new_subs = Vec::new();
let mut old_idx = 0;
while !subs.is_empty() {
let sub = subs.remove(0);
// Update the index of the primary sub-alignment, as we may have removed
// sub-alignments ahead of it
if old_idx == primary_sub_idx {
primary_sub_idx = new_subs.len();
}
if sub.score as f32 >= min_score {
new_subs.push(sub);
}
old_idx += 1;
}
// Filter out sub-alignments that have score worse than X% of the primary
let subs_len = subs.len();
let (new_subs, _) = subs.into_iter().fold(

This comment has been minimized.

Copy link
@jdidion

jdidion Sep 19, 2023

Collaborator

This works. But just a reminder that you can remove the mut from subs and do let (subs, _) = ....

This comment has been minimized.

Copy link
@nh13

nh13 Sep 19, 2023

Author Member

wasn't working for me locally

(Vec::with_capacity(subs_len), 0),
|(mut new_subs, old_idx), sub| {
if old_idx == primary_sub_idx {
primary_sub_idx = new_subs.len();
}
if sub.score as f32 >= min_score {
new_subs.push(sub);
}
(new_subs, old_idx + 1)
},
);
subs = new_subs;
}

Expand Down

0 comments on commit 50ca3d5

Please sign in to comment.