60 template <
typename trace_matrix_t>
62 requires matrix_concept<remove_cvref_t<trace_matrix_t>> &&
65 inline alignment_coordinate alignment_begin_coordinate(trace_matrix_t && matrix,
66 alignment_coordinate
const end_coordinate)
68 constexpr
auto D = trace_directions::diagonal;
69 constexpr
auto L = trace_directions::left;
70 constexpr
auto U = trace_directions::up;
71 size_t row = end_coordinate.seq2_pos + 1;
72 size_t col = end_coordinate.seq1_pos + 1;
74 assert(row < matrix.rows());
75 assert(col < matrix.cols());
79 trace_directions dir = matrix.at(row, col);
82 col = std::max<size_t>(col, 1) - 1;
84 else if ((dir & U) == U)
86 row = std::max<size_t>(row, 1) - 1;
88 else if ((dir & D) == D)
90 row = std::max<size_t>(row, 1) - 1;
91 col = std::max<size_t>(col, 1) - 1;
96 if (!(row == 0 || col == 0))
97 throw std::logic_error{
"Unknown seqan3::trace_direction in an inner cell of the trace matrix."};
103 return {std::max<size_t>(col, 1) - 1, std::max<size_t>(row, 1) - 1};
124 typename trace_matrix_t,
125 typename gapped_database_alphabet_t = gapped<value_type_t<database_t>>,
126 typename gapped_query_alphabet_t = gapped<value_type_t<query_t>>>
128 requires matrix_concept<remove_cvref_t<trace_matrix_t>> &&
129 std::Same<typename remove_cvref_t<trace_matrix_t>::entry_type, trace_directions>
131 inline std::pair<std::vector<gapped_database_alphabet_t>, std::vector<gapped_query_alphabet_t>>
132 alignment_trace(database_t && database,
134 trace_matrix_t && matrix,
135 alignment_coordinate
const end_coordinate)
137 constexpr
auto N = trace_directions::none;
138 constexpr
auto D = trace_directions::diagonal;
139 constexpr
auto L = trace_directions::left;
140 constexpr
auto U = trace_directions::up;
141 size_t col = end_coordinate.seq1_pos + 1;
142 size_t row = end_coordinate.seq2_pos + 1;
144 assert(row <= query.size());
145 assert(col <= database.size());
146 assert(row < matrix.rows());
147 assert(col < matrix.cols());
149 std::deque<gapped_database_alphabet_t> gapped_database{};
150 std::deque<gapped_query_alphabet_t> gapped_query{};
152 if (matrix.at(0, 0) != N)
153 throw std::logic_error{
"End trace must be NONE"};
157 trace_directions dir = matrix.at(row, col);
160 col = std::max<size_t>(col, 1) - 1;
161 gapped_database.push_front(database[col]);
162 gapped_query.push_front(gap::GAP);
164 else if ((dir & U) == U)
166 row = std::max<size_t>(row, 1) - 1;
167 gapped_database.push_front(gap::GAP);
168 gapped_query.push_front(query[row]);
170 else if ((dir & D) == D)
172 row = std::max<size_t>(row, 1) - 1;
173 col = std::max<size_t>(col, 1) - 1;
174 gapped_database.push_front(database[col]);
175 gapped_query.push_front(query[row]);
180 if (!(row == 0 || col == 0))
181 throw std::logic_error{
"Unknown seqan3::trace_direction in an inner cell of the trace matrix."};
189 {std::begin(gapped_database), std::end(gapped_database)},
190 {std::begin(gapped_query), std::end(gapped_query)}
Contains the declaration of seqan3::detail::alignment_trace_matrix.
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Definition: aligned_sequence_concept.hpp:288
Provides seqan3::detail::alignment_coordinate.
Provides various metafunctions used by the range module.