SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
advanceable_alignment_coordinate.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
12#include <concepts>
13#include <iterator>
14#include <type_traits>
15
21
22namespace seqan3::detail
23{
24
37{
39 none,
41 column,
43 row
44};
45
61template <advanceable_alignment_coordinate_state state = advanceable_alignment_coordinate_state::none>
63{
64public:
72
76 constexpr advanceable_alignment_coordinate() noexcept = default;
81 constexpr advanceable_alignment_coordinate & operator=(advanceable_alignment_coordinate const &) noexcept = default;
83 constexpr advanceable_alignment_coordinate & operator=(advanceable_alignment_coordinate &&) noexcept = default;
84 ~advanceable_alignment_coordinate() noexcept = default;
85
87 template <advanceable_alignment_coordinate_state other_state>
88 requires (other_state != state)
90 first{other.first},
91 second{other.second}
92 {}
93
95 template <advanceable_alignment_coordinate_state other_state>
96 requires (other_state != state)
98 first{std::move(other.first)},
99 second{std::move(other.second)}
100 {}
101
107 row_index_type<size_t> const r_idx) noexcept :
108 first{c_idx.get()},
109 second{r_idx.get()}
110 {}
112
114 constexpr friend bool operator==(advanceable_alignment_coordinate const & lhs,
115 advanceable_alignment_coordinate const & rhs) noexcept
116 {
117 return std::tie(lhs.first, lhs.second) == std::tie(rhs.first, rhs.second);
118 }
119
120 constexpr friend bool operator!=(advanceable_alignment_coordinate const & lhs,
121 advanceable_alignment_coordinate const & rhs) noexcept
122 {
123 return std::tie(lhs.first, lhs.second) != std::tie(rhs.first, rhs.second);
124 }
125
126 constexpr friend bool operator<=(advanceable_alignment_coordinate const & lhs,
127 advanceable_alignment_coordinate const & rhs) noexcept
128 {
129 return std::tie(lhs.first, lhs.second) <= std::tie(rhs.first, rhs.second);
130 }
131
132 constexpr friend bool operator<(advanceable_alignment_coordinate const & lhs,
133 advanceable_alignment_coordinate const & rhs) noexcept
134 {
135 return std::tie(lhs.first, lhs.second) < std::tie(rhs.first, rhs.second);
136 }
137
138 constexpr friend bool operator>=(advanceable_alignment_coordinate const & lhs,
139 advanceable_alignment_coordinate const & rhs) noexcept
140 {
141 return std::tie(lhs.first, lhs.second) >= std::tie(rhs.first, rhs.second);
142 }
143
144 constexpr friend bool operator>(advanceable_alignment_coordinate const & lhs,
145 advanceable_alignment_coordinate const & rhs) noexcept
146 {
147 return std::tie(lhs.first, lhs.second) > std::tie(rhs.first, rhs.second);
148 }
150
161 constexpr advanceable_alignment_coordinate & operator++(/*pre-increment*/) noexcept
163 {
165 ++this->first;
166 else
167 ++this->second;
168 return *this;
169 }
170
174 constexpr advanceable_alignment_coordinate operator++(int /*post-increment*/) noexcept
176 {
178 ++(*this);
179 return tmp;
180 }
181
185 constexpr advanceable_alignment_coordinate & operator--(/*pre-decrement*/) noexcept
187 {
189 --this->first;
190 else
191 --this->second;
192 return *this;
193 }
194
198 constexpr advanceable_alignment_coordinate operator--(int /*post-decrement*/) noexcept
200 {
202 --(*this);
203 return tmp;
204 }
205
212 {
214 this->first += offset;
215 else
216 this->second += offset;
217 return *this;
218 }
219
226 {
228 this->first -= offset;
229 else
230 this->second -= offset;
231 return *this;
232 }
233
240 {
242 tmp += offset;
243 return tmp;
244 }
245
252 {
254 tmp -= offset;
255 return tmp;
256 }
257
262 constexpr difference_type operator-(advanceable_alignment_coordinate const & other) const noexcept
264 {
266 return this->first - other.first;
267 else
268 return this->second - other.second;
269 }
271
274
279 advanceable_alignment_coordinate const & me) noexcept
281 {
282 return me + offset;
283 }
285
287 size_t first{};
289 size_t second{};
290};
291
292} // namespace seqan3::detail
293
294namespace seqan3
295{
296
307template <typename char_t, typename coordinate_type>
308 requires detail::is_value_specialisation_of_v<std::remove_cvref_t<coordinate_type>,
309 detail::advanceable_alignment_coordinate>
310inline debug_stream_type<char_t> & operator<<(debug_stream_type<char_t> & s, coordinate_type && c)
311{
312 s << std::tie(c.first, c.second);
313 return s;
314}
315
316} // namespace seqan3
Implements an internal alignment coordinate that can be used as an argument to the std::ranges::iota_...
Definition advanceable_alignment_coordinate.hpp:63
constexpr advanceable_alignment_coordinate & operator-=(difference_type const offset) noexcept
Returns the coordinate which is advanced depending on the set policy by -offset.
Definition advanceable_alignment_coordinate.hpp:224
constexpr advanceable_alignment_coordinate() noexcept=default
constexpr advanceable_alignment_coordinate operator+(difference_type const offset) const noexcept
Returns a new coordinate which is advanced depending on the set policy by offset.
Definition advanceable_alignment_coordinate.hpp:238
constexpr advanceable_alignment_coordinate operator++(int) noexcept
Post-increments the coordinate depending on the set policy by one.
Definition advanceable_alignment_coordinate.hpp:174
constexpr advanceable_alignment_coordinate operator-(difference_type const offset) const noexcept
Returns a new coordinate which is advanced depending on the set policy by -offset.
Definition advanceable_alignment_coordinate.hpp:250
constexpr advanceable_alignment_coordinate(advanceable_alignment_coordinate< other_state > &&other)
Move-constructs from another advanceable_alignment_coordinate with a different policy.
Definition advanceable_alignment_coordinate.hpp:97
constexpr friend advanceable_alignment_coordinate operator+(difference_type const offset, advanceable_alignment_coordinate const &me) noexcept
Non-member function.
Definition advanceable_alignment_coordinate.hpp:278
size_t second
The front/back position of the alignment in the second sequence.
Definition advanceable_alignment_coordinate.hpp:289
constexpr advanceable_alignment_coordinate & operator+=(difference_type const offset) noexcept
Returns the coordinate which is advanced depending on the set policy by offset.
Definition advanceable_alignment_coordinate.hpp:210
size_t first
The front/back position of the alignment in the first sequence.
Definition advanceable_alignment_coordinate.hpp:287
constexpr advanceable_alignment_coordinate & operator--() noexcept
Decrements the coordinate depending on the set policy by one.
Definition advanceable_alignment_coordinate.hpp:185
constexpr advanceable_alignment_coordinate(column_index_type< size_t > const c_idx, row_index_type< size_t > const r_idx) noexcept
Construction from the respective column and row indices.
Definition advanceable_alignment_coordinate.hpp:106
constexpr difference_type operator-(advanceable_alignment_coordinate const &other) const noexcept
Returns the difference of this and another coordinate depending on the set policy.
Definition advanceable_alignment_coordinate.hpp:262
constexpr advanceable_alignment_coordinate & operator++() noexcept
Increments the coordinate depending on the set policy by one.
Definition advanceable_alignment_coordinate.hpp:161
constexpr advanceable_alignment_coordinate operator--(int) noexcept
Post-decrements the coordinate depending on the set policy by one.
Definition advanceable_alignment_coordinate.hpp:198
Provides seqan3::debug_stream and related types.
debug_stream_type< char_t > & operator<<(debug_stream_type< char_t > &stream, alignment_t &&alignment)
Stream operator for alignments, which are represented as tuples of aligned sequences.
Definition debug_stream_alignment.hpp:107
advanceable_alignment_coordinate_state
Represents a state to specify the implementation of the seqan3::detail::advanceable_alignment_coordin...
Definition advanceable_alignment_coordinate.hpp:37
@ column
The corresponding alignment coordinate will be incrementable/decrementable in the column index.
@ none
The corresponding alignment coordinate will not be incrementable/decrementable.
@ row
The corresponding alignment coordinate will be incrementable/decrementable in the row index.
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
T operator!=(T... args)
Provides basic data structure for strong types.
A strong type for designated initialisation of the column index of a matrix.
Definition matrix_coordinate.hpp:29
A strong type for designated initialisation of the row index of a matrix.
Definition matrix_coordinate.hpp:58
Provides type traits for working with templates.
T tie(T... args)
Provides seqan3::debug_stream and related types.
Hide me