SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
rna15.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
15#include <vector>
16
19
20// ------------------------------------------------------------------
21// rna15
22// ------------------------------------------------------------------
23
24namespace seqan3
25{
26
50class rna15 : public nucleotide_base<rna15, 15>
51{
52private:
55
57 friend base_t;
59 friend base_t::base_t;
61
62public:
66 constexpr rna15() noexcept = default;
67 constexpr rna15(rna15 const &) noexcept = default;
68 constexpr rna15(rna15 &&) noexcept = default;
69 constexpr rna15 & operator=(rna15 const &) noexcept = default;
70 constexpr rna15 & operator=(rna15 &&) noexcept = default;
71 ~rna15() noexcept = default;
72
73 using base_t::base_t;
74
82 template <std::same_as<dna15> t>
83 constexpr rna15(t const & r) noexcept
84 {
85 assign_rank(r.to_rank());
86 }
88
89private:
92 {
93 'A',
94 'B',
95 'C',
96 'D',
97 'G',
98 'H',
99 'K',
100 'M',
101 'N',
102 'R',
103 'S',
104 'U',
105 'V',
106 'W',
107 'Y'
108 };
109
111 static constexpr rank_type rank_complement(rank_type const rank)
112 {
114 }
115
117 static constexpr char_type rank_to_char(rank_type const rank)
118 {
119 return rank_to_char_table[rank];
120 }
121
123 static constexpr rank_type char_to_rank(char_type const chr)
124 {
125 return dna15::char_to_rank(chr);
126 }
127};
128
129// ------------------------------------------------------------------
130// containers
131// ------------------------------------------------------------------
132
139
140// ------------------------------------------------------------------
141// literals
142// ------------------------------------------------------------------
143inline namespace literals
144{
145
160constexpr rna15 operator""_rna15(char const c) noexcept
161{
162 return rna15{}.assign_char(c);
163}
164
174inline rna15_vector operator""_rna15(char const * s, std::size_t n)
175{
176 rna15_vector r;
177 r.resize(n);
178
179 for (size_t i = 0; i < n; ++i)
180 r[i].assign_char(s[i]);
181
182 return r;
183}
185
186} // inline namespace literals
187
188} // namespace seqan3
constexpr derived_type & assign_char(char_type const chr) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:165
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
constexpr derived_type & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: alphabet_base.hpp:191
rank_type rank
The value of the alphabet letter is stored as the rank.
Definition: alphabet_base.hpp:265
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap..
Definition: dna15.hpp:51
static constexpr rank_type rank_complement(rank_type const rank)
Returns the complement by rank.
Definition: dna15.hpp:158
static constexpr rank_type char_to_rank(char_type const chr)
Returns the rank representation of character.
Definition: dna15.hpp:170
A CRTP-base that refines seqan3::alphabet_base and is used by the nucleotides.
Definition: nucleotide_base.hpp:43
alphabet_base< rna15, size, char > base_t
Type of the base class.
Definition: nucleotide_base.hpp:46
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap..
Definition: rna15.hpp:51
static constexpr rank_type rank_complement(rank_type const rank)
Returns the complement by rank.
Definition: rna15.hpp:111
static constexpr char_type rank_to_char_table[alphabet_size]
The lookup table used in rank_to_char.
Definition: rna15.hpp:92
static constexpr char_type rank_to_char(rank_type const rank)
Returns the character representation of rank.
Definition: rna15.hpp:117
static constexpr rank_type char_to_rank(char_type const chr)
Returns the rank representation of character.
Definition: rna15.hpp:123
friend base_t
Befriend seqan3::nucleotide_base.
Definition: rna15.hpp:57
constexpr rna15() noexcept=default
Defaulted.
Provides seqan3::dna15, container aliases and string literals.
The main SeqAn3 namespace.
Definition: cleanup.hpp:4
SeqAn specific customisations in the standard namespace.
Provides seqan3::nucleotide_base.
T resize(T... args)