Skip to content

Commit

Permalink
fixes a bug introduced by partial hits: several full seeds can have t…
Browse files Browse the repository at this point in the history
…he same partial base seed (identical query and ref coordinates. Such partial seeds got added to the same NAM and thus increased the score (through incrementing n_hits several times)
  • Loading branch information
ksahlin committed Apr 21, 2024
1 parent d9d5aaf commit f5a127a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/nam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ inline void add_to_hits_per_ref_partial(
}
}

bool operator==(const Hit& lhs, const Hit& 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);
}

void merge_hits_into_nams(
robin_hood::unordered_map<unsigned int, std::vector<Hit>>& hits_per_ref,
int k,
Expand All @@ -80,7 +85,11 @@ void merge_hits_into_nams(

std::vector<Nam> open_nams;
unsigned int prev_q_start = 0;
auto prev_hit = Hit{0,0,0,0};
for (auto &h : hits) {
if (prev_hit == h) {
continue;
}
bool is_added = false;
for (auto & o : open_nams) {

Expand Down Expand Up @@ -152,6 +161,7 @@ void merge_hits_into_nams(
open_nams.erase(std::remove_if(open_nams.begin(), open_nams.end(), predicate), open_nams.end());
prev_q_start = h.query_start;
}
prev_hit = h;
}

// Add all current open_matches to final NAMs
Expand Down

0 comments on commit f5a127a

Please sign in to comment.