Skip to content

Commit

Permalink
Remove the partial_start and partial_end attributes
Browse files Browse the repository at this point in the history
Since the first syncmer is always the base, we partial_start is always
identical to start and partial_end is always identical to start + k.
  • Loading branch information
marcelm committed Jan 14, 2025
1 parent ec338a6 commit 575dabd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/nam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ 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.partial_start, q.is_reverse};
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;
Expand All @@ -256,7 +256,7 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
continue;
}
nr_good_hits++;
add_to_matches_map_partial(matches_map[q.is_reverse], q.partial_start, q.partial_end, index, partial_pos);
add_to_matches_map_partial(matches_map[q.is_reverse], q.start, q.start + index.k(), index, partial_pos);
}
partial_queried.push_back(ph);
}
Expand Down Expand Up @@ -312,15 +312,15 @@ std::pair<int, std::vector<Nam>> find_nams_rescue(
}
}
else if (use_mcs) {
PartialHit ph = {qr.hash & index.get_main_hash_mask(), qr.partial_start, qr.is_reverse};
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.partial_start, qr.partial_end, true};
RescueHit rh{partial_pos, partial_count, qr.start, qr.start + index.k(), true};
if (qr.is_reverse){
hits_rc.push_back(rh);
} else {
Expand Down
8 changes: 2 additions & 6 deletions src/randstrobes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,9 @@ QueryRandstrobeVector randstrobes_query(const std::string_view seq, const IndexP
RandstrobeIterator randstrobe_fwd_iter{syncmers, parameters.randstrobe};
while (randstrobe_fwd_iter.has_next()) {
auto randstrobe = randstrobe_fwd_iter.next();
const unsigned int partial_start = randstrobe.strobe1_pos;
randstrobes.push_back(
QueryRandstrobe {
randstrobe.hash, randstrobe.strobe1_pos, randstrobe.strobe2_pos + parameters.syncmer.k,
partial_start, partial_start + parameters.syncmer.k, false
randstrobe.hash, randstrobe.strobe1_pos, randstrobe.strobe2_pos + parameters.syncmer.k, false
}
);
}
Expand All @@ -267,11 +265,9 @@ QueryRandstrobeVector randstrobes_query(const std::string_view seq, const IndexP
RandstrobeIterator randstrobe_rc_iter{syncmers, parameters.randstrobe};
while (randstrobe_rc_iter.has_next()) {
auto randstrobe = randstrobe_rc_iter.next();
const unsigned int partial_start = randstrobe.strobe1_pos;
randstrobes.push_back(
QueryRandstrobe {
randstrobe.hash, randstrobe.strobe1_pos, randstrobe.strobe2_pos + parameters.syncmer.k,
partial_start, partial_start + parameters.syncmer.k, true
randstrobe.hash, randstrobe.strobe1_pos, randstrobe.strobe2_pos + parameters.syncmer.k, true
}
);
}
Expand Down
5 changes: 0 additions & 5 deletions src/randstrobes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,6 @@ struct QueryRandstrobe {
randstrobe_hash_t hash;
unsigned int start;
unsigned int end;
/* Start and end of the main syncmer (relevant if the randstrobe couldn’t
* be found in the index and we fall back to a partial hit)
*/
unsigned int partial_start;
unsigned int partial_end;
bool is_reverse;
};

Expand Down

0 comments on commit 575dabd

Please sign in to comment.