SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
rna4.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// rna4
19// ------------------------------------------------------------------
20
21namespace seqan3
22{
23
45class rna4 : public nucleotide_base<rna4, 4>
46{
47private:
50
52 friend base_t;
55 friend base_t::base_t;
57
58public:
62 constexpr rna4() noexcept = default;
63 constexpr rna4(rna4 const &) noexcept = default;
64 constexpr rna4(rna4 &&) noexcept = default;
65 constexpr rna4 & operator=(rna4 const &) noexcept = default;
66 constexpr rna4 & operator=(rna4 &&) noexcept = default;
67 ~rna4() noexcept = default;
68
69 using base_t::base_t;
70
78 template <std::same_as<dna4> t>
79 constexpr rna4(t const & r) noexcept
80 {
81 assign_rank(r.to_rank());
82 }
84
85private:
87 static constexpr char_type rank_to_char_table[alphabet_size]{'A', 'C', 'G', 'U'};
88
90 static constexpr rank_type rank_complement(rank_type const rank)
91 {
92 return dna4::rank_complement(rank);
93 }
94
96 static constexpr char_type rank_to_char(rank_type const rank)
97 {
98 return rank_to_char_table[rank];
99 }
100
102 static constexpr rank_type char_to_rank(char_type const chr)
103 {
104 return dna4::char_to_rank(chr);
105 }
106};
107
108// ------------------------------------------------------------------
109// containers
110// ------------------------------------------------------------------
111
118
119// ------------------------------------------------------------------
120// literals
121// ------------------------------------------------------------------
122inline namespace literals
123{
124
139constexpr rna4 operator""_rna4(char const c) noexcept
140{
141 return rna4{}.assign_char(c);
142}
143
153SEQAN3_WORKAROUND_LITERAL rna4_vector operator""_rna4(char const * s, std::size_t n)
154{
155 rna4_vector r;
156 r.resize(n);
157
158 for (size_t i = 0; i < n; ++i)
159 r[i].assign_char(s[i]);
160
161 return r;
162}
164
165} // namespace literals
166
167} // 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 four letter DNA alphabet of A,C,G,T.
Definition dna4.hpp:50
A CRTP-base that refines seqan3::alphabet_base and is used by the nucleotides.
Definition nucleotide_base.hpp:40
The four letter RNA alphabet of A,C,G,U.
Definition rna4.hpp:46
constexpr rna4() noexcept=default
Defaulted.
Provides seqan3::dna4, 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