21namespace seqan3::detail
26struct policy_max_error
30 search_cfg::max_error_total total{};
32 search_cfg::max_error_substitution substitution{};
34 search_cfg::max_error_insertion insertion{};
36 search_cfg::max_error_deletion deletion{};
39 bool only_max_error_total{
false};
41 bool has_max_error_total{
false};
46 policy_max_error() =
default;
47 policy_max_error(policy_max_error
const &) =
default;
48 policy_max_error(policy_max_error &&) =
default;
49 policy_max_error & operator=(policy_max_error
const &) =
default;
50 policy_max_error & operator=(policy_max_error &&) =
default;
51 ~policy_max_error() =
default;
62 template <
typename configuration_t>
63 requires is_type_specialisation_of_v<configuration_t, seqan3::configuration>
64 explicit policy_max_error(configuration_t
const & config)
66 using search_traits_t = search_traits<configuration_t>;
67 only_max_error_total = search_traits_t::only_max_error_total;
68 has_max_error_total = search_traits_t::has_max_error_total;
70 total = config.get_or(search_cfg::max_error_total{search_cfg::error_count{0}});
71 substitution = config.get_or(search_cfg::max_error_substitution{search_cfg::error_count{0}});
72 insertion = config.get_or(search_cfg::max_error_insertion{search_cfg::error_count{0}});
73 deletion = config.get_or(search_cfg::max_error_deletion{search_cfg::error_count{0}});
85 template <std::ranges::forward_range query_t>
86 auto max_error_counts(query_t && query)
88 detail::search_param errors{0, 0, 0, 0};
92 errors.total = to_error_count(total.error, query_size);
93 errors.substitution = to_error_count(substitution.error, query_size);
94 errors.insertion = to_error_count(insertion.error, query_size);
95 errors.deletion = to_error_count(deletion.error, query_size);
98 if (only_max_error_total)
99 errors.substitution = errors.insertion = errors.deletion = errors.total;
101 else if (!has_max_error_total)
102 errors.total = std::min<uint32_t>(255, errors.substitution + errors.insertion + errors.deletion);
106 if (errors.substitution > errors.total)
107 throw std::invalid_argument{
"The substitution error threshold is higher than the total error threshold."};
108 if (errors.insertion > errors.total)
109 throw std::invalid_argument{
"The insertion error threshold is higher than the total error threshold."};
110 if (errors.deletion > errors.total)
111 throw std::invalid_argument{
"The deletion error threshold is higher than the total error threshold."};
133 [[maybe_unused]]
size_t const query_size)
136 [&query_size](
auto error)
138 if constexpr (std::same_as<
decltype(error), search_cfg::error_count>)
143 if (0.0 > error.get() || error.get() > 1.0)
147 uint8_t
const calculated_error_count =
std::clamp(error.get() * query_size, 0.0, 255.0);
148 return calculated_error_count;
constexpr size_t size
The size of a type pack.
Definition: traits.hpp:146
Provides data structures used by different search algorithms.
Provides seqan3::detail::search_traits.