Skip to content

Commit 6f44c9f

Browse files
committed
Fix: Sort partial seeds
Since we now produce partial seeds even in non-MCS mode, we need to sort in more cases.
1 parent c805bd2 commit 6f44c9f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/nam.cpp

+5-1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
223223
const StrobemerIndex& index,
224224
bool use_mcs
225225
) {
226+
// If we produce matches in sorted order, then merge_matches_into_nams()
227+
// does not have to re-sort
228+
bool sorting_needed{use_mcs};
226229
std::vector<PartialHit> partial_queried; // TODO: is a small set more efficient than linear search in a small vector?
227230
if (use_mcs) {
228231
partial_queried.reserve(10);
@@ -275,10 +278,11 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
275278
add_to_matches_map_partial(matches_map[q.is_revcomp], q.partial_start, q.partial_end, index, partial_pos);
276279
}
277280
}
281+
sorting_needed = true;
278282
}
279283

280284
float nonrepetitive_fraction = total_hits > 0 ? ((float) nr_good_hits) / ((float) total_hits) : 1.0;
281-
auto nams = merge_matches_into_nams_forward_and_reverse(matches_map, index.k(), use_mcs);
285+
auto nams = merge_matches_into_nams_forward_and_reverse(matches_map, index.k(), sorting_needed);
282286
return {nonrepetitive_fraction, nr_good_hits, nams};
283287
}
284288

0 commit comments

Comments
 (0)