28namespace seqan3::detail
33struct search_configuration_validator
39 template <
typename query_t>
40 static void validate_query_type()
42 using pure_query_t = std::remove_cvref_t<query_t>;
43 if constexpr (range_dimension_v<pure_query_t> == 1u)
45 static_assert(std::ranges::random_access_range<pure_query_t>,
46 "The query sequence must model random_access_range.");
47 static_assert(std::ranges::sized_range<pure_query_t>,
"The query sequence must model sized_range.");
51 static_assert(std::ranges::forward_range<pure_query_t>,
"The query collection must model forward_range.");
52 static_assert(std::ranges::sized_range<pure_query_t>,
"The query collection must model sized_range.");
53 static_assert(std::ranges::random_access_range<std::ranges::range_value_t<pure_query_t>>,
54 "Elements of the query collection must model random_access_range.");
55 static_assert(std::ranges::sized_range<std::ranges::range_value_t<pure_query_t>>,
56 "Elements of the query collection must model sized_range.");
99template <
typename index_t,
100 std::ranges::forward_range queries_t,
102 requires std::ranges::forward_range<std::ranges::range_reference_t<queries_t>>
103 && std::same_as<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>
107 auto updated_cfg = detail::search_configurator::add_defaults(
cfg);
109 detail::search_configuration_validator::validate_query_type<queries_t>();
116 using query_t = std::ranges::range_reference_t<indexed_queries_t>;
120 using traits_t = detail::search_traits<complete_configuration_t>;
123 detail::execution_handler_parallel,
124 detail::execution_handler_sequential>;
129 if constexpr (std::same_as<execution_handler_t, detail::execution_handler_parallel>)
131 auto thread_count = parallel.thread_count;
133 throw std::runtime_error{
"You must configure the number of threads in seqan3::search_cfg::parallel."};
144 if constexpr (traits_t::has_user_callback)
158 std::move(algorithm),
167template <
typename index_t,
168 std::ranges::forward_range queries_t,
170 requires std::ranges::forward_range<std::ranges::range_reference_t<queries_t>>
171 && (!std::same_as<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>)
172inline auto search(queries_t && queries,
173 index_t
const & index,
176 static_assert(std::convertible_to<range_innermost_value_t<queries_t>,
typename index_t::alphabet_type>,
177 "The alphabet of the text collection must be convertible to the alphabet of the index.");
179 if constexpr (range_dimension_v<queries_t> == 2u)
180 return search(queries | views::deep{views::convert<typename index_t::alphabet_type>}, index, cfg);
182 return search(queries | views::convert<typename index_t::alphabet_type>, index, cfg);
187template <
typename index_t,
188 std::ranges::forward_range query_t,
193 return search(std::views::single(std::forward<query_t>(query)), index, cfg);
197template <
typename index_t,
typename configuration_t = decltype(search_cfg::default_configuration)>
198inline auto search(
char const *
const queries,
199 index_t
const & index,
206template <
typename index_t,
typename configuration_t = decltype(search_cfg::default_configuration)>
208 index_t
const & index,
212 query.
reserve(std::ranges::size(queries));
213 std::ranges::for_each(queries,
214 [&query](
char const *
const q)
218 return search(std::move(query) | seqan3::detail::all, index, cfg);
Provides seqan3::detail::algorithm_executor_blocking.
Provides seqan3::detail::algorithm_result_generator_range.
Provides seqan3::detail::all.
An input range over the algorithm results generated by the underlying algorithm executor.
Definition algorithm_result_generator_range.hpp:45
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
Provides seqan3::configuration and utility functions.
Provides seqan3::views::deep.
Provides the default configuration for the seqan3::search() interface.
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:32
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:105
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
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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.