33 template <
typename derived_t,
typename cell_t,
typename align_local_t = std::false_type>
34 class affine_gap_policy
44 using score_t = std::tuple_element_t<0, cell_t>;
52 constexpr affine_gap_policy() noexcept = default;
53 constexpr affine_gap_policy(affine_gap_policy const &) noexcept = default;
54 constexpr affine_gap_policy(affine_gap_policy &&) noexcept = default;
55 constexpr affine_gap_policy & operator=(affine_gap_policy const &) noexcept = default;
56 constexpr affine_gap_policy & operator=(affine_gap_policy &&) noexcept = default;
57 ~affine_gap_policy() noexcept = default;
67 template <typename matrix_entry_type, typename cache_t>
68 constexpr
void compute_cell(matrix_entry_type && current_cell,
70 score_t const score) const noexcept
75 auto & [score_entry, coordinate, trace_value] = current_cell;
76 auto & [main_score, hz_score, hz_trace] = score_entry;
77 auto & [prev_cell, gap_open, gap_extend, opt] = cache;
78 auto & [prev_score, vt_score, vt_trace] = prev_cell;
85 score_t tmp = prev_score + score;
88 if constexpr (decays_to_ignore_v<decltype(trace_value)>)
90 tmp = (tmp < vt_score) ? vt_score : tmp;
91 tmp = (tmp < hz_score) ? hz_score : tmp;
92 if constexpr (align_local_t::value)
93 tmp = (tmp < 0) ? 0 : tmp;
97 tmp = (tmp < vt_score) ? (trace_value = vt_trace, vt_score)
98 : (trace_value = trace_directions::diagonal | vt_trace, tmp);
99 tmp = (tmp < hz_score) ? (trace_value = hz_trace, hz_score)
100 : (trace_value |= hz_trace, tmp);
101 if constexpr (align_local_t::value)
102 tmp = (tmp < 0) ? (trace_value = trace_directions::none, 0) : tmp;
105 prev_score = main_score;
108 static_cast<derived_t
const &
>(*this).check_score(
109 alignment_optimum{tmp,
static_cast<alignment_coordinate
>(coordinate)}, opt);
113 vt_score += gap_extend;
114 hz_score += gap_extend;
116 if constexpr (decays_to_ignore_v<decltype(trace_value)>)
118 vt_score = (vt_score < tmp) ? tmp : vt_score;
119 hz_score = (hz_score < tmp) ? tmp : hz_score;
123 vt_score = (vt_score < tmp) ? (vt_trace = trace_directions::up_open, tmp)
124 : (vt_trace = trace_directions::up, vt_score);
125 hz_score = (hz_score < tmp) ? (hz_trace = trace_directions::left_open, tmp)
126 : (hz_trace = trace_directions::left, hz_score);
135 template <
typename gap_scheme_t>
136 constexpr
auto make_cache(gap_scheme_t && scheme)
const noexcept
139 alignment_coordinate{column_index_type{0u}, row_index_type{0u}}};
141 static_cast<score_t
>(scheme.get_gap_open_score() + scheme.get_gap_score()),
142 static_cast<score_t>(scheme.get_gap_score()),
Provides the declaration of seqan3::detail::trace_directions.
Definition: aligned_sequence_concept.hpp:35
auto const get
A view calling std::get on each element in a range.
Definition: get.hpp:66
Provides seqan3::detail::alignment_optimum.