SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
rna15.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 
15 #include <vector>
16 
19 
20 // ------------------------------------------------------------------
21 // rna15
22 // ------------------------------------------------------------------
23 
24 namespace seqan3
25 {
26 
48 class rna15 : public nucleotide_base<rna15, 15>
49 {
50 private:
53 
55  friend base_t;
57  friend base_t::base_t;
59 
60 public:
64  constexpr rna15() noexcept = default;
65  constexpr rna15(rna15 const &) noexcept = default;
66  constexpr rna15(rna15 &&) noexcept = default;
67  constexpr rna15 & operator=(rna15 const &) noexcept = default;
68  constexpr rna15 & operator=(rna15 &&) noexcept = default;
69  ~rna15() noexcept = default;
70 
71  using base_t::base_t;
72 
74  constexpr rna15(dna15 const & r) noexcept
75 #if SEQAN3_WORKAROUND_GCC_90897
76  requires true
77 #endif
78  {
79  assign_rank(r.to_rank());
80  }
82 
83 protected:
85 
87  static constexpr char_type rank_to_char[alphabet_size]
88  {
89  'A',
90  'B',
91  'C',
92  'D',
93  'G',
94  'H',
95  'K',
96  'M',
97  'N',
98  'R',
99  'S',
100  'U',
101  'V',
102  'W',
103  'Y'
104  };
105 
107  static constexpr std::array<rank_type, 256> char_to_rank = dna15::char_to_rank;
108 
110  static const std::array<rna15, alphabet_size> complement_table;
111 };
112 
113 // ------------------------------------------------------------------
114 // containers
115 // ------------------------------------------------------------------
116 
120 
121 // ------------------------------------------------------------------
122 // literals
123 // ------------------------------------------------------------------
124 
133 constexpr rna15 operator""_rna15(char const c) noexcept
134 {
135  return rna15{}.assign_char(c);
136 }
137 
147 inline rna15_vector operator""_rna15(char const * s, std::size_t n)
148 {
149  rna15_vector r;
150  r.resize(n);
151 
152  for (size_t i = 0; i < n; ++i)
153  r[i].assign_char(s[i]);
154 
155  return r;
156 }
158 
159 // ------------------------------------------------------------------
160 // rna15 (deferred definition)
161 // ------------------------------------------------------------------
162 
163 constexpr std::array<rna15, rna15::alphabet_size> rna15::complement_table
164 {
165  'U'_rna15, // complement of 'A'_rna15
166  'V'_rna15, // complement of 'B'_rna15
167  'G'_rna15, // complement of 'C'_rna15
168  'H'_rna15, // complement of 'D'_rna15
169  'C'_rna15, // complement of 'G'_rna15
170  'D'_rna15, // complement of 'H'_rna15
171  'M'_rna15, // complement of 'K'_rna15
172  'K'_rna15, // complement of 'M'_rna15
173  'N'_rna15, // complement of 'N'_rna15
174  'Y'_rna15, // complement of 'R'_rna15
175  'S'_rna15, // complement of 'S'_rna15
176  'A'_rna15, // complement of 'U'_rna15
177  'B'_rna15, // complement of 'V'_rna15
178  'W'_rna15, // complement of 'W'_rna15
179  'R'_rna15 // complement of 'Y'_rna15
180 };
181 
182 } // namespace seqan3
std::vector::resize
T resize(T... args)
dna15.hpp
Provides seqan3::dna15, container aliases and string literals.
seqan3::alphabet_base< rna15, size, 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:176
vector
seqan3::dna15
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition: dna15.hpp:49
seqan3::alphabet_base< rna15, size, char >
seqan3::nucleotide_base
A CRTP-base that refines seqan3::alphabet_base and is used by the nucleotides.
Definition: nucleotide_base.hpp:41
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:142
seqan3::rna15::rna15
constexpr rna15() noexcept=default
Defaulted.
seqan3::rna15
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap.
Definition: rna15.hpp:49
std::array< rank_type, 256 >
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
nucleotide_base.hpp
Provides seqan3::nucleotide_base.
seqan3::alphabet_base< rna15, size, 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:62
seqan3::alphabet_base< rna15, size, char >::assign_rank
constexpr rna15 & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:167
std::size_t