SeqAn3
rna15.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
40 #pragma once
41 
42 #include <vector>
43 
46 
47 // ------------------------------------------------------------------
48 // rna15
49 // ------------------------------------------------------------------
50 
51 namespace seqan3
52 {
53 
73 class rna15 : public nucleotide_base<rna15, 15>
74 {
75 private:
78 
80  friend base_t;
82  friend base_t::base_t;
84 
85 public:
89  constexpr rna15() noexcept : base_t{} {}
90  constexpr rna15(rna15 const &) = default;
91  constexpr rna15(rna15 &&) = default;
92  constexpr rna15 & operator=(rna15 const &) = default;
93  constexpr rna15 & operator=(rna15 &&) = default;
94  ~rna15() = default;
95 
96  using base_t::base_t;
97 
99  constexpr rna15(dna15 const & r) noexcept
100  {
101  assign_rank(r.to_rank());
102  }
104 
105 protected:
107 
109  static constexpr char_type rank_to_char[value_size]
110  {
111  'A',
112  'B',
113  'C',
114  'D',
115  'G',
116  'H',
117  'K',
118  'M',
119  'N',
120  'R',
121  'S',
122  'U',
123  'V',
124  'W',
125  'Y'
126  };
127 
129  static constexpr std::array<rank_type, 256> char_to_rank = dna15::char_to_rank;
130 
132  static const std::array<rna15, value_size> complement_table;
133 };
134 
135 // ------------------------------------------------------------------
136 // containers
137 // ------------------------------------------------------------------
138 
141 using rna15_vector = std::vector<rna15>;
142 
143 // ------------------------------------------------------------------
144 // literals
145 // ------------------------------------------------------------------
146 
155 constexpr rna15 operator""_rna15(char const c) noexcept
156 {
157  return rna15{}.assign_char(c);
158 }
159 
169 inline rna15_vector operator""_rna15(char const * s, std::size_t n)
170 {
171  rna15_vector r;
172  r.resize(n);
173 
174  for (size_t i = 0; i < n; ++i)
175  r[i].assign_char(s[i]);
176 
177  return r;
178 }
180 
181 // ------------------------------------------------------------------
182 // rna15 (deferred definition)
183 // ------------------------------------------------------------------
184 
185 constexpr std::array<rna15, rna15::value_size> rna15::complement_table
186 {
187  'U'_rna15, // complement of 'A'_rna15
188  'V'_rna15, // complement of 'B'_rna15
189  'G'_rna15, // complement of 'C'_rna15
190  'H'_rna15, // complement of 'D'_rna15
191  'C'_rna15, // complement of 'G'_rna15
192  'D'_rna15, // complement of 'H'_rna15
193  'M'_rna15, // complement of 'K'_rna15
194  'K'_rna15, // complement of 'M'_rna15
195  'N'_rna15, // complement of 'N'_rna15
196  'Y'_rna15, // complement of 'R'_rna15
197  'S'_rna15, // complement of 'S'_rna15
198  'A'_rna15, // complement of 'U'_rna15
199  'B'_rna15, // complement of 'V'_rna15
200  'W'_rna15, // complement of 'W'_rna15
201  'R'_rna15 // complement of 'Y'_rna15
202 };
203 
204 } // namespace seqan3
char char_type
The type of the alphabet when converted to char (e.g. via to_char()).
Definition: alphabet_base.hpp:87
alphabet_concept && assign_char(alphabet_concept &&alph, char_type const chr)
Returns the alphabet letter&#39;s value in character representation.
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition: dna15.hpp:73
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
constexpr rna15(dna15 const &r) noexcept
Allow implicit construction from dna/rna of the same size.
Definition: rna15.hpp:99
constexpr rna15 & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:189
static detail::min_viable_uint_t< size > constexpr value_size
The size of the alphabet, i.e. the number of different values it can take.
Definition: alphabet_base.hpp:198
Provides seqan3::nucleotide_base.
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap.
Definition: rna15.hpp:73
std::vector< rna15 > rna15_vector
Alias for an std::vector of seqan3::rna15.
Definition: rna15.hpp:141
Contains seqan3::dna15, container aliases and string literals.
A CRTP-base that refines seqan3::alphabet_base and is used by the nucleotides.
Definition: nucleotide_base.hpp:65