SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
trace_iterator_banded.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
16
17namespace seqan3::detail
18{
19
31template <two_dimensional_matrix_iterator matrix_iter_t>
32class trace_iterator_banded : public trace_iterator_base<trace_iterator_banded<matrix_iter_t>, matrix_iter_t>
33{
34private:
35 static_assert(std::same_as<std::iter_value_t<matrix_iter_t>, trace_directions>,
36 "Value type of the underlying iterator must be trace_directions.");
37
40
42 friend base_t;
43
44public:
48 constexpr trace_iterator_banded() = default;
49 constexpr trace_iterator_banded(trace_iterator_banded const &) = default;
51 constexpr trace_iterator_banded & operator=(trace_iterator_banded const &) = default;
54
60 template <typename index_t>
62 noexcept :
64 pivot_column{static_cast<size_t>(pivot_column.get())}
65 {}
66
76 template <two_dimensional_matrix_iterator other_matrix_iter_t>
78 requires std::constructible_from<matrix_iter_t, other_matrix_iter_t>
81 {}
83
85 [[nodiscard]] constexpr matrix_coordinate coordinate() const noexcept
86 {
87 auto coord = base_t::coordinate();
88 coord.row += static_cast<int32_t>(coord.col - pivot_column);
89 return coord;
90 }
91
92private:
94 constexpr void go_left(matrix_iter_t & iter) const noexcept
95 {
96 // Note, in the banded matrix, the columns are virtually shifted by one cell.
97 // So going left means go to the previous column and then one row down.
99 }
100
102 constexpr void go_diagonal(matrix_iter_t & iter) const noexcept
103 {
104 // Note, in the banded matrix, the columns are virtually shifted by one cell.
105 // So going diagonal means go to the previous column and stay in the same row.
107 }
108
109 size_t pivot_column{};
110};
111
112} // namespace seqan3::detail
A trace iterator for banded trace matrices.
Definition: trace_iterator_banded.hpp:33
constexpr trace_iterator_banded()=default
Defaulted.
constexpr trace_iterator_banded & operator=(trace_iterator_banded &&)=default
Defaulted.
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:61
friend base_t
Befriend base class.
Definition: trace_iterator_banded.hpp:42
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:80
constexpr matrix_coordinate coordinate() const noexcept
Returns the current coordinate in two-dimensional space.
Definition: trace_iterator_banded.hpp:85
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:102
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:109
constexpr void go_left(matrix_iter_t &iter) const noexcept
Moves iterator to previous left cell.
Definition: trace_iterator_banded.hpp:94
A CRTP-base class for trace iterator implementations for the alignment algorithms.
Definition: trace_iterator_base.hpp:63
matrix_iter_t matrix_iter
The underlying matrix iterator.
Definition: trace_iterator_base.hpp:293
constexpr matrix_coordinate coordinate() const noexcept
Returns the current coordinate in two-dimensional space.
Definition: trace_iterator_base.hpp:145
trace_directions
The possible directions a trace can have. The values can be combined by the logical |-operator.
Definition: trace_directions.hpp:29
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
A strong type for designated initialisation of the column index of a matrix.
Definition: matrix_coordinate.hpp:34
A representation of a location or offset within a two-dimensional matrix.
Definition: matrix_coordinate.hpp:96
A strong type for designated initialisation of the row index of a matrix.
Definition: matrix_coordinate.hpp:65
Provides seqan3::detail::trace_iterator_base.