31namespace seqan3::detail
36struct search_configuration_validator
42 template <
typename query_t>
43 static void validate_query_type()
46 if constexpr(range_dimension_v<pure_query_t> == 1u)
48 static_assert(std::ranges::random_access_range<pure_query_t>,
49 "The query sequence must model random_access_range.");
50 static_assert(std::ranges::sized_range<pure_query_t>,
"The query sequence must model sized_range.");
54 static_assert(std::ranges::forward_range<pure_query_t>,
"The query collection must model forward_range.");
55 static_assert(std::ranges::sized_range<pure_query_t>,
"The query collection must model sized_range.");
56 static_assert(std::ranges::random_access_range<std::ranges::range_value_t<pure_query_t>>,
57 "Elements of the query collection must model random_access_range.");
58 static_assert(std::ranges::sized_range<std::ranges::range_value_t<pure_query_t>>,
59 "Elements of the query collection must model sized_range.");
97template <
typename index_t,
98 std::ranges::forward_range queries_t,
101 requires std::ranges::forward_range<std::ranges::range_reference_t<queries_t>> &&
102 std::same_as<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>
105 index_t
const & index,
108 auto updated_cfg = detail::search_configurator::add_defaults(cfg);
110 detail::search_configuration_validator::validate_query_type<queries_t>();
112 size_t queries_size = std::ranges::distance(queries);
113 auto indexed_queries =
views::zip(std::views::iota(
size_t{0}, queries_size), queries);
115 using indexed_queries_t =
decltype(indexed_queries);
117 using query_t = std::ranges::range_reference_t<indexed_queries_t>;
118 auto [algorithm, complete_config] = detail::search_configurator::configure_algorithm<query_t>(updated_cfg, index);
120 using complete_configuration_t =
decltype(complete_config);
121 using traits_t = detail::search_traits<complete_configuration_t>;
122 using algorithm_result_t =
typename traits_t::search_result_type;
124 complete_configuration_t::template exists<search_cfg::parallel>(),
125 detail::execution_handler_parallel,
126 detail::execution_handler_sequential>;
129 auto select_execution_handler = [&] ()
131 if constexpr (std::same_as<execution_handler_t, detail::execution_handler_parallel>)
133 auto thread_count = get<search_cfg::parallel>(complete_config).thread_count;
135 throw std::runtime_error{
"You must configure the number of threads in seqan3::search_cfg::parallel."};
137 return execution_handler_t{*thread_count};
141 return execution_handler_t{};
146 if constexpr (traits_t::has_user_callback)
148 select_execution_handler().bulk_execute(algorithm,
150 get<search_cfg::on_result>(complete_config).callback);
154 using executor_t = detail::algorithm_executor_blocking<indexed_queries_t,
157 execution_handler_t>;
160 std::move(algorithm),
161 algorithm_result_t{},
162 select_execution_handler()}};
169template <
typename index_t,
170 std::ranges::forward_range queries_t,
172 requires std::ranges::forward_range<std::ranges::range_reference_t<queries_t>> &&
173 (!std::same_as<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>)
174inline auto search(queries_t && queries,
175 index_t
const & index,
178 static_assert(std::convertible_to<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>,
179 "The alphabet of the text collection must be convertible to the alphabet of the index.");
181 if constexpr (range_dimension_v<queries_t> == 2u)
182 return search(queries | views::deep{views::convert<typename index_t::alphabet_type>}, index, cfg);
184 return search(queries | views::convert<typename index_t::alphabet_type>, index, cfg);
189template <
typename index_t,
190 std::ranges::forward_range query_t,
192inline auto search(query_t && query,
193 index_t
const & index,
200template <
typename index_t,
typename configuration_t = decltype(search_cfg::default_configuration)>
201inline auto search(
char const *
const queries,
202 index_t
const & index,
209template <
typename index_t,
typename configuration_t = decltype(search_cfg::default_configuration)>
211 index_t
const & index,
217 return search(std::move(query) | detail::persist, index, cfg);
Provides seqan3::detail::algorithm_executor_blocking.
Provides seqan3::detail::algorithm_result_generator_range.
The <algorithm> header from C++20's standard library.
An input range over the algorithm results generated by the underlying algorithm executor.
Definition: algorithm_result_generator_range.hpp:46
Provides seqan3::configuration and utility functions.
Provides seqan3::views::deep.
Provides the default configuration for the seqan3::search() interface.
const configuration default_configuration
The default configuration: Compute all exact matches.
Definition: default_configuration.hpp:33
@ single
The text is a single range.
Definition: concept.hpp:74
auto search(queries_t &&queries, index_t const &index, configuration_t const &cfg=search_cfg::default_configuration)
Search a query or a range of queries in an index.
Definition: search.hpp:104
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:151
constexpr auto zip
A zip view.
Definition: zip.hpp:29
The main SeqAn3 namespace.
Definition: cigar_operation_table.hpp:2
Provides seqan3::search_cfg::on_result.
Provides seqan3::search_cfg::parallel configuration.
Provides seqan3::detail::persist.
The <ranges> header from C++20's standard library.
Provides seqan3::detail::search_configurator.
Provides seqan3::detail::search_traits.
Provides seqan3::views::convert.
Provides seqan3::views::zip.