15 #include <type_traits>
21 namespace seqan3::detail
34 template <
typename alignment_algorithm_t>
35 class find_optimum_policy
39 friend alignment_algorithm_t;
42 bool test_every_cell{
false};
44 bool test_last_row_cell{
false};
46 bool test_last_column_cell{
false};
51 constexpr find_optimum_policy() =
default;
52 constexpr find_optimum_policy(find_optimum_policy
const &) =
default;
53 constexpr find_optimum_policy(find_optimum_policy &&) =
default;
54 constexpr find_optimum_policy & operator=(find_optimum_policy
const &) =
default;
55 constexpr find_optimum_policy & operator=(find_optimum_policy &&) =
default;
56 ~find_optimum_policy() =
default;
59 template <
typename configuration_t>
60 find_optimum_policy(configuration_t
const & config)
62 if constexpr (configuration_t::template exists<align_cfg::method_local>())
63 test_every_cell = true;
65 auto method_global_config = config.get_or(align_cfg::method_global{});
66 test_last_row_cell = method_global_config.free_end_gaps_sequence1_trailing;
67 test_last_column_cell = method_global_config.free_end_gaps_sequence2_trailing;
83 template <
typename cell_t,
typename score_t>
84 constexpr
void check_score_of_cell([[maybe_unused]] cell_t
const & current_cell,
85 [[maybe_unused]] alignment_algorithm_state<score_t> & state)
const noexcept
88 check_and_update(current_cell, state);
92 template <
typename other_alignment_algorithm_t,
typename score_t,
typename is_local_t>
93 friend class affine_gap_policy;
95 template <
typename other_alignment_algorithm_t, simd_concept score_t,
typename is_local_t>
96 friend class simd_affine_gap_policy;
99 template <
typename other_alignment_algorithm_t>
100 friend class affine_gap_init_policy;
114 template <
typename cell_t,
typename score_t>
115 constexpr
void check_score_of_last_row_cell([[maybe_unused]] cell_t
const & last_row_cell,
116 [[maybe_unused]] alignment_algorithm_state<score_t> & state)
const
120 if (!test_every_cell && test_last_row_cell)
121 check_and_update(last_row_cell, state);
136 template <
typename alignment_column_t,
typename score_t>
137 constexpr
void check_score_of_cells_in_last_column([[maybe_unused]] alignment_column_t && last_column,
138 [[maybe_unused]] alignment_algorithm_state<score_t> & state)
142 if (!test_every_cell && test_last_column_cell)
143 for (
auto && cell : last_column)
144 check_and_update(cell, state);
159 template <
typename cell_t,
typename score_t>
160 constexpr
void check_score_of_last_cell([[maybe_unused]] cell_t
const & last_cell,
161 [[maybe_unused]] alignment_algorithm_state<score_t> & state)
const noexcept
164 if (!(test_every_cell || test_last_row_cell || test_last_column_cell))
165 check_and_update(last_cell, state);
176 template <
typename cell_t,
typename score_t>
177 constexpr
void check_and_update(cell_t
const & cell, alignment_algorithm_state<score_t> & state)
const noexcept
179 auto const & [score_cell, trace_cell] = cell;
180 state.optimum.update_if_new_optimal_score(score_cell.current,
181 column_index_type{trace_cell.coordinate.first},
182 row_index_type{trace_cell.coordinate.second});