36 template <
typename trace_matrix_t>
38 requires matrix<remove_cvref_t<trace_matrix_t>> &&
41 inline alignment_coordinate alignment_front_coordinate(trace_matrix_t && matrix,
42 alignment_coordinate
const back_coordinate)
44 constexpr
auto D = trace_directions::diagonal;
45 constexpr
auto L = trace_directions::left;
46 constexpr
auto U = trace_directions::up;
48 matrix_coordinate coordinate{row_index_type{back_coordinate.
second}, column_index_type{back_coordinate.first}};
50 assert(coordinate.row < matrix.rows());
51 assert(coordinate.col < matrix.cols());
55 trace_directions dir = matrix.at(coordinate);
58 coordinate.col = std::max<size_t>(coordinate.col, 1) - 1;
60 else if ((dir & U) == U)
62 coordinate.row = std::max<size_t>(coordinate.row, 1) - 1;
64 else if ((dir & D) == D)
66 coordinate.row = std::max<size_t>(coordinate.row, 1) - 1;
67 coordinate.col = std::max<size_t>(coordinate.col, 1) - 1;
72 if (!(coordinate.row == 0 || coordinate.col == 0))
73 throw std::logic_error{
"Unknown seqan3::trace_direction in an inner cell of the trace matrix."};
79 return {column_index_type{coordinate.col}, row_index_type{coordinate.row}};
96 tuple_like alignment_t,
99 typename trace_matrix_t>
101 requires matrix<remove_cvref_t<trace_matrix_t>> &&
102 std::same_as<typename remove_cvref_t<trace_matrix_t>::value_type, trace_directions> &&
103 detail::all_satisfy_aligned_seq<detail::tuple_type_list_t<alignment_t>>
105 inline alignment_t alignment_trace(database_t && database,
107 trace_matrix_t && matrix,
108 alignment_coordinate
const back_coordinate,
109 alignment_coordinate
const front_coordinate)
111 constexpr
auto N = trace_directions::none;
112 constexpr
auto D = trace_directions::diagonal;
113 constexpr
auto L = trace_directions::left;
114 constexpr
auto U = trace_directions::up;
116 matrix_coordinate coordinate{row_index_type{back_coordinate.second}, column_index_type{back_coordinate.first}};
118 assert(coordinate.row <= query.size());
119 assert(coordinate.col <= database.size());
120 assert(coordinate.row < matrix.rows());
121 assert(coordinate.col < matrix.cols());
123 alignment_t aligned_seq{};
126 auto end_aligned_db = std::ranges::cend(std::get<0>(aligned_seq));
127 auto end_aligned_qy = std::ranges::cend(std::get<1>(aligned_seq));
129 if (matrix.at({row_index_type{0u}, column_index_type{0u}}) != N)
134 trace_directions dir = matrix.at(coordinate);
137 coordinate.col = std::max<size_t>(coordinate.col, 1) - 1;
139 end_aligned_qy =
insert_gap(std::get<1>(aligned_seq), end_aligned_qy);
141 else if ((dir & U) == U)
143 coordinate.row = std::max<size_t>(coordinate.row, 1) - 1;
144 end_aligned_db =
insert_gap(std::get<0>(aligned_seq), end_aligned_db);
147 else if ((dir & D) == D)
149 coordinate.row = std::max<size_t>(coordinate.row, 1) - 1;
150 coordinate.col = std::max<size_t>(coordinate.col, 1) - 1;
157 if (!(coordinate.row == 0 || coordinate.col == 0))
158 throw std::logic_error{
"Unknown seqan3::trace_direction in an inner cell of the trace matrix."};
size_t second
The begin/end position of the alignment in the second sequence.
Definition: alignment_coordinate.hpp:379
void assign_unaligned(aligned_seq_t &aligned_seq, unaligned_sequence_type &&unaligned_seq)
An implementation of seqan3::aligned_sequence::assign_unaligned_sequence for sequence containers...
Definition: aligned_sequence_concept.hpp:375
aligned_seq_t::iterator insert_gap(aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it)
An implementation of seqan3::aligned_sequence::insert_gap for sequence containers.
Definition: aligned_sequence_concept.hpp:248
Includes the aligned_sequence and the related insert_gap and erase_gap functions to enable stl contai...
Provides the declaration of seqan3::detail::trace_directions.
Definition: aligned_sequence_concept.hpp:36
Provides seqan3::views::slice.
Provides seqan3::detail::alignment_coordinate.
Provides various transformation traits used by the range module.
The concept std::same_as<T, U> is satisfied if and only if T and U denote the same type...
Provides seqan3::detail::matrix.
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:141