SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
aa10li.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
20 
21 namespace seqan3
22 {
80 class aa10li : public aminoacid_base<aa10li, 10>
81 {
82 private:
85 
87  friend base_t;
89  friend base_t::base_t;
91 
92 public:
96  constexpr aa10li() noexcept = default;
97  constexpr aa10li(aa10li const &) noexcept = default;
98  constexpr aa10li(aa10li &&) noexcept = default;
99  constexpr aa10li & operator=(aa10li const &) noexcept = default;
100  constexpr aa10li & operator=(aa10li &&) noexcept = default;
101  ~aa10li() noexcept = default;
102 
104  using base_t::base_t;
106 
107 protected:
110  {
111  'A',
112  'B',
113  'C',
114  'F',
115  'G',
116  'H',
117  'I',
118  'J',
119  'K',
120  'P',
121  };
122 
125  {
126  [] () constexpr
127  {
129 
130  // initialize with UNKNOWN (std::array::fill unfortunately not constexpr)
131  for (auto & c : ret)
132  c = 0; // value of 'A', because S appears most frequently and gets converted to A in this alphabet
133 
134  // reverse mapping for characters and their lowercase
135  for (rank_type rnk = 0u; rnk < alphabet_size; ++rnk)
136  {
137  ret[static_cast<rank_type>( rank_to_char[rnk]) ] = rnk;
138  ret[static_cast<rank_type>(to_lower(rank_to_char[rnk]))] = rnk;
139  }
140 
141  ret['D'] = ret['B']; ret['d'] = ret['B']; // Convert D to B (either D/N).
142  ret['E'] = ret['B']; ret['e'] = ret['B']; // Convert E to B (either D/N).
143  ret['L'] = ret['J']; ret['l'] = ret['J']; // Convert L to J (either I/L).
144  ret['M'] = ret['J']; ret['m'] = ret['J']; // Convert M to J (either I/L).
145  ret['N'] = ret['H']; ret['n'] = ret['H']; // Convert N to H.
146  ret['O'] = ret['K']; ret['o'] = ret['K']; // Convert Pyrrolysine to K.
147  ret['Q'] = ret['B']; ret['q'] = ret['B']; // Convert Q to B (either D/N).
148  ret['R'] = ret['K']; ret['r'] = ret['K']; // Convert R to K.
149  ret['S'] = ret['A']; ret['s'] = ret['A']; // Convert S to A.
150  ret['T'] = ret['A']; ret['t'] = ret['A']; // Convert T to A.
151  ret['U'] = ret['C']; ret['u'] = ret['C']; // Convert Selenocysteine to C.
152  ret['V'] = ret['I']; ret['v'] = ret['I']; // Convert V to I.
153  ret['W'] = ret['F']; ret['w'] = ret['F']; // Convert W to F.
154  ret['X'] = ret['A']; ret['x'] = ret['A']; // Convert unknown amino acids to Alanine.
155  ret['Y'] = ret['F']; ret['y'] = ret['F']; // Convert Y to F.
156  ret['Z'] = ret['B']; ret['z'] = ret['B']; // Convert Z (either E/Q) to B (either D/N).
157  ret['*'] = ret['F']; // The most common stop codon is UGA. This is most similar to a Tryptophan which in this alphabet gets converted to Phenylalanine.
158  return ret;
159  }()
160  };
161 };
162 
163 // ------------------------------------------------------------------
164 // containers
165 // ------------------------------------------------------------------
166 
170 
171 // ------------------------------------------------------------------
172 // literals
173 // ------------------------------------------------------------------
174 
184 constexpr aa10li operator""_aa10li(char const c) noexcept
185 {
186  return aa10li{}.assign_char(c);
187 }
188 
201 inline aa10li_vector operator""_aa10li(char const * const s, size_t const n)
202 {
203  aa10li_vector r;
204  r.resize(n);
205 
206  for (size_t i = 0; i < n; ++i)
207  r[i].assign_char(s[i]);
208 
209  return r;
210 }
212 
213 } // namespace seqan3
std::vector::resize
T resize(T... args)
concept.hpp
Provides seqan3::aminoacid_alphabet.
seqan3::alphabet_base< aa10li, size, char >::alphabet_size
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:176
vector
seqan3::alphabet_base< aa10li, size, char >
aminoacid_base.hpp
Provides seqan3::aminoacid_base.
seqan3::alphabet_base::assign_char
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:142
seqan3::alphabet_base< aa10li, size, char >::rank_type
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:64
std::array< rank_type, 256 >
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
seqan3::aa10li::aa10li
constexpr aa10li() noexcept=default
Defaulted.
transform.hpp
Provides utilities for modifying characters.
seqan3::aa10li::char_to_rank
static constexpr std::array< rank_type, 256 > char_to_rank
Char to value conversion table.
Definition: aa10li.hpp:125
seqan3::aminoacid_base
A CRTP-base that refines seqan3::alphabet_base and is used by the amino acids.
Definition: aminoacid_base.hpp:30
seqan3::to_lower
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:81
std::conditional_t
seqan3::aa10li::rank_to_char
static constexpr char_type rank_to_char[alphabet_size]
Value to char conversion table.
Definition: aa10li.hpp:110
seqan3::aa10li
The reduced Li amino acid alphabet.
Definition: aa10li.hpp:81