BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
rna15.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
14#pragma once
15
16#include <vector>
17
20
21// ------------------------------------------------------------------
22// rna15
23// ------------------------------------------------------------------
24
25namespace bio::alphabet
26{
27
49class rna15 : public nucleotide_base<rna15, 15>
50{
51private:
54
56 friend base_t;
58 friend base_t::base_t;
60
61public:
65 constexpr rna15() noexcept = default;
66 constexpr rna15(rna15 const &) noexcept = default;
67 constexpr rna15(rna15 &&) noexcept = default;
68 constexpr rna15 & operator=(rna15 const &) noexcept = default;
69 constexpr rna15 & operator=(rna15 &&) noexcept = default;
70 ~rna15() noexcept = default;
71
72 using base_t::base_t;
73
75 constexpr rna15(dna15 const & r) noexcept { assign_rank(r.to_rank()); }
77
78protected:
80
83 rank_to_char{'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'};
84
86 static constexpr std::array<rank_type, 256> char_to_rank = dna15::char_to_rank;
87
89 static const std::array<rna15, alphabet_size> complement_table;
90};
91
92} // namespace bio::alphabet
93
94// ------------------------------------------------------------------
95// literals
96// ------------------------------------------------------------------
97
98namespace bio::alphabet
99{
100
101inline namespace literals
102{
103
112consteval rna15 operator""_rna15(char const c)
113{
114 if (!char_is_valid_for<rna15>(c))
115 throw std::invalid_argument{"Illegal character in character literal."};
116
117 return rna15{}.assign_char(c);
118}
119
129template <meta::detail::literal_buffer_string str>
130constexpr std::vector<rna15> operator""_rna15()
131{
132 return detail::string_literal<str, rna15>();
133}
135
136} // namespace literals
137
138} // namespace bio::alphabet
139
140// ------------------------------------------------------------------
141// rna15 (deferred definition)
142// ------------------------------------------------------------------
143
144namespace bio::alphabet
145{
146
147constexpr std::array<rna15, rna15::alphabet_size> rna15::complement_table{
148 'U'_rna15, // complement of 'A'_rna15
149 'V'_rna15, // complement of 'B'_rna15
150 'G'_rna15, // complement of 'C'_rna15
151 'H'_rna15, // complement of 'D'_rna15
152 'C'_rna15, // complement of 'G'_rna15
153 'D'_rna15, // complement of 'H'_rna15
154 'M'_rna15, // complement of 'K'_rna15
155 'K'_rna15, // complement of 'M'_rna15
156 'N'_rna15, // complement of 'N'_rna15
157 'Y'_rna15, // complement of 'R'_rna15
158 'S'_rna15, // complement of 'S'_rna15
159 'A'_rna15, // complement of 'U'_rna15
160 'B'_rna15, // complement of 'V'_rna15
161 'W'_rna15, // complement of 'W'_rna15
162 'R'_rna15 // complement of 'Y'_rna15
163};
164
165} // namespace bio::alphabet
constexpr derived_type & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition: base.hpp:168
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: base.hpp:145
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap..
Definition: dna15.hpp:50
A CRTP-base that refines bio::alphabet::base and is used by the nucleotides.
Definition: nucleotide_base.hpp:42
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap..
Definition: rna15.hpp:50
constexpr rna15() noexcept=default
Defaulted.
Provides bio::alphabet::dna15, container aliases and string literals.
The alphabet module's namespace.
Definition: aa10li.hpp:23
Provides bio::alphabet::nucleotide_base.