SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
cigar_op.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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_op
19 // ------------------------------------------------------------------
20 
21 namespace seqan3
22 {
23 
52 class cigar_op : public alphabet_base<cigar_op, 9, char>
53 {
54 private:
57 
59  friend base_t;
61 
62 public:
66  constexpr cigar_op() noexcept = default;
67  constexpr cigar_op(cigar_op const &) noexcept = default;
68  constexpr cigar_op(cigar_op &&) noexcept = default;
69  constexpr cigar_op & operator=(cigar_op const &) noexcept = default;
70  constexpr cigar_op & operator=(cigar_op &&) noexcept = default;
71  ~cigar_op() noexcept = default;
72 
74 protected:
76 
78  static constexpr char_type rank_to_char[alphabet_size]
79  {
80  'M',
81  'D',
82  'I',
83  'S',
84  'H',
85  'N',
86  'P',
87  'X',
88  '='
89  };
90 
92  static constexpr std::array<rank_type, 256> char_to_rank
93  {
94  [] () constexpr
95  {
97 
98  // reverse mapping for characters
99  for (size_t rnk = 0u; rnk < alphabet_size; ++rnk)
100  {
101  ret[rank_to_char[rnk] ] = rnk;
102  }
103 
104  return ret;
105  }()
106  };
107 };
108 
109 // ------------------------------------------------------------------
110 // literals
111 // ------------------------------------------------------------------
112 
121 inline cigar_op operator""_cigar_op(char const c) noexcept
122 {
123  return cigar_op{}.assign_char(c);
124 }
126 } // namespace seqan3
seqan3::cigar_op::cigar_op
constexpr cigar_op() noexcept=default
Defaulted.
alphabet_base.hpp
Provides seqan3::alphabet_base.
seqan3::alphabet_base< cigar_op, 9, char >::alphabet_size
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:174
seqan3::alphabet_base
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:51
seqan3::cigar_op::operator=
constexpr cigar_op & operator=(cigar_op const &) noexcept=default
Defaulted.
seqan3::alphabet_base::assign_char
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:140
std::array< rank_type, 256 >
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
seqan3::cigar_op::~cigar_op
~cigar_op() noexcept=default
seqan3::alphabet_base< cigar_op, 9, char >::char_type
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:60
seqan3::cigar_op
The (extended) cigar operation alphabet of M,D,I,H,N,P,S,X,=.
Definition: cigar_op.hpp:52