A library for working with phylogenetic and population genetic data.
v0.27.0
codes.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2022 Lucas Czech
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18  Contact:
19  Lucas Czech <lczech@carnegiescience.edu>
20  Department of Plant Biology, Carnegie Institution For Science
21  260 Panama Street, Stanford, CA 94305, USA
22 */
23 
32 
36 
37 #include <algorithm>
38 #include <cassert>
39 #include <cctype>
40 #include <stdexcept>
41 #include <unordered_map>
42 
43 namespace genesis {
44 namespace sequence {
45 
46 // =================================================================================================
47 // Name Lists
48 // =================================================================================================
49 
50 static const std::unordered_map<char, std::string> nucleic_acid_code_to_name = {
51  { 'A', "Adenine" },
52  { 'C', "Cytosine" },
53  { 'G', "Guanine" },
54  { 'T', "Thymine" },
55  { 'U', "Uracil" },
56 
57  { 'W', "Weak" },
58  { 'S', "Strong" },
59  { 'M', "aMino" },
60  { 'K', "Keto" },
61  { 'R', "puRine" },
62  { 'Y', "pYrimidine" },
63 
64  { 'B', "not A" },
65  { 'D', "not C" },
66  { 'H', "not G" },
67  { 'V', "not T" },
68 
69  { 'N', "any" },
70  { 'O', "omitted" },
71  { 'X', "masked" },
72  { '.', "gap" },
73  { '-', "gap" },
74  { '?', "gap" }
75 };
76 
77 static const std::unordered_map<char, std::string> amino_acid_code_to_name = {
78  { 'A', "Alanine" },
79  { 'B', "Aspartic acid or Asparagine" },
80  { 'C', "Cysteine" },
81  { 'D', "Aspartic acid" },
82  { 'E', "Glutamic acid" },
83  { 'F', "Phenylalanine" },
84  { 'G', "Glycine" },
85  { 'H', "Histidine" },
86  { 'I', "Isoleucine" },
87  { 'J', "Leucine or Isoleucine" },
88  { 'K', "Lysine" },
89  { 'L', "Leucine" },
90  { 'M', "Methionine" },
91  { 'N', "Asparagine" },
92  { 'O', "Pyrrolysine" },
93  { 'P', "Proline" },
94  { 'Q', "Glutamine" },
95  { 'R', "Arginine" },
96  { 'S', "Serine" },
97  { 'T', "Threonine" },
98  { 'U', "Selenocysteine" },
99  { 'V', "Valine" },
100  { 'W', "Tryptophan" },
101  { 'Y', "Tyrosine" },
102  { 'Z', "Glutamic acid or Glutamine" },
103 
104  { 'X', "any" },
105  { '*', "translation stop" },
106  { '-', "gap" },
107  { '?', "gap" }
108 };
109 
110 // =================================================================================================
111 // Color Lists
112 // =================================================================================================
113 
114 static const std::map<char, std::string> nucleic_acid_text_colors_map = {
115  { 'A', "Red" },
116  { 'C', "Green" },
117  { 'G', "Yellow" },
118  { 'T', "Blue" },
119  { 'U', "Blue" },
120 
121  { 'W', "DarkGray" },
122  { 'S', "DarkGray" },
123  { 'M', "DarkGray" },
124  { 'K', "DarkGray" },
125  { 'R', "DarkGray" },
126  { 'Y', "DarkGray" },
127 
128  { 'B', "DarkGray" },
129  { 'D', "DarkGray" },
130  { 'H', "DarkGray" },
131  { 'V', "DarkGray" },
132 
133  { 'N', "DarkGray" },
134  { 'O', "DarkGray" },
135  { 'X', "DarkGray" },
136  { '.', "DarkGray" },
137  { '-', "DarkGray" },
138  { '?', "DarkGray" }
139 };
140 
141 static const std::map<char, std::string> amino_acid_text_colors_map = {
142  { 'A', "Blue" },
143  { 'B', "DarkGray" },
144  { 'C', "LightMagenta" },
145  { 'D', "Magenta" },
146  { 'E', "Magenta" },
147  { 'F', "Blue" },
148  { 'G', "LightRed" },
149  { 'H', "Cyan" },
150  { 'I', "Blue" },
151  { 'J', "DarkGray" },
152  { 'K', "Red" },
153  { 'L', "Blue" },
154  { 'M', "Blue" },
155  { 'N', "Green" },
156  { 'O', "DarkGray" },
157  { 'P', "Yellow" },
158  { 'Q', "Green" },
159  { 'R', "Red" },
160  { 'S', "Green" },
161  { 'T', "Green" },
162  { 'U', "DarkGray" },
163  { 'V', "Blue" },
164  { 'W', "Blue" },
165  { 'Y', "Cyan" },
166  { 'Z', "DarkGray" },
167 
168  { 'X', "DarkGray" },
169  { '*', "DarkGray" },
170  { '-', "DarkGray" },
171  { '?', "DarkGray" }
172 };
173 
174 static const std::map<char, utils::Color> nucleic_acid_colors_map = {
175  { 'A', { 1.0, 0.0, 0.0 } },
176  { 'C', { 0.0, 1.0, 0.0 } },
177  { 'G', { 1.0, 1.0, 0.0 } },
178  { 'T', { 0.0, 0.0, 1.0 } },
179  { 'U', { 0.0, 0.0, 1.0 } },
180 
181  { 'W', { 0.376, 0.376, 0.376 } },
182  { 'S', { 0.376, 0.376, 0.376 } },
183  { 'M', { 0.376, 0.376, 0.376 } },
184  { 'K', { 0.376, 0.376, 0.376 } },
185  { 'R', { 0.376, 0.376, 0.376 } },
186  { 'Y', { 0.376, 0.376, 0.376 } },
187 
188  { 'B', { 0.5, 0.5, 0.5 } },
189  { 'D', { 0.5, 0.5, 0.5 } },
190  { 'H', { 0.5, 0.5, 0.5 } },
191  { 'V', { 0.5, 0.5, 0.5 } },
192 
193  { 'N', { 0.5, 0.5, 0.5 } },
194  { 'O', { 0.5, 0.5, 0.5 } },
195  { 'X', { 0.5, 0.5, 0.5 } },
196  { '.', { 0.5, 0.5, 0.5 } },
197  { '-', { 0.5, 0.5, 0.5 } },
198  { '?', { 0.5, 0.5, 0.5 } }
199 };
200 
201 static const std::map<char, utils::Color> amino_acid_colors_map = {
202  { 'A', { 0.098, 0.500, 1.000 } },
203  { 'B', { 0.376, 0.376, 0.376 } },
204  { 'C', { 0.902, 0.500, 0.500 } },
205  { 'D', { 0.800, 0.302, 0.800 } },
206  { 'E', { 0.800, 0.302, 0.800 } },
207  { 'F', { 0.098, 0.500, 1.000 } },
208  { 'G', { 0.902, 0.600, 0.302 } },
209  { 'H', { 0.098, 0.702, 0.702 } },
210  { 'I', { 0.098, 0.500, 1.000 } },
211  { 'J', { 0.376, 0.376, 0.376 } },
212  { 'K', { 0.902, 0.200, 0.098 } },
213  { 'L', { 0.098, 0.500, 1.000 } },
214  { 'M', { 0.098, 0.500, 1.000 } },
215  { 'N', { 0.098, 0.800, 0.098 } },
216  { 'O', { 0.376, 0.376, 0.376 } },
217  { 'P', { 0.800, 0.800, 0.000 } },
218  { 'Q', { 0.098, 0.800, 0.098 } },
219  { 'R', { 0.902, 0.200, 0.098 } },
220  { 'S', { 0.098, 0.800, 0.098 } },
221  { 'T', { 0.098, 0.800, 0.098 } },
222  { 'U', { 0.376, 0.376, 0.376 } },
223  { 'V', { 0.098, 0.500, 1.000 } },
224  { 'W', { 0.098, 0.500, 1.000 } },
225  { 'Y', { 0.098, 0.702, 0.702 } },
226  { 'Z', { 0.376, 0.376, 0.376 } },
227 
228  { 'X', { 0.5, 0.5, 0.5 } },
229  { '*', { 0.5, 0.5, 0.5 } },
230  { '-', { 0.5, 0.5, 0.5 } },
231  { '?', { 0.5, 0.5, 0.5 } }
232 };
233 
234 // =================================================================================================
235 // Ambiguity Lists
236 // =================================================================================================
237 
238 static const std::unordered_map<char, std::string> nucleic_acid_ambiguity_char_map = {
239  { 'A', "A" },
240  { 'C', "C" },
241  { 'G', "G" },
242  { 'T', "T" },
243  { 'U', "T" },
244 
245  { 'W', "AT" },
246  { 'S', "CG" },
247  { 'M', "AC" },
248  { 'K', "GT" },
249  { 'R', "AG" },
250  { 'Y', "CT" },
251 
252  { 'B', "CGT" },
253  { 'D', "AGT" },
254  { 'H', "ACT" },
255  { 'V', "ACG" },
256 
257  { 'N', "ACGT" },
258  { 'O', "-" },
259  { 'X', "-" },
260  { '.', "-" },
261  { '-', "-" },
262  { '?', "-" }
263 };
264 
265 static const std::unordered_map< std::string, char > nucleic_acid_ambiguity_string_map = {
266  { "A", 'A' },
267  { "C", 'C' },
268  { "G", 'G' },
269  { "T", 'T' },
270 
271  { "AT", 'W' },
272  { "CG", 'S' },
273  { "AC", 'M' },
274  { "GT", 'K' },
275  { "AG", 'R' },
276  { "CT", 'Y' },
277 
278  { "CGT", 'B' },
279  { "AGT", 'D' },
280  { "ACT", 'H' },
281  { "ACG", 'V' },
282 
283  { "ACGT", 'N' },
284  { "-", '-' }
285 };
286 
287 // =================================================================================================
288 // Codes
289 // =================================================================================================
290 
291 // ---------------------------------------------------------------------
292 // Nucleic Acids
293 // ---------------------------------------------------------------------
294 
296 {
297  return "ACGT";
298 }
299 
301 {
302  return "WSMKRYBDHV";
303 }
304 
306 {
307  return "NOX.-?";
308 }
309 
311 {
312  return "NOX";
313 }
314 
316 {
317  return nucleic_acid_codes_plain()
320 }
321 
323 {
324  return nucleic_acid_codes_plain()
327 }
328 
329 // ---------------------------------------------------------------------
330 // Amino Acids
331 // ---------------------------------------------------------------------
332 
334 {
335  return "ACDEFGHIKLMNOPQRSTUVWY";
336 }
337 
339 {
340  return "BJZ";
341 }
342 
344 {
345  return "X*-?.";
346 }
347 
348 std::string amino_acid_codes_all()
349 {
350  return amino_acid_codes_plain()
353 }
354 
355 // ---------------------------------------------------------------------
356 // Misc
357 // ---------------------------------------------------------------------
358 
359 std::string normalize_code_alphabet( std::string const& alphabet )
360 {
361  // Uppercase, sort, uniq the alphabet.
362  auto normalized = utils::to_upper( alphabet );
363  std::sort( normalized.begin(), normalized.end() );
364  normalized.erase( std::unique( normalized.begin(), normalized.end() ), normalized.end() );
365  return normalized;
366 }
367 
368 char normalize_nucleic_acid_code( char code, bool accept_degenerated )
369 {
370  switch( code ) {
371  case 'u':
372  case 'U':
373  case 't':
374  case 'T':
375  return 'T';
376  case 'a':
377  case 'A':
378  return 'A';
379  case 'c':
380  case 'C':
381  return 'C';
382  case 'g':
383  case 'G':
384  return 'G';
385  case 'w':
386  case 'W':
387  case 's':
388  case 'S':
389  case 'm':
390  case 'M':
391  case 'k':
392  case 'K':
393  case 'r':
394  case 'R':
395  case 'y':
396  case 'Y':
397  case 'b':
398  case 'B':
399  case 'd':
400  case 'D':
401  case 'h':
402  case 'H':
403  case 'v':
404  case 'V':
405  if( accept_degenerated ) {
406  return utils::to_upper( code );
407  } else {
408  throw std::invalid_argument(
409  "Degenerated nucleic acid code not accepted: " + std::string( 1, code )
410  );
411  }
412  case 'n':
413  case 'N':
414  case 'o':
415  case 'O':
416  case 'x':
417  case 'X':
418  case '.':
419  case '-':
420  case '?':
421  return '-';
422  default:
423  throw std::invalid_argument( "Not a nucleic acid code: " + std::string( 1, code ) );
424  }
425 }
426 
427 char normalize_amino_acid_code( char code, bool accept_degenerated )
428 {
429  switch( code ) {
430  case 'A':
431  case 'C':
432  case 'D':
433  case 'E':
434  case 'F':
435  case 'G':
436  case 'H':
437  case 'I':
438  case 'K':
439  case 'L':
440  case 'M':
441  case 'N':
442  case 'O':
443  case 'P':
444  case 'Q':
445  case 'R':
446  case 'S':
447  case 'T':
448  case 'U':
449  case 'V':
450  case 'W':
451  case 'Y':
452  return code;
453  case 'a':
454  case 'c':
455  case 'd':
456  case 'e':
457  case 'f':
458  case 'g':
459  case 'h':
460  case 'i':
461  case 'k':
462  case 'l':
463  case 'm':
464  case 'n':
465  case 'o':
466  case 'p':
467  case 'q':
468  case 'r':
469  case 's':
470  case 't':
471  case 'u':
472  case 'v':
473  case 'w':
474  case 'y':
475  return utils::to_upper( code );
476  case 'B':
477  case 'J':
478  case 'Z':
479  case 'b':
480  case 'j':
481  case 'z':
482  if( accept_degenerated ) {
483  return utils::to_upper( code );
484  } else {
485  throw std::invalid_argument(
486  "Degenerated amino acid code not accepted: " + std::string( 1, code )
487  );
488  }
489  case 'X':
490  case 'x':
491  case '*':
492  case '-':
493  case '?':
494  case '.':
495  return '-';
496  default:
497  throw std::invalid_argument( "Not an amino acid code: " + std::string( 1, code ) );
498  }
499 }
500 
501 std::string reverse_complement( std::string const& sequence, bool accept_degenerated )
502 {
503  // Dummy result string.
504  auto result = std::string( sequence.size(), '-' );
505 
506  // Get rev comp char. We only need to check upper case as we normalized before.
507  auto rev_comp = []( char c ){
508  switch( c ) {
509  case 'A':
510  return 'T';
511  case 'C':
512  return 'G';
513  case 'G':
514  return 'C';
515  case 'T':
516  return 'A';
517 
518  case 'W':
519  return 'W';
520  case 'S':
521  return 'S';
522  case 'M':
523  return 'K';
524  case 'K':
525  return 'M';
526  case 'R':
527  return 'Y';
528  case 'Y':
529  return 'R';
530 
531  case 'B':
532  return 'V';
533  case 'D':
534  return 'H';
535  case 'H':
536  return 'D';
537  case 'V':
538  return 'B';
539 
540  default:
541  // We already checked for invalid chars in the normalize function.
542  // Just do this to be safe.
543  assert( false );
544  throw std::invalid_argument( "Not a nucleic acid code: " + std::string( 1, c ) );
545  }
546  };
547 
548  // Stupid and simple.
549  for( size_t i = 0; i < sequence.size(); ++i ) {
550  char c = sequence[i];
551 
552  // Slighly hacky: the normalize function turns 'N' into '-'.
553  // We don't want that here, so we have to treat that special case.
554  if( c == 'n' || c == 'N' ) {
555  if( accept_degenerated ) {
556  result[ sequence.size() - i - 1 ] = 'N';
557  continue;
558  } else {
559  throw std::invalid_argument(
560  "Degenerated nucleic acid code not accepted: " + std::string( 1, c )
561  );
562  }
563  }
564 
565  // First normalize, then reverse. Slighly inefficition, but saves code duplication.
566  c = normalize_nucleic_acid_code( c, accept_degenerated );
567  result[ sequence.size() - i - 1 ] = rev_comp( c );
568  }
569  return result;
570 }
571 
572 bool nucleic_acid_code_containment( char a, char b, bool undetermined_matches_all )
573 {
574  // This is slightly bad, because we are not actually encoding binary,
575  // but using hex here (for simplicity of writing...). Should still work as expected.
576  auto binary_code_ = [ undetermined_matches_all ]( char c ){
577  switch( c ) {
578  case 'A':
579  return 0x0001;
580  case 'C':
581  return 0x0010;
582  case 'G':
583  return 0x0100;
584  case 'T':
585  return 0x1000;
586 
587  case 'W':
588  return 0x1001;
589  case 'S':
590  return 0x0110;
591  case 'M':
592  return 0x0011;
593  case 'K':
594  return 0x1100;
595  case 'R':
596  return 0x0101;
597  case 'Y':
598  return 0x1010;
599 
600  case 'B':
601  return 0x1110;
602  case 'D':
603  return 0x1101;
604  case 'H':
605  return 0x1011;
606  case 'V':
607  return 0x0111;
608 
609  case '-': {
610  if( undetermined_matches_all ) {
611  return 0x1111;
612  } else {
613  return 0x0000;
614  }
615  }
616 
617  default:
618  // We already checked for invalid chars in the normalize function.
619  // Just do this to be safe.
620  assert( false );
621  throw std::invalid_argument( "Not a nucleic acid code: " + std::string( 1, c ) );
622  }
623  };
624 
625  auto const an = normalize_nucleic_acid_code( a, true );
626  auto const bn = normalize_nucleic_acid_code( b, true );
627 
628  auto const ab = binary_code_( an );
629  auto const bb = binary_code_( bn );
630 
631  return ( ab & bb ) > 0;
632 }
633 
634 // =================================================================================================
635 // Color Codes
636 // =================================================================================================
637 
638 std::map<char, std::string> nucleic_acid_text_colors()
639 {
641 }
642 
643 std::map<char, std::string> amino_acid_text_colors()
644 {
646 }
647 
648 std::map<char, utils::Color> nucleic_acid_colors()
649 {
651 }
652 
653 std::map<char, utils::Color> amino_acid_colors()
654 {
655  return amino_acid_colors_map;
656 }
657 
658 // =================================================================================================
659 // Translate Codes
660 // =================================================================================================
661 
662 std::string nucleic_acid_name( char code )
663 {
664  auto ucode = toupper(code);
665  if( nucleic_acid_code_to_name.count( ucode ) == 0 ) {
666  throw std::out_of_range( "Invalid nucleic acid code '" + std::string( 1, code ) + "'." );
667  }
668  return nucleic_acid_code_to_name.at( ucode );
669 }
670 
671 std::string amino_acid_name( char code )
672 {
673  auto ucode = toupper(code);
674  if( amino_acid_code_to_name.count( ucode ) == 0 ) {
675  throw std::out_of_range( "Invalid amino acid code '" + std::string( 1, code ) + "'." );
676  }
677  return amino_acid_code_to_name.at( ucode );
678 }
679 
680 std::string nucleic_acid_ambiguities( char code )
681 {
682  auto ucode = toupper(code);
683  if( nucleic_acid_code_to_name.count( ucode ) == 0 ) {
684  throw std::out_of_range( "Invalid nucleic acid code '" + std::string( 1, code ) + "'." );
685  }
686  return nucleic_acid_ambiguity_char_map.at( ucode );
687 }
688 
689 char nucleic_acid_ambiguity_code( std::string codes )
690 {
691  // Uppercase, sort, uniq the codes.
692  auto tmp = utils::to_upper( codes );
693  std::sort( tmp.begin(), tmp.end() );
694  tmp.erase( std::unique( tmp.begin(), tmp.end() ), tmp.end() );
695 
696  if( nucleic_acid_ambiguity_string_map.count( tmp ) == 0 ) {
697  throw std::out_of_range( "Invalid nucleic acid codes '" + codes + "'." );
698  }
699  return nucleic_acid_ambiguity_string_map.at( tmp );
700 }
701 
702 } // namespace sequence
703 } // namespace genesis
genesis::sequence::amino_acid_codes_undetermined
std::string amino_acid_codes_undetermined()
Return all undetermined amino acid codes, and .. Those are X*-?..
Definition: codes.cpp:343
genesis::sequence::nucleic_acid_codes_degenerated
std::string nucleic_acid_codes_degenerated()
Return all degenerated nucleic acid codes. Those are WSMKRYBDHV.
Definition: codes.cpp:300
genesis::sequence::nucleic_acid_code_containment
bool nucleic_acid_code_containment(char a, char b, bool undetermined_matches_all)
Compare two nucleic acid codes and check if they are equal, taking degenerated/ambiguous characters i...
Definition: codes.cpp:572
genesis::sequence::nucleic_acid_codes_plain
std::string nucleic_acid_codes_plain()
Return all plain nucleic acid codes. Those are ACGTU.
Definition: codes.cpp:295
genesis::sequence::nucleic_acid_codes_undetermined_letters
std::string nucleic_acid_codes_undetermined_letters()
Return all undetermined nucleic acid codes that are letters. Those are NOX, that is,...
Definition: codes.cpp:310
genesis::sequence::nucleic_acid_ambiguity_code
char nucleic_acid_ambiguity_code(std::string codes)
Return the nucleic acid code that represents all given codes.
Definition: codes.cpp:689
genesis::sequence::amino_acid_codes_degenerated
std::string amino_acid_codes_degenerated()
Return all degenerated amino acid codes. Those are BJZ.
Definition: codes.cpp:338
genesis::sequence::amino_acid_code_to_name
static const std::unordered_map< char, std::string > amino_acid_code_to_name
Definition: codes.cpp:77
genesis::utils::to_upper
constexpr char to_upper(char c) noexcept
Return the upper case version of a letter, ASCII-only.
Definition: char.hpp:230
string.hpp
Provides some commonly used string utility functions.
genesis::sequence::normalize_code_alphabet
std::string normalize_code_alphabet(std::string const &alphabet)
Normalize an alphabet set of Sequence codes, i.e., make them upper case, sort them,...
Definition: codes.cpp:359
genesis::sequence::amino_acid_text_colors_map
static const std::map< char, std::string > amino_acid_text_colors_map
Definition: codes.cpp:141
genesis::sequence::nucleic_acid_colors_map
static const std::map< char, utils::Color > nucleic_acid_colors_map
Definition: codes.cpp:174
genesis::sequence::normalize_nucleic_acid_code
char normalize_nucleic_acid_code(char code, bool accept_degenerated)
Normalize a nucleic acide code.
Definition: codes.cpp:368
genesis::sequence::nucleic_acid_ambiguity_char_map
static const std::unordered_map< char, std::string > nucleic_acid_ambiguity_char_map
Definition: codes.cpp:238
genesis::sequence::nucleic_acid_codes_undetermined
std::string nucleic_acid_codes_undetermined()
Return all undetermined nucleic acid codes. Those are NOX.-?.
Definition: codes.cpp:305
genesis::sequence::amino_acid_colors_map
static const std::map< char, utils::Color > amino_acid_colors_map
Definition: codes.cpp:201
genesis
Container namespace for all symbols of genesis in order to keep them separate when used as a library.
Definition: placement/formats/edge_color.cpp:42
genesis::sequence::nucleic_acid_codes_all_letters
std::string nucleic_acid_codes_all_letters()
Return all valid nucleic acid codes. Those are ACGTUWSMKRYBDHVNOX, that is, excluding ....
Definition: codes.cpp:322
char.hpp
genesis::sequence::nucleic_acid_text_colors
std::map< char, std::string > nucleic_acid_text_colors()
Return a map of text colors for each nucleic acid code.
Definition: codes.cpp:638
color.hpp
Header of Color class.
genesis::sequence::nucleic_acid_ambiguities
std::string nucleic_acid_ambiguities(char code)
Return the possible ambiguous nucleic acid codes for a given code char.
Definition: codes.cpp:680
genesis::sequence::nucleic_acid_ambiguity_string_map
static const std::unordered_map< std::string, char > nucleic_acid_ambiguity_string_map
Definition: codes.cpp:265
genesis::sequence::reverse_complement
std::string reverse_complement(std::string const &sequence, bool accept_degenerated)
Get the reverse complement of a nucleic acid sequence.
Definition: codes.cpp:501
genesis::sequence::amino_acid_name
std::string amino_acid_name(char code)
Get the name of a amino acid given its IUPAC code.
Definition: codes.cpp:671
genesis::sequence::normalize_amino_acid_code
char normalize_amino_acid_code(char code, bool accept_degenerated)
Normalize an amino acid code.
Definition: codes.cpp:427
genesis::sequence::amino_acid_codes_all
std::string amino_acid_codes_all()
Return all valid amino acid codes, and .. Those are ACDEFGHIKLMNOPQRSTUVWYBJZX*-?....
Definition: codes.cpp:348
genesis::sequence::nucleic_acid_text_colors_map
static const std::map< char, std::string > nucleic_acid_text_colors_map
Definition: codes.cpp:114
genesis::sequence::nucleic_acid_colors
std::map< char, utils::Color > nucleic_acid_colors()
Return a map of Colors for each nucleic acid code.
Definition: codes.cpp:648
genesis::sequence::amino_acid_text_colors
std::map< char, std::string > amino_acid_text_colors()
Return a map of text colors for each amino acid code.
Definition: codes.cpp:643
genesis::sequence::nucleic_acid_codes_all
std::string nucleic_acid_codes_all()
Return all valid nucleic acid codes. Those are ACGTUWSMKRYBDHVNOX.-?.
Definition: codes.cpp:315
genesis::sequence::amino_acid_codes_plain
std::string amino_acid_codes_plain()
Return all plain amino acid codes. Those are ACDEFGHIKLMNOPQRSTUVWY.
Definition: codes.cpp:333
genesis::sequence::nucleic_acid_name
std::string nucleic_acid_name(char code)
Get the name of a nucleic acid given its IUPAC code.
Definition: codes.cpp:662
codes.hpp
genesis::sequence::amino_acid_colors
std::map< char, utils::Color > amino_acid_colors()
Return a map of Colors for each amino acid code.
Definition: codes.cpp:653
genesis::sequence::nucleic_acid_code_to_name
static const std::unordered_map< char, std::string > nucleic_acid_code_to_name
Definition: codes.cpp:50