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;
47 size_t row = back_coordinate.second + 1;
48 size_t col = back_coordinate.first + 1;
50 assert(row < matrix.rows());
51 assert(col < matrix.cols());
55 trace_directions dir = matrix.at(row, col);
58 col = std::max<size_t>(col, 1) - 1;
60 else if ((dir & U) == U)
62 row = std::max<size_t>(row, 1) - 1;
64 else if ((dir & D) == D)
66 row = std::max<size_t>(row, 1) - 1;
67 col = std::max<size_t>(col, 1) - 1;
72 if (!(row == 0 || col == 0))
73 throw std::logic_error{
"Unknown seqan3::trace_direction in an inner cell of the trace matrix."};
79 return {column_index_type{col}, row_index_type{row}};
96 TupleLike alignment_t,
99 typename trace_matrix_t>
101 requires Matrix<remove_cvref_t<trace_matrix_t>> &&
102 std::Same<typename remove_cvref_t<trace_matrix_t>::entry_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;
115 size_t col = back_coordinate.first + 1;
116 size_t row = back_coordinate.second + 1;
118 assert(row <= query.size());
119 assert(col <= database.size());
120 assert(row < matrix.rows());
121 assert(col < matrix.cols());
123 alignment_t aligned_seq{};
129 if (matrix.at(0, 0) != N)
134 trace_directions dir = matrix.at(row, col);
137 col = std::max<size_t>(col, 1) - 1;
139 insert_gap(std::get<1>(aligned_seq), end_aligned_qy);
141 else if ((dir & U) == U)
143 row = std::max<size_t>(row, 1) - 1;
144 insert_gap(std::get<0>(aligned_seq), end_aligned_db);
147 else if ((dir & D) == D)
149 row = std::max<size_t>(row, 1) - 1;
150 col = std::max<size_t>(col, 1) - 1;
157 if (!(row == 0 || col == 0))
158 throw std::logic_error{
"Unknown seqan3::trace_direction in an inner cell of the trace matrix."};
void assign_unaligned(aligned_seq_t &aligned_seq, unaligned_sequence_type &&unaligned_seq)
An implementation of seqan3::AlignedSequence::assign_unaligned_sequence for sequence containers...
Definition: aligned_sequence_concept.hpp:345
aligned_seq_t::iterator insert_gap(aligned_seq_t &aligned_seq, typename aligned_seq_t::const_iterator pos_it)
An implementation of seqan3::AlignedSequence::insert_gap for sequence containers. ...
Definition: aligned_sequence_concept.hpp:229
Includes the AlignedSequence and the related insert_gap and erase_gap functions to enable stl contain...
constexpr auto slice
A view adaptor that returns a half-open interval on the underlying range.
Definition: slice.hpp:144
Provides seqan3::view::all.
Provides the declaration of seqan3::detail::trace_directions.
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.
Definition: aligned_sequence_concept.hpp:35
Provides seqan3::detail::alignment_coordinate.
Provides various transformation traits used by the range module.
::ranges::cend cend
Alias for ranges::cend. Returns an iterator to the end of a range.
Definition: ranges:214
Provides seqan3::detail::Matrix.