20namespace seqan3::detail
31template <
typename word_t,
typename score_t,
bool is_semi_global,
bool use_max_errors>
32class edit_distance_score_matrix_full
36 template <std::ranges::viewable_range database_t,
37 std::ranges::viewable_range query_t,
38 typename align_config_t,
40 friend class edit_distance_unbanded;
45 edit_distance_score_matrix_full() =
default;
46 edit_distance_score_matrix_full(edit_distance_score_matrix_full
const &) =
default;
47 edit_distance_score_matrix_full(edit_distance_score_matrix_full &&) =
default;
48 edit_distance_score_matrix_full & operator=(edit_distance_score_matrix_full
const &) =
default;
49 edit_distance_score_matrix_full & operator=(edit_distance_score_matrix_full &&) =
default;
50 ~edit_distance_score_matrix_full() =
default;
54 template <
typename derived_t,
typename edit_traits>
55 friend class edit_distance_unbanded_score_matrix_policy;
60 edit_distance_score_matrix_full(
size_t const rows_size) : rows_size{rows_size}, columns{}
66 using word_type = word_t;
69 static constexpr auto word_size = bits_of<word_type>;
72 using score_type = score_t;
78 using reference = value_type;
81 using size_type = size_t;
94 void reserve(
size_t const new_capacity)
96 columns.reserve(new_capacity);
107 template <
typename score_type>
108 static size_t max_rows(word_type
const score_mask,
109 unsigned const last_block,
110 score_type
const score,
111 score_type
const max_errors)
noexcept
114 size_t const active_row = word_size * last_block +
offset;
115 return active_row + (score <= max_errors);
123 static score_type score_delta_of_word(word_type
const & vp, word_type
const & vn)
noexcept
132 reference
at(matrix_coordinate
const & coordinate)
const noexcept
134 size_t col = coordinate.col;
135 size_t row = coordinate.row;
137 assert(row < rows());
138 assert(col < cols());
140 column_type
const & column = columns[col];
141 if constexpr (use_max_errors)
142 if (!(row < column.max_rows))
145 score_type score = is_semi_global ? 0u :
static_cast<score_type
>(col);
147 size_t current_row = 1u;
148 size_t word_idx = 0u;
150 for (; current_row + word_size <= row; ++word_idx, current_row += word_size)
151 score += score_delta_of_word(column.vp[word_idx], column.vn[word_idx]);
153 if (row >= current_row)
155 word_type
const mask = (1u << (row - current_row + 1u)) - 1u;
156 score += score_delta_of_word(column.vp[word_idx] & mask, column.vn[word_idx] & mask);
163 size_t rows() const noexcept
169 size_t cols() const noexcept
171 return columns.size();
176 struct max_errors_state
184 struct score_matrix_state
193 struct column_type : enable_state_t<true, score_matrix_state>, enable_state_t<use_max_errors, max_errors_state>
201 requires (!use_max_errors)
203 column_type column{};
204 column.vp = std::move(vp);
205 column.vn = std::move(vn);
207 columns.push_back(std::move(column));
216 requires use_max_errors
218 column_type column{};
219 column.vp = std::move(vp);
220 column.vn = std::move(vn);
221 column.max_rows = max_rows;
223 columns.push_back(std::move(column));
Provides utility functions for bit twiddling.
Forwards for seqan3::edit_distance_unbanded related types.
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
typename decltype(detail::at< idx >(list_t{}))::type at
Return the type at given index from the type list.
Definition: traits.hpp:279