SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
trace_iterator_banded.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
13
14namespace seqan3::detail
15{
16
28template <two_dimensional_matrix_iterator matrix_iter_t>
29class trace_iterator_banded : public trace_iterator_base<trace_iterator_banded<matrix_iter_t>, matrix_iter_t>
30{
31private:
32 static_assert(std::same_as<std::iter_value_t<matrix_iter_t>, trace_directions>,
33 "Value type of the underlying iterator must be trace_directions.");
34
37
39 friend base_t;
40
41public:
45 constexpr trace_iterator_banded() = default;
46 constexpr trace_iterator_banded(trace_iterator_banded const &) = default;
48 constexpr trace_iterator_banded & operator=(trace_iterator_banded const &) = default;
51
57 template <typename index_t>
58 constexpr trace_iterator_banded(matrix_iter_t const matrix_iter,
61 pivot_column{static_cast<size_t>(pivot_column.get())}
62 {}
63
73 template <two_dimensional_matrix_iterator other_matrix_iter_t>
74 requires std::constructible_from<matrix_iter_t, other_matrix_iter_t>
76 {}
78
80 [[nodiscard]] constexpr matrix_coordinate coordinate() const noexcept
81 {
82 auto coord = base_t::coordinate();
83 coord.row += static_cast<int32_t>(coord.col - pivot_column);
84 return coord;
85 }
86
87private:
89 constexpr void go_left(matrix_iter_t & iter) const noexcept
90 {
91 // Note, in the banded matrix, the columns are virtually shifted by one cell.
92 // So going left means go to the previous column and then one row down.
94 }
95
97 constexpr void go_diagonal(matrix_iter_t & iter) const noexcept
98 {
99 // Note, in the banded matrix, the columns are virtually shifted by one cell.
100 // So going diagonal means go to the previous column and stay in the same row.
102 }
103
104 size_t pivot_column{};
105};
106
107} // namespace seqan3::detail
A trace iterator for banded trace matrices.
Definition trace_iterator_banded.hpp:30
constexpr trace_iterator_banded()=default
Defaulted.
constexpr trace_iterator_banded & operator=(trace_iterator_banded &&)=default
Defaulted.
constexpr trace_iterator_banded(trace_iterator_banded< other_matrix_iter_t > const other) noexcept
Constructs from the underlying trace matrix iterator indicating the start of the trace path.
Definition trace_iterator_banded.hpp:75
constexpr trace_iterator_banded & operator=(trace_iterator_banded const &)=default
Defaulted.
~trace_iterator_banded()=default
Defaulted.
constexpr trace_iterator_banded(trace_iterator_banded const &)=default
Defaulted.
constexpr trace_iterator_banded(matrix_iter_t const matrix_iter, column_index_type< index_t > const &pivot_column) noexcept
Constructs from the underlying trace matrix iterator indicating the start of the trace path.
Definition trace_iterator_banded.hpp:58
friend base_t
Befriend base class.
Definition trace_iterator_banded.hpp:39
constexpr matrix_coordinate coordinate() const noexcept
Returns the current coordinate in two-dimensional space.
Definition trace_iterator_banded.hpp:80
constexpr trace_iterator_banded(trace_iterator_banded &&)=default
Defaulted.
constexpr void go_diagonal(matrix_iter_t &iter) const noexcept
Moves iterator to previous up cell.
Definition trace_iterator_banded.hpp:97
size_t pivot_column
The largest column index which is inside of the band in the first row of the matrix.
Definition trace_iterator_banded.hpp:104
constexpr void go_left(matrix_iter_t &iter) const noexcept
Moves iterator to previous left cell.
Definition trace_iterator_banded.hpp:89
A CRTP-base class for trace iterator implementations for the alignment algorithms.
Definition trace_iterator_base.hpp:61
matrix_iter_t matrix_iter
The underlying matrix iterator.
Definition trace_iterator_base.hpp:283
constexpr matrix_coordinate coordinate() const noexcept
Returns the current coordinate in two-dimensional space.
Definition trace_iterator_base.hpp:137
trace_directions
The possible directions a trace can have. The values can be combined by the logical |-operator.
Definition trace_directions.hpp:26
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
A strong type for designated initialisation of the column index of a matrix.
Definition matrix_coordinate.hpp:29
A representation of a location or offset within a two-dimensional matrix.
Definition matrix_coordinate.hpp:87
A strong type for designated initialisation of the row index of a matrix.
Definition matrix_coordinate.hpp:58
Provides seqan3::detail::trace_iterator_base.
Hide me