SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
cigar_operation.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
17// ------------------------------------------------------------------
18// cigar_operation
19// ------------------------------------------------------------------
20
22{
23
47class cigar_operation : public alphabet_base<cigar_operation, 9, char>
48{
49private:
52
54 friend base_t;
55
56public:
60 constexpr cigar_operation() noexcept = default;
61 constexpr cigar_operation(cigar_operation const &) noexcept = default;
62 constexpr cigar_operation(cigar_operation &&) noexcept = default;
63 constexpr cigar_operation & operator=(cigar_operation const &) noexcept = default;
64 constexpr cigar_operation & operator=(cigar_operation &&) noexcept = default;
65 ~cigar_operation() noexcept = default;
66
68
69private:
71 static constexpr char_type rank_to_char_table[alphabet_size]
72 {
73 'M',
74 'D',
75 'I',
76 'S',
77 'H',
78 'N',
79 'P',
80 'X',
81 '='
82 };
83
85 static constexpr std::array<rank_type, 256> char_to_rank_table
86 {
87 [] () constexpr
88 {
90
91 // reverse mapping for characters
92 for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
93 {
94 ret[rank_to_char_table[rnk]] = rnk;
95 }
96
97 return ret;
98 }()
99 };
100
102 static constexpr char_type rank_to_char(rank_type const rank)
103 {
104 return rank_to_char_table[rank];
105 }
106
108 static constexpr rank_type char_to_rank(char_type const chr)
109 {
110 using index_t = std::make_unsigned_t<char_type>;
111 return char_to_rank_table[static_cast<index_t>(chr)];
112 }
113};
114
115} // namespace seqan3::exposition_only
Provides seqan3::alphabet_base.
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:57
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:80
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:203
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:72
The actual implementation of seqan3::cigar::operation for documentation purposes only....
Definition: cigar_operation.hpp:48
constexpr cigar_operation() noexcept=default
Defaulted.
A namespace for SeqAn entities that are intended for documentation purposes only.
Definition: cigar_operation.hpp:22