@@ -289,6 +289,24 @@ def binary_search(index_filename: Path,
289
289
# Otherwise keep the current unique length
290
290
unique_lengths [counted_positions ])
291
291
292
+ # If we have a k-mer count of 1 and the current length queried is the
293
+ # same as the lower bound (i.e. can't get smaller for a unique count)
294
+ # This position has finished searching
295
+ finished_search [counted_positions ] = np .where (
296
+ count_list == 1 ,
297
+ current_length_query [counted_positions ] ==
298
+ lower_length_bound [counted_positions ],
299
+ finished_search [counted_positions ])
300
+
301
+ # If we have a k-mer count > 1 and the current length queried is the
302
+ # same as the uppper bound (i.e. can't find a unique length or larger)
303
+ # This position has finished searching
304
+ finished_search [counted_positions ] = np .where (
305
+ count_list > 1 ,
306
+ current_length_query [counted_positions ] ==
307
+ upper_length_bound [counted_positions ],
308
+ finished_search [counted_positions ])
309
+
292
310
# Update the query length and bounds for the next iteration
293
311
294
312
# Lower the upper bounds of our search range on positions where
@@ -314,13 +332,6 @@ def binary_search(index_filename: Path,
314
332
(upper_length_bound [counted_positions ] / 2 ) +
315
333
(lower_length_bound [counted_positions ] / 2 )).astype (data_type )
316
334
317
- # If we have reduced our bounds to overlapping we have finished
318
- # searching on this position
319
- finished_search [counted_positions ] = \
320
- finished_search [counted_positions ] | \
321
- (upper_length_bound [counted_positions ] <
322
- lower_length_bound [counted_positions ])
323
-
324
335
iteration_count += 1
325
336
326
337
verbose_print (verbose ,
0 commit comments