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 29, 2025
1 parent 6c04227 commit 2a7b4f5
Showing 1 changed file with 0 additions and 32 deletions.
32 changes: 0 additions & 32 deletions src/nam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,6 @@ bool operator==(const Match& lhs, const Match& rhs) {
return (lhs.query_start == rhs.query_start) && (lhs.query_end == rhs.query_end) && (lhs.ref_start == rhs.ref_start) && (lhs.ref_end == rhs.ref_end);
}

/*
* A partial hit is a hit where not the full randstrobe hash could be found in
* the index but only the "main" hash (only the first aux_len bits).
*/
struct PartialHit {
randstrobe_hash_t hash;
unsigned int start; // position in strobemer index
bool is_reverse;
bool operator==(const PartialHit& rhs) const {
return (hash == rhs.hash) && (start == rhs.start) && (is_reverse == rhs.is_reverse);
}
};

inline void add_to_matches_map_full(
robin_hood::unordered_map<unsigned int, std::vector<Match>>& matches_map,
int query_start,
Expand Down Expand Up @@ -223,10 +210,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,22 +226,15 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
add_to_matches_map_full(matches_map[q.is_revcomp], 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_revcomp], q.start, q.start + index.k(), index, partial_pos);
}
partial_queried.push_back(ph);
}
}

Expand Down Expand Up @@ -306,8 +282,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::array<std::vector<RescueHit>, 2> hits;
matches_map[0].reserve(100);
Expand All @@ -323,18 +297,12 @@ std::pair<int, std::vector<Nam>> find_nams_rescue(
hits[qr.is_revcomp].push_back(rh);
}
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);
RescueHit rh{partial_pos, partial_count, qr.start, qr.start + index.k(), true};
hits[qr.is_revcomp].push_back(rh);
}
partial_queried.push_back(ph);
}
}

Expand Down

0 comments on commit 2a7b4f5

Please sign in to comment.