15#include <seqan3/search/views/minimiser_hash.hpp>
17#include <hibf/contrib/std/chunk_view.hpp>
29template <
typename index_t>
30void search_singular_ibf(search_arguments
const & arguments, index_t && index)
34 auto cereal_future =
std::async(std::launch::async,
37 load_index(index, arguments);
40 seqan3::sequence_file_input<dna4_traits, seqan3::fields<seqan3::field::id, seqan3::field::seq>> fin{
41 arguments.query_file};
42 using record_type =
typename decltype(fin)::record_type;
45 sync_out synced_out{arguments};
49 auto worker = [&](
size_t const start,
size_t const extent)
51 seqan::hibf::serial_timer local_compute_minimiser_timer{};
52 seqan::hibf::serial_timer local_query_ibf_timer{};
53 seqan::hibf::serial_timer local_generate_results_timer{};
55 auto agent = index.ibf().membership_agent();
61 auto hash_adaptor = seqan3::views::minimiser_hash(arguments.shape,
62 seqan3::window_size{arguments.window_size},
63 seqan3::seed{adjust_seed(arguments.shape_weight)});
65 for (
auto && [
id, seq] :
std::span{records.
data() + start, extent})
67 result_string.clear();
69 result_string +=
'\t';
71 auto minimiser_view = seq | hash_adaptor | std::views::common;
72 local_compute_minimiser_timer.start();
73 minimiser.assign(minimiser_view.begin(), minimiser_view.end());
74 local_compute_minimiser_timer.stop();
76 size_t const minimiser_count{minimiser.size()};
77 size_t const threshold = thresholder.get(minimiser_count);
79 local_query_ibf_timer.start();
80 auto & user_bin_ids = agent.membership_for(minimiser, threshold);
81 local_query_ibf_timer.stop();
82 local_generate_results_timer.start();
83 for (
auto && user_bin : user_bin_ids)
85 auto conv =
std::to_chars(buffer.data(), buffer.data() + buffer.size(), user_bin);
92 if (
auto & last_char = result_string.back(); last_char ==
',')
95 result_string +=
'\n';
97 synced_out.write(result_string);
98 local_generate_results_timer.stop();
101 arguments.compute_minimiser_timer += local_compute_minimiser_timer;
102 arguments.query_ibf_timer += local_query_ibf_timer;
103 arguments.generate_results_timer += local_generate_results_timer;
106 auto write_header = [&]()
108 if constexpr (is_ibf)
109 return synced_out.write_header(arguments, index.ibf().hash_function_count());
111 return synced_out.write_header(arguments, index.ibf().ibf_vector[0].hash_function_count());
114 for (
auto && chunked_records : fin | seqan::stl::views::chunk((1ULL << 20) * 10))
117 arguments.query_file_io_timer.start();
121 arguments.query_file_io_timer.stop();
124 [[maybe_unused]]
static bool header_written = write_header();
126 arguments.parallel_search_timer.start();
127 do_parallel(worker, records.size(), arguments.threads);
128 arguments.parallel_search_timer.stop();
Provides raptor::adjust_seed.
T back_inserter(T... args)
Definition threshold.hpp:19
Provides raptor::dna4_traits.
Provides raptor::do_parallel.
Provides raptor::load_index.
Provides raptor::sync_out.
Provides raptor::threshold::threshold.