SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
rna15.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
12#include <vector>
13
16
17// ------------------------------------------------------------------
18// rna15
19// ------------------------------------------------------------------
20
21namespace seqan3
22{
23
47class rna15 : public nucleotide_base<rna15, 15>
48{
49private:
52
54 friend base_t;
57 friend base_t::base_t;
59
60public:
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
80 template <std::same_as<dna15> t>
81 constexpr rna15(t const & r) noexcept
82 {
83 assign_rank(r.to_rank());
84 }
86
87private:
89 static constexpr char_type
90 rank_to_char_table[alphabet_size]{'A', 'B', 'C', 'D', 'G', 'H', 'K', 'M', 'N', 'R', 'S', 'U', 'V', 'W', 'Y'};
91
93 static constexpr rank_type rank_complement(rank_type const rank)
94 {
95 return dna15::rank_complement(rank);
96 }
97
99 static constexpr char_type rank_to_char(rank_type const rank)
100 {
101 return rank_to_char_table[rank];
102 }
103
105 static constexpr rank_type char_to_rank(char_type const chr)
106 {
107 return dna15::char_to_rank(chr);
108 }
109};
110
111// ------------------------------------------------------------------
112// containers
113// ------------------------------------------------------------------
114
121
122// ------------------------------------------------------------------
123// literals
124// ------------------------------------------------------------------
125inline namespace literals
126{
127
142constexpr rna15 operator""_rna15(char const c) noexcept
143{
144 return rna15{}.assign_char(c);
145}
146
156SEQAN3_WORKAROUND_LITERAL rna15_vector operator""_rna15(char const * s, std::size_t n)
157{
158 rna15_vector r;
159 r.resize(n);
160
161 for (size_t i = 0; i < n; ++i)
162 r[i].assign_char(s[i]);
163
164 return r;
165}
167
168} // namespace literals
169
170} // namespace seqan3
constexpr derived_type & assign_char(char_type const chr) noexcept
Assign from a character, implicitly converts invalid characters.
Definition alphabet_base.hpp:160
detail::min_viable_uint_t< size - 1 > rank_type
The type of the alphabet when represented as a number (e.g. via to_rank()).
Definition alphabet_base.hpp:77
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:196
std::conditional_t< std::same_as< char_t, void >, char, char_t > char_type
The char representation; conditional needed to make semi alphabet definitions legal.
Definition alphabet_base.hpp:69
constexpr derived_type & assign_rank(rank_type const c) noexcept
Assign from a numeric value.
Definition alphabet_base.hpp:184
The 15 letter DNA alphabet, containing all IUPAC smybols minus the gap.
Definition dna15.hpp:48
A CRTP-base that refines seqan3::alphabet_base and is used by the nucleotides.
Definition nucleotide_base.hpp:40
The 15 letter RNA alphabet, containing all IUPAC smybols minus the gap.
Definition rna15.hpp:48
constexpr rna15() noexcept=default
Defaulted.
Provides seqan3::dna15, container aliases and string literals.
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
SeqAn specific customisations in the standard namespace.
Provides seqan3::nucleotide_base.
#define SEQAN3_WORKAROUND_LITERAL
Our char literals returning std::vector should be constexpr if constexpr std::vector is supported.
Definition platform.hpp:269
T resize(T... args)
Hide me