18namespace seqan3::detail
23struct policy_max_error
27 search_cfg::max_error_total total{};
29 search_cfg::max_error_substitution substitution{};
31 search_cfg::max_error_insertion insertion{};
33 search_cfg::max_error_deletion deletion{};
36 bool only_max_error_total{
false};
38 bool has_max_error_total{
false};
43 policy_max_error() =
default;
44 policy_max_error(policy_max_error
const &) =
default;
45 policy_max_error(policy_max_error &&) =
default;
46 policy_max_error & operator=(policy_max_error
const &) =
default;
47 policy_max_error & operator=(policy_max_error &&) =
default;
48 ~policy_max_error() =
default;
59 template <
typename configuration_t>
60 requires is_type_specialisation_of_v<configuration_t, seqan3::configuration>
61 explicit policy_max_error(configuration_t
const & config)
63 using search_traits_t = search_traits<configuration_t>;
64 only_max_error_total = search_traits_t::only_max_error_total;
65 has_max_error_total = search_traits_t::has_max_error_total;
67 total = config.get_or(search_cfg::max_error_total{search_cfg::error_count{0}});
68 substitution = config.get_or(search_cfg::max_error_substitution{search_cfg::error_count{0}});
69 insertion = config.get_or(search_cfg::max_error_insertion{search_cfg::error_count{0}});
70 deletion = config.get_or(search_cfg::max_error_deletion{search_cfg::error_count{0}});
82 template <std::ranges::forward_range query_t>
83 auto max_error_counts(query_t && query)
85 detail::search_param errors{0, 0, 0, 0};
87 [[maybe_unused]]
auto query_size = std::ranges::size(query);
89 errors.total = to_error_count(total.error, query_size);
90 errors.substitution = to_error_count(substitution.error, query_size);
91 errors.insertion = to_error_count(insertion.error, query_size);
92 errors.deletion = to_error_count(deletion.error, query_size);
95 if (only_max_error_total)
96 errors.substitution = errors.insertion = errors.deletion = errors.total;
98 else if (!has_max_error_total)
99 errors.total = std::min<uint32_t>(255, errors.substitution + errors.insertion + errors.deletion);
103 if (errors.substitution > errors.total)
104 throw std::invalid_argument{
"The substitution error threshold is higher than the total error threshold."};
105 if (errors.insertion > errors.total)
106 throw std::invalid_argument{
"The insertion error threshold is higher than the total error threshold."};
107 if (errors.deletion > errors.total)
108 throw std::invalid_argument{
"The deletion error threshold is higher than the total error threshold."};
130 [[maybe_unused]]
size_t const query_size)
133 [&query_size](
auto error)
135 if constexpr (std::same_as<
decltype(error), search_cfg::error_count>)
140 if (0.0 > error.get() || error.get() > 1.0)
144 uint8_t
const calculated_error_count =
std::clamp(error.get() * query_size, 0.0, 255.0);
145 return calculated_error_count;
Provides data structures used by different search algorithms.
Provides seqan3::detail::search_traits.