A library for working with phylogenetic and population genetic data.
v0.27.0
codes.cpp File Reference
#include "genesis/sequence/functions/codes.hpp"
#include "genesis/utils/text/char.hpp"
#include "genesis/utils/text/string.hpp"
#include "genesis/utils/tools/color.hpp"
#include <algorithm>
#include <cassert>
#include <cctype>
#include <stdexcept>
#include <unordered_map>

Go to the source code of this file.

Namespaces

 genesis
 Container namespace for all symbols of genesis in order to keep them separate when used as a library.
 
 genesis::sequence
 

Functions

std::string amino_acid_codes_all ()
 Return all valid amino acid codes, and .. Those are ACDEFGHIKLMNOPQRSTUVWYBJZX*-?.. More...
 
std::string amino_acid_codes_degenerated ()
 Return all degenerated amino acid codes. Those are BJZ. More...
 
std::string amino_acid_codes_plain ()
 Return all plain amino acid codes. Those are ACDEFGHIKLMNOPQRSTUVWY. More...
 
std::string amino_acid_codes_undetermined ()
 Return all undetermined amino acid codes, and .. Those are X*-?.. More...
 
std::map< char, utils::Color > amino_acid_colors ()
 Return a map of Colors for each amino acid code. More...
 
std::string amino_acid_name (char code)
 Get the name of a amino acid given its IUPAC code. More...
 
std::map< char, std::string > amino_acid_text_colors ()
 Return a map of text colors for each amino acid code. More...
 
char normalize_amino_acid_code (char code, bool accept_degenerated=true)
 Normalize an amino acid code. More...
 
std::string normalize_code_alphabet (std::string const &alphabet)
 Normalize an alphabet set of Sequence codes, i.e., make them upper case, sort them, and remove duplicates. More...
 
char normalize_nucleic_acid_code (char code, bool accept_degenerated=true)
 Normalize a nucleic acide code. More...
 
std::string nucleic_acid_ambiguities (char code)
 Return the possible ambiguous nucleic acid codes for a given code char. More...
 
char nucleic_acid_ambiguity_code (std::string codes)
 Return the nucleic acid code that represents all given codes. More...
 
bool nucleic_acid_code_containment (char a, char b, bool undetermined_matches_all=true)
 Compare two nucleic acid codes and check if they are equal, taking degenerated/ambiguous characters into account. More...
 
std::string nucleic_acid_codes_all ()
 Return all valid nucleic acid codes. Those are ACGTUWSMKRYBDHVNOX.-?. More...
 
std::string nucleic_acid_codes_all_letters ()
 Return all valid nucleic acid codes. Those are ACGTUWSMKRYBDHVNOX, that is, excluding .-? as compared to nucleic_acid_codes_all(). More...
 
std::string nucleic_acid_codes_degenerated ()
 Return all degenerated nucleic acid codes. Those are WSMKRYBDHV. More...
 
std::string nucleic_acid_codes_plain ()
 Return all plain nucleic acid codes. Those are ACGTU. More...
 
std::string nucleic_acid_codes_undetermined ()
 Return all undetermined nucleic acid codes. Those are NOX.-?. More...
 
std::string nucleic_acid_codes_undetermined_letters ()
 Return all undetermined nucleic acid codes that are letters. Those are NOX, that is, excluding .-? as compared to nucleic_acid_codes_undetermined(). More...
 
std::map< char, utils::Color > nucleic_acid_colors ()
 Return a map of Colors for each nucleic acid code. More...
 
std::string nucleic_acid_name (char code)
 Get the name of a nucleic acid given its IUPAC code. More...
 
std::map< char, std::string > nucleic_acid_text_colors ()
 Return a map of text colors for each nucleic acid code. More...
 
std::string reverse_complement (std::string const &sequence, bool accept_degenerated=true)
 Get the reverse complement of a nucleic acid sequence. More...
 

Variables

static const std::unordered_map< char, std::string > amino_acid_code_to_name
 
static const std::map< char, utils::Color > amino_acid_colors_map
 
static const std::map< char, std::string > amino_acid_text_colors_map
 
static const std::unordered_map< char, std::string > nucleic_acid_ambiguity_char_map
 
static const std::unordered_map< std::string, char > nucleic_acid_ambiguity_string_map
 
static const std::unordered_map< char, std::string > nucleic_acid_code_to_name
 
static const std::map< char, utils::Color > nucleic_acid_colors_map
 
static const std::map< char, std::string > nucleic_acid_text_colors_map