SeqAn3 3.4.0-rc.3
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
aa10murphy.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
17
18namespace seqan3
19{
20
78class aa10murphy : public aminoacid_base<aa10murphy, 10>
79{
80private:
83
85 friend base_t;
88 friend base_t::base_t;
90
91public:
95 constexpr aa10murphy() noexcept = default;
101
105
106private:
108 static constexpr char_type rank_to_char_table[alphabet_size]{'A', 'B', 'C', 'F', 'G', 'H', 'I', 'K', 'P', 'S'};
109
111 static constexpr char_type rank_to_char(rank_type const rank)
112 {
113 return rank_to_char_table[rank];
114 }
115
117 static constexpr rank_type char_to_rank(char_type const chr)
118 {
119 using index_t = std::make_unsigned_t<char_type>;
120 return char_to_rank_table[static_cast<index_t>(chr)];
121 }
122
124 static constexpr std::array<rank_type, 256> char_to_rank_table{
125 []() constexpr
126 {
128
129 // initialize with 'S' because that appears most frequently
130 ret.fill(9u);
131
132 // reverse mapping for characters and their lowercase
133 for (rank_type rnk = 0u; rnk < alphabet_size; ++rnk)
134 {
135 ret[static_cast<rank_type>(rank_to_char_table[rnk])] = rnk;
136 ret[static_cast<rank_type>(to_lower(rank_to_char_table[rnk]))] = rnk;
137 }
138
139 ret['D'] = ret['B'];
140 ret['d'] = ret['B']; // Convert D to B (either D/N).
141 ret['E'] = ret['B'];
142 ret['e'] = ret['B']; // Convert E to B (either D/N).
143 ret['J'] = ret['I'];
144 ret['j'] = ret['I']; // Convert J (either I/L) to I.
145 ret['L'] = ret['I'];
146 ret['l'] = ret['I']; // Convert L to I.
147 ret['M'] = ret['I'];
148 ret['m'] = ret['I']; // Convert M to I.
149 ret['N'] = ret['B'];
150 ret['n'] = ret['B']; // Convert N to B (either D/N).
151 ret['O'] = ret['K'];
152 ret['o'] = ret['K']; // Convert Pyrrolysine to K.
153 ret['Q'] = ret['B'];
154 ret['q'] = ret['B']; // Convert Q to B (either D/N).
155 ret['R'] = ret['K'];
156 ret['r'] = ret['K']; // Convert R to K.
157 ret['T'] = ret['S'];
158 ret['t'] = ret['S']; // Convert T to S.
159 ret['U'] = ret['C'];
160 ret['u'] = ret['C']; // Convert Selenocysteine to C.
161 ret['V'] = ret['I'];
162 ret['v'] = ret['I']; // Convert V to I.
163 ret['W'] = ret['F'];
164 ret['w'] = ret['F']; // Convert W to F.
165 ret['X'] = ret['S'];
166 ret['x'] = ret['S']; // Convert unknown amino acids to Serine.
167 ret['Y'] = ret['F'];
168 ret['y'] = ret['F']; // Convert Y to F.
169 ret['Z'] = ret['B'];
170 ret['z'] = ret['B']; // Convert Z (either E/Q) to B (either D/N).
171 ret['*'] = ret['F']; // The most common stop codon is UGA. This is most similar to a Tryptophan which in
172 // this alphabet gets converted to Phenylalanine.
173
174 return ret;
175 }()};
176};
177
178// ------------------------------------------------------------------
179// containers
180// ------------------------------------------------------------------
181
188
189// ------------------------------------------------------------------
190// literals
191// ------------------------------------------------------------------
192inline namespace literals
193{
194
208constexpr aa10murphy operator""_aa10murphy(char const c) noexcept
209{
210 return aa10murphy{}.assign_char(c);
211}
212
224SEQAN3_WORKAROUND_LITERAL aa10murphy_vector operator""_aa10murphy(char const * const s, size_t const n)
225{
227 r.resize(n);
228
229 for (size_t i = 0; i < n; ++i)
230 r[i].assign_char(s[i]);
231
232 return r;
233}
235
236} // namespace literals
237
238} // namespace seqan3
Provides seqan3::aminoacid_alphabet.
Provides seqan3::aminoacid_base.
The reduced Murphy amino acid alphabet.
Definition aa10murphy.hpp:79
constexpr aa10murphy() noexcept=default
Defaulted.
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
A CRTP-base that refines seqan3::alphabet_base and is used by the amino acids.
Definition aminoacid_base.hpp:30
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
T fill(T... args)
The main SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
constexpr char_type to_lower(char_type const c) noexcept
Converts 'A'-'Z' to 'a'-'z' respectively; other characters are returned as is.
Definition transform.hpp:74
#define SEQAN3_WORKAROUND_LITERAL
Our char literals returning std::vector should be constexpr if constexpr std::vector is supported.
Definition platform.hpp:294
Provides utilities for modifying characters.
Hide me