@@ -219,6 +219,21 @@ std::tuple<float, int, std::vector<Nam>> find_nams(
219
219
}
220
220
}
221
221
222
+ // Rescue using partial hits, even in non-MCS mode
223
+ if (total_hits == 0 && !use_mcs) {
224
+ for (const auto &q : query_randstrobes) {
225
+ size_t partial_pos = index .find_partial (q.hash );
226
+ if (partial_pos != index .end ()) {
227
+ total_hits++;
228
+ if (index .is_partial_filtered (partial_pos)) {
229
+ continue ;
230
+ }
231
+ nr_good_hits++;
232
+ add_to_matches_map_partial (matches_map[q.is_reverse ], q.start , q.start + index .k (), index , partial_pos);
233
+ }
234
+ }
235
+ }
236
+
222
237
float nonrepetitive_fraction = total_hits > 0 ? ((float ) nr_good_hits) / ((float ) total_hits) : 1.0 ;
223
238
auto nams = merge_matches_into_nams_forward_and_reverse (matches_map, index .k (), use_mcs);
224
239
return {nonrepetitive_fraction, nr_good_hits, nams};
@@ -249,43 +264,34 @@ std::pair<int, std::vector<Nam>> find_nams_rescue(
249
264
}
250
265
};
251
266
std::array<robin_hood::unordered_map<unsigned int , std::vector<Match>>, 2 > matches_map;
252
- std::vector<RescueHit> hits_fw;
253
- std::vector<RescueHit> hits_rc;
267
+ std::array<std::vector<RescueHit>, 2 > hits;
254
268
matches_map[0 ].reserve (100 );
255
269
matches_map[1 ].reserve (100 );
256
- hits_fw .reserve (5000 );
257
- hits_rc .reserve (5000 );
270
+ hits[ 0 ] .reserve (5000 );
271
+ hits[ 1 ] .reserve (5000 );
258
272
259
273
for (auto &qr : query_randstrobes) {
260
274
size_t position = index .find_full (qr.hash );
261
275
if (position != index .end ()) {
262
276
unsigned int count = index .get_count_full (position);
263
277
RescueHit rh{position, count, qr.start , qr.end , false };
264
- if (qr.is_reverse ){
265
- hits_rc.push_back (rh);
266
- } else {
267
- hits_fw.push_back (rh);
268
- }
278
+ hits[qr.is_reverse ].push_back (rh);
269
279
}
270
280
else if (use_mcs) {
271
281
size_t partial_pos = index .find_partial (qr.hash );
272
282
if (partial_pos != index .end ()) {
273
283
unsigned int partial_count = index .get_count_partial (partial_pos);
274
284
RescueHit rh{partial_pos, partial_count, qr.start , qr.start + index .k (), true };
275
- if (qr.is_reverse ){
276
- hits_rc.push_back (rh);
277
- } else {
278
- hits_fw.push_back (rh);
279
- }
285
+ hits[qr.is_reverse ].push_back (rh);
280
286
}
281
287
}
282
288
}
283
289
284
- std::sort (hits_fw .begin (), hits_fw .end ());
285
- std::sort (hits_rc .begin (), hits_rc .end ());
290
+ std::sort (hits[ 0 ] .begin (), hits[ 0 ] .end ());
291
+ std::sort (hits[ 1 ] .begin (), hits[ 1 ] .end ());
286
292
int n_hits = 0 ;
287
293
size_t is_revcomp = 0 ;
288
- for (auto & rescue_hits : {hits_fw, hits_rc} ) {
294
+ for (auto & rescue_hits : hits ) {
289
295
int cnt = 0 ;
290
296
for (auto &rh : rescue_hits) {
291
297
if ((rh.count > rescue_cutoff && cnt >= 5 ) || rh.count > 1000 ) {
0 commit comments