SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
cigar_operation.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
14// ------------------------------------------------------------------
15// cigar_operation
16// ------------------------------------------------------------------
17
19{
20
44class cigar_operation : public alphabet_base<cigar_operation, 9, char>
45{
46private:
49
51 friend base_t;
52
53public:
57 constexpr cigar_operation() noexcept = default;
58 constexpr cigar_operation(cigar_operation const &) noexcept = default;
59 constexpr cigar_operation(cigar_operation &&) noexcept = default;
60 constexpr cigar_operation & operator=(cigar_operation const &) noexcept = default;
61 constexpr cigar_operation & operator=(cigar_operation &&) noexcept = default;
62 ~cigar_operation() noexcept = default;
63
65
66private:
68 static constexpr char_type rank_to_char_table[alphabet_size]{'M', 'D', 'I', 'S', 'H', 'N', 'P', 'X', '='};
69
71 static constexpr std::array<rank_type, 256> char_to_rank_table{[]() constexpr
72 {
74
75 // reverse mapping for characters
76 for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
77 {
78 ret[rank_to_char_table[rnk]] = rnk;
79 }
80
81 return ret;
82 }()}; // namespace seqan3::exposition_only
83
85 static constexpr char_type rank_to_char(rank_type const rank)
86 {
87 return rank_to_char_table[rank];
88 }
89
91 static constexpr rank_type char_to_rank(char_type const chr)
92 {
93 using index_t = std::make_unsigned_t<char_type>;
94 return char_to_rank_table[static_cast<index_t>(chr)];
95 }
96};
97
98} // namespace seqan3::exposition_only
Provides seqan3::alphabet_base.
A CRTP-base that makes defining a custom alphabet easier.
Definition alphabet_base.hpp:54
detail::min_viable_uint_t< size - 1 > rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition alphabet_base.hpp:77
static constexpr detail::min_viable_uint_t< size > alphabet_size
The size of the alphabet, i.e. the number of different values it can take.
Definition alphabet_base.hpp:196
std::conditional_t< std::same_as< char, void >, char, char > char_type
The char representation; conditional needed to make semi alphabet definitions legal.
Definition alphabet_base.hpp:69
The actual implementation of seqan3::cigar::operation for documentation purposes only.
Definition cigar_operation.hpp:45
constexpr cigar_operation() noexcept=default
Defaulted.
A namespace for SeqAn entities that are intended for documentation purposes only.
Definition cigar_operation.hpp:19
Hide me