SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
cigar_operation.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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]{'M', 'D', 'I', 'S', 'H', 'N', 'P', 'X', '='};
72
74 static constexpr std::array<rank_type, 256> char_to_rank_table{[]() constexpr {std::array<rank_type, 256> ret{};
75
76 // reverse mapping for characters
77 for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
78 {
79 ret[rank_to_char_table[rnk]] = rnk;
80 }
81
82 return ret;
83}()
84}; // namespace seqan3::exposition_only
85
87static constexpr char_type rank_to_char(rank_type const rank)
88{
89 return rank_to_char_table[rank];
90}
91
93static constexpr rank_type char_to_rank(char_type const chr)
94{
95 using index_t = std::make_unsigned_t<char_type>;
96 return char_to_rank_table[static_cast<index_t>(chr)];
97}
98}
99;
100
101} // 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:199
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