Loading...
Searching...
No Matches
advanceable_alignment_coordinate.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <concepts>
#include <iterator>
#include <type_traits>
#include <seqan3/alignment/matrix/detail/matrix_coordinate.hpp>
#include <seqan3/core/debug_stream/debug_stream_type.hpp>
#include <seqan3/core/debug_stream/tuple.hpp>
#include <seqan3/core/detail/strong_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>
namespace seqan3::detail
{
enum struct advanceable_alignment_coordinate_state : uint8_t
{
none,
column,
row
};
template <advanceable_alignment_coordinate_state state = advanceable_alignment_coordinate_state::none>
class advanceable_alignment_coordinate
{
public:
using difference_type = std::make_signed_t<size_t>;
constexpr advanceable_alignment_coordinate() noexcept = default;
constexpr advanceable_alignment_coordinate(advanceable_alignment_coordinate const &) noexcept = default;
constexpr advanceable_alignment_coordinate(advanceable_alignment_coordinate &&) noexcept = default;
constexpr advanceable_alignment_coordinate & operator=(advanceable_alignment_coordinate const &) noexcept = default;
constexpr advanceable_alignment_coordinate & operator=(advanceable_alignment_coordinate &&) noexcept = default;
~advanceable_alignment_coordinate() noexcept = default;
template <advanceable_alignment_coordinate_state other_state>
requires (other_state != state)
constexpr advanceable_alignment_coordinate(advanceable_alignment_coordinate<other_state> const & other) :
first{other.first},
second{other.second}
{}
template <advanceable_alignment_coordinate_state other_state>
requires (other_state != state)
constexpr advanceable_alignment_coordinate(advanceable_alignment_coordinate<other_state> && other) :
first{std::move(other.first)},
second{std::move(other.second)}
{}
constexpr advanceable_alignment_coordinate(column_index_type<size_t> const c_idx,
row_index_type<size_t> const r_idx) noexcept :
first{c_idx.get()},
second{r_idx.get()}
{}
constexpr friend bool operator==(advanceable_alignment_coordinate const & lhs,
advanceable_alignment_coordinate const & rhs) noexcept
{
return std::tie(lhs.first, lhs.second) == std::tie(rhs.first, rhs.second);
}
constexpr friend bool operator!=(advanceable_alignment_coordinate const & lhs,
advanceable_alignment_coordinate const & rhs) noexcept
{
return std::tie(lhs.first, lhs.second) != std::tie(rhs.first, rhs.second);
}
constexpr friend bool operator<=(advanceable_alignment_coordinate const & lhs,
advanceable_alignment_coordinate const & rhs) noexcept
{
return std::tie(lhs.first, lhs.second) <= std::tie(rhs.first, rhs.second);
}
constexpr friend bool operator<(advanceable_alignment_coordinate const & lhs,
advanceable_alignment_coordinate const & rhs) noexcept
{
return std::tie(lhs.first, lhs.second) < std::tie(rhs.first, rhs.second);
}
constexpr friend bool operator>=(advanceable_alignment_coordinate const & lhs,
advanceable_alignment_coordinate const & rhs) noexcept
{
return std::tie(lhs.first, lhs.second) >= std::tie(rhs.first, rhs.second);
}
constexpr friend bool operator>(advanceable_alignment_coordinate const & lhs,
advanceable_alignment_coordinate const & rhs) noexcept
{
return std::tie(lhs.first, lhs.second) > std::tie(rhs.first, rhs.second);
}
constexpr advanceable_alignment_coordinate & operator++(/*pre-increment*/) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
if constexpr (state == advanceable_alignment_coordinate_state::column)
++this->first;
else
++this->second;
return *this;
}
constexpr advanceable_alignment_coordinate operator++(int /*post-increment*/) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
advanceable_alignment_coordinate tmp{*this};
++(*this);
return tmp;
}
constexpr advanceable_alignment_coordinate & operator--(/*pre-decrement*/) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
if constexpr (state == advanceable_alignment_coordinate_state::column)
--this->first;
else
--this->second;
return *this;
}
constexpr advanceable_alignment_coordinate operator--(int /*post-decrement*/) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
advanceable_alignment_coordinate tmp{*this};
--(*this);
return tmp;
}
constexpr advanceable_alignment_coordinate & operator+=(difference_type const offset) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
if constexpr (state == advanceable_alignment_coordinate_state::column)
this->first += offset;
else
this->second += offset;
return *this;
}
constexpr advanceable_alignment_coordinate & operator-=(difference_type const offset) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
if constexpr (state == advanceable_alignment_coordinate_state::column)
this->first -= offset;
else
this->second -= offset;
return *this;
}
constexpr advanceable_alignment_coordinate operator+(difference_type const offset) const noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
advanceable_alignment_coordinate tmp{*this};
tmp += offset;
return tmp;
}
constexpr advanceable_alignment_coordinate operator-(difference_type const offset) const noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
advanceable_alignment_coordinate tmp{*this};
tmp -= offset;
return tmp;
}
constexpr difference_type operator-(advanceable_alignment_coordinate const & other) const noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
if constexpr (state == advanceable_alignment_coordinate_state::column)
return this->first - other.first;
else
return this->second - other.second;
}
constexpr friend advanceable_alignment_coordinate operator+(difference_type const offset,
advanceable_alignment_coordinate const & me) noexcept
requires (state != advanceable_alignment_coordinate_state::none)
{
return me + offset;
}
size_t first{};
size_t second{};
};
} // namespace seqan3::detail
namespace seqan3
{
template <auto state_t>
struct advanceable_alignment_coordinate_printer<detail::advanceable_alignment_coordinate<state_t>>
{
template <typename stream_t>
constexpr void operator()(stream_t & stream, detail::advanceable_alignment_coordinate<state_t> const arg) const
{
stream << std::tie(arg.first, arg.second);
}
};
} // namespace seqan3
debug_stream_type.hpp
Provides seqan3::debug_stream and related types.
seqan3::field::offset
@ offset
Sequence (seqan3::field::seq) relative start position (0-based), unsigned value.
Definition record.hpp:66
iterator
matrix_coordinate.hpp
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
seqan3
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
std::rel_ops::operator!=
T operator!=(T... args)
strong_type.hpp
Provides basic data structure for strong types.
seqan3::advanceable_alignment_coordinate_printer< detail::advanceable_alignment_coordinate< state_t > >::operator()
constexpr void operator()(stream_t &stream, detail::advanceable_alignment_coordinate< state_t > const arg) const
The function call operator that prints the coordinate to the given stream.
Definition advanceable_alignment_coordinate.hpp:313
seqan3::advanceable_alignment_coordinate_printer
Definition default_printer.hpp:27
template_inspection.hpp
Provides type traits for working with templates.
std::tie
T tie(T... args)
tuple.hpp
Provides seqan3::debug_stream and related types.
type_traits
Hide me