Skip to content

Commit

Permalink
PartialHit is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelm committed Jan 15, 2025
1 parent 8ece1ed commit c0667ff
Showing 1 changed file with 1 addition and 19 deletions.
20 changes: 1 addition & 19 deletions src/nam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,10 +223,6 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
const StrobemerIndex& index,
bool use_mcs
) {
std::vector<PartialHit> partial_queried; // TODO: is a small set more efficient than linear search in a small vector?
if (use_mcs) {
partial_queried.reserve(10);
}
std::array<robin_hood::unordered_map<unsigned int, std::vector<Match>>, 2> matches_map;
matches_map[0].reserve(100);
matches_map[1].reserve(100);
Expand All @@ -243,24 +239,18 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
add_to_matches_map_full(matches_map[q.is_reverse], q.start, q.end, index, position);
}
else if (use_mcs) {
PartialHit ph{q.hash & index.get_main_hash_mask(), q.start, q.is_reverse};
if (std::find(partial_queried.begin(), partial_queried.end(), ph) != partial_queried.end()) {
// already queried
continue;
}
size_t partial_pos = index.find_partial(q.hash);
if (partial_pos != index.end()) {
total_hits++;
if (index.is_partial_filtered(partial_pos)) {
partial_queried.push_back(ph);
continue;
}
nr_good_hits++;
add_to_matches_map_partial(matches_map[q.is_reverse], q.start, q.start + index.k(), index, partial_pos);
}
partial_queried.push_back(ph);
}
}

float nonrepetitive_fraction = total_hits > 0 ? ((float) nr_good_hits) / ((float) total_hits) : 1.0;
auto nams = merge_matches_into_nams_forward_and_reverse(matches_map, index.k(), use_mcs);
return {nonrepetitive_fraction, nr_good_hits, nams};
Expand Down Expand Up @@ -290,8 +280,6 @@ std::pair<int, std::vector<Nam>> find_nams_rescue(
< std::tie(rhs.count, rhs.query_start, rhs.query_end);
}
};
std::vector<PartialHit> partial_queried; // TODO: is a small set more efficient than linear search in a small vector?
partial_queried.reserve(10);
std::array<robin_hood::unordered_map<unsigned int, std::vector<Match>>, 2> matches_map;
std::vector<RescueHit> hits_fw;
std::vector<RescueHit> hits_rc;
Expand All @@ -312,11 +300,6 @@ std::pair<int, std::vector<Nam>> find_nams_rescue(
}
}
else if (use_mcs) {
PartialHit ph = {qr.hash & index.get_main_hash_mask(), qr.start, qr.is_reverse};
if (std::find(partial_queried.begin(), partial_queried.end(), ph) != partial_queried.end()) {
// already queried
continue;
}
size_t partial_pos = index.find_partial(qr.hash);
if (partial_pos != index.end()) {
unsigned int partial_count = index.get_count_partial(partial_pos);
Expand All @@ -327,7 +310,6 @@ std::pair<int, std::vector<Nam>> find_nams_rescue(
hits_fw.push_back(rh);
}
}
partial_queried.push_back(ph);
}
}

Expand Down

0 comments on commit c0667ff

Please sign in to comment.