27namespace seqan3::detail
32struct search_configuration_validator
38 template <
typename query_t>
39 static void validate_query_type()
41 using pure_query_t = std::remove_cvref_t<query_t>;
44 static_assert(std::ranges::random_access_range<pure_query_t>,
45 "The query sequence must model random_access_range.");
46 static_assert(std::ranges::sized_range<pure_query_t>,
"The query sequence must model sized_range.");
50 static_assert(std::ranges::forward_range<pure_query_t>,
"The query collection must model forward_range.");
51 static_assert(std::ranges::sized_range<pure_query_t>,
"The query collection must model sized_range.");
52 static_assert(std::ranges::random_access_range<std::ranges::range_value_t<pure_query_t>>,
53 "Elements of the query collection must model random_access_range.");
54 static_assert(std::ranges::sized_range<std::ranges::range_value_t<pure_query_t>>,
55 "Elements of the query collection must model sized_range.");
98template <
typename index_t,
99 std::ranges::forward_range queries_t,
101 requires std::ranges::forward_range<std::ranges::range_reference_t<queries_t>>
106 auto updated_cfg = detail::search_configurator::add_defaults(cfg);
108 detail::search_configuration_validator::validate_query_type<queries_t>();
110 size_t queries_size = std::ranges::distance(queries);
113 using indexed_queries_t =
decltype(indexed_queries);
115 using query_t = std::ranges::range_reference_t<indexed_queries_t>;
116 auto [algorithm, complete_config] = detail::search_configurator::configure_algorithm<query_t>(updated_cfg, index);
118 using complete_configuration_t =
decltype(complete_config);
119 using traits_t = detail::search_traits<complete_configuration_t>;
120 using algorithm_result_t =
typename traits_t::search_result_type;
122 detail::execution_handler_parallel,
123 detail::execution_handler_sequential>;
128 if constexpr (std::same_as<execution_handler_t, detail::execution_handler_parallel>)
130 auto thread_count = parallel.thread_count;
132 throw std::runtime_error{
"You must configure the number of threads in seqan3::search_cfg::parallel."};
134 return execution_handler_t{*thread_count};
138 return execution_handler_t{};
143 if constexpr (traits_t::has_user_callback)
145 select_execution_handler().bulk_execute(algorithm,
151 using executor_t = detail::algorithm_executor_blocking<indexed_queries_t,
154 execution_handler_t>;
157 std::move(algorithm),
158 algorithm_result_t{},
159 select_execution_handler()}};
166template <
typename index_t,
167 std::ranges::forward_range queries_t,
169 requires std::ranges::forward_range<std::ranges::range_reference_t<queries_t>>
171inline auto search(queries_t && queries,
172 index_t
const & index,
175 static_assert(std::convertible_to<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>,
176 "The alphabet of the text collection must be convertible to the alphabet of the index.");
186template <
typename index_t,
187 std::ranges::forward_range query_t,
196template <
typename index_t,
typename configuration_t = decltype(search_cfg::default_configuration)>
197inline auto search(
char const *
const queries,
198 index_t
const & index,
201 return search(std::string_view{queries}, index, cfg);
205template <
typename index_t,
typename configuration_t = decltype(search_cfg::default_configuration)>
206inline auto search(std::initializer_list<char const * const>
const & queries,
207 index_t
const & index,
210 std::vector<std::string_view> query;
211 query.
reserve(std::ranges::size(queries));
212 std::ranges::for_each(queries,
213 [&query](
char const *
const q)
217 return search(std::move(query) | std::views::all, index, cfg);
Provides seqan3::detail::algorithm_executor_blocking.
Provides seqan3::detail::algorithm_result_generator_range.
An input range over the algorithm results generated by the underlying algorithm executor.
Definition algorithm_result_generator_range.hpp:45
deep(underlying_adaptor_t &&inner) -> deep< underlying_adaptor_t >
Template argument deduction helper that preserves lvalue references and turns rvalue references into ...
Provides seqan3::configuration and utility functions.
Provides seqan3::views::deep.
Provides the default configuration for the seqan3::search() interface.
typename range_innermost_value< t >::type range_innermost_value_t
Shortcut for seqan3::range_innermost_value (transformation_trait shortcut).
Definition core/range/type_traits.hpp:95
constexpr size_t range_dimension_v
Returns the number of times you can call seqan3::value_type_t recursively on t (type trait).
Definition core/range/type_traits.hpp:112
seqan3::detail::parallel_mode< std::integral_constant< seqan3::detail::search_config_id, seqan3::detail::search_config_id::parallel > > parallel
Enables the parallel execution of the search algorithm if possible for the given configuration.
Definition parallel.hpp:31
constexpr configuration default_configuration
The default configuration: Compute all exact matches.
Definition default_configuration.hpp:26
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
seqan::stl::views::zip zip
A view adaptor that takes several views and returns tuple-like values from every i-th element of each...
Definition zip.hpp:24
constexpr auto convert
A view that converts each element in the input range (implicitly or via static_cast).
Definition utility/views/convert.hpp:66
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition configuration.hpp:412
Provides seqan3::search_cfg::on_result.
Provides seqan3::search_cfg::parallel configuration.
Provides seqan3::detail::search_configurator.
Provides seqan3::detail::search_traits.
Provides seqan3::views::convert.
Provides seqan3::views::zip.