A library for working with phylogenetic and population genetic data.
v0.32.0
codes.cpp
Go to the documentation of this file.
1 /*
2  Genesis - A toolkit for working with phylogenetic data.
3  Copyright (C) 2014-2023 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 char nucleic_acid_transition( char code )
573 {
574  switch( code ) {
575  case 'a':
576  case 'A':
577  return 'G';
578  case 'c':
579  case 'C':
580  return 'T';
581  case 'g':
582  case 'G':
583  return 'A';
584  case 'u':
585  case 'U':
586  case 't':
587  case 'T':
588  return 'C';
589  default:
590  throw std::invalid_argument(
591  "No transition base for nucleic acid code: " + std::string( 1, code )
592  );
593  }
594 }
595 
596 bool nucleic_acid_code_containment( char a, char b, bool undetermined_matches_all )
597 {
598  // This is slightly bad, because we are not actually encoding binary,
599  // but using hex here (for simplicity of writing...). Should still work as expected.
600  auto binary_code_ = [ undetermined_matches_all ]( char c ){
601  switch( c ) {
602  case 'A':
603  return 0x0001;
604  case 'C':
605  return 0x0010;
606  case 'G':
607  return 0x0100;
608  case 'T':
609  return 0x1000;
610 
611  case 'W':
612  return 0x1001;
613  case 'S':
614  return 0x0110;
615  case 'M':
616  return 0x0011;
617  case 'K':
618  return 0x1100;
619  case 'R':
620  return 0x0101;
621  case 'Y':
622  return 0x1010;
623 
624  case 'B':
625  return 0x1110;
626  case 'D':
627  return 0x1101;
628  case 'H':
629  return 0x1011;
630  case 'V':
631  return 0x0111;
632 
633  case '-': {
634  if( undetermined_matches_all ) {
635  return 0x1111;
636  } else {
637  return 0x0000;
638  }
639  }
640 
641  default:
642  // We already checked for invalid chars in the normalize function.
643  // Just do this to be safe.
644  assert( false );
645  throw std::invalid_argument( "Not a nucleic acid code: " + std::string( 1, c ) );
646  }
647  };
648 
649  auto const an = normalize_nucleic_acid_code( a, true );
650  auto const bn = normalize_nucleic_acid_code( b, true );
651 
652  auto const ab = binary_code_( an );
653  auto const bb = binary_code_( bn );
654 
655  return ( ab & bb ) > 0;
656 }
657 
658 // =================================================================================================
659 // Color Codes
660 // =================================================================================================
661 
662 std::map<char, std::string> nucleic_acid_text_colors()
663 {
665 }
666 
667 std::map<char, std::string> amino_acid_text_colors()
668 {
670 }
671 
672 std::map<char, utils::Color> nucleic_acid_colors()
673 {
675 }
676 
677 std::map<char, utils::Color> amino_acid_colors()
678 {
679  return amino_acid_colors_map;
680 }
681 
682 // =================================================================================================
683 // Translate Codes
684 // =================================================================================================
685 
686 std::string nucleic_acid_name( char code )
687 {
688  auto ucode = toupper(code);
689  if( nucleic_acid_code_to_name.count( ucode ) == 0 ) {
690  throw std::out_of_range( "Invalid nucleic acid code '" + std::string( 1, code ) + "'." );
691  }
692  return nucleic_acid_code_to_name.at( ucode );
693 }
694 
695 std::string amino_acid_name( char code )
696 {
697  auto ucode = toupper(code);
698  if( amino_acid_code_to_name.count( ucode ) == 0 ) {
699  throw std::out_of_range( "Invalid amino acid code '" + std::string( 1, code ) + "'." );
700  }
701  return amino_acid_code_to_name.at( ucode );
702 }
703 
704 std::string nucleic_acid_ambiguities( char code )
705 {
706  auto ucode = toupper(code);
707  if( nucleic_acid_code_to_name.count( ucode ) == 0 ) {
708  throw std::out_of_range( "Invalid nucleic acid code '" + std::string( 1, code ) + "'." );
709  }
710  return nucleic_acid_ambiguity_char_map.at( ucode );
711 }
712 
713 char nucleic_acid_ambiguity_code( std::string codes )
714 {
715  // Uppercase, sort, uniq the codes.
716  auto tmp = utils::to_upper( codes );
717  std::sort( tmp.begin(), tmp.end() );
718  tmp.erase( std::unique( tmp.begin(), tmp.end() ), tmp.end() );
719 
720  if( nucleic_acid_ambiguity_string_map.count( tmp ) == 0 ) {
721  throw std::out_of_range( "Invalid nucleic acid codes '" + codes + "'." );
722  }
723  return nucleic_acid_ambiguity_string_map.at( tmp );
724 }
725 
726 } // namespace sequence
727 } // 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:596
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:713
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::sequence::nucleic_acid_transition
char nucleic_acid_transition(char code)
Return the transition base for the given base.
Definition: codes.cpp:572
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:662
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:704
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:695
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:672
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:667
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:686
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:677
genesis::sequence::nucleic_acid_code_to_name
static const std::unordered_map< char, std::string > nucleic_acid_code_to_name
Definition: codes.cpp:50