|
Zip and Skip Tries
|
Defines nucleotide representation and related utility functions. More...
#include <array>#include <cstdint>#include <stdexcept>#include <fstream>

Go to the source code of this file.
Enumerations | |
| enum class | Nucleotide : uint8_t { A = 0 , C = 1 , G = 2 , T = 3 , INVALID } |
| Enumerates the four nucleotides of DNA. More... | |
Functions | |
| bool | is_valid_nucleotide (char nucleotide) |
| Checks if a character represents a valid nucleotide. | |
| std::ostream & | operator<< (std::ostream &os, const Nucleotide &nucleotide) |
| Inserts a textual representation of a nucleotide into an output stream. | |
Variables | |
| static constexpr std::array< Nucleotide, 256 > | char_to_nucleotide |
| Lookup table for converting characters to nucleotides. | |
| static constexpr std::array< char, 4 > | nucleotide_to_char |
| Lookup table for converting nucleotides to characters. | |
Defines nucleotide representation and related utility functions.
This file provides a type-safe representation of DNA nucleotides and utility functions for converting between character and nucleotide formats. It supports case-insensitive conversion and implements streaming operators for convenient output. This is used primarily for genetic sequence processing in the trie data structures.
Definition in file nucleotide.hpp.
|
strong |
Enumerates the four nucleotides of DNA.
This enumeration provides a type-safe way of representing the four nucleotides in DNA: Adenine (A), Cytosine (C), Guanine (G), and Thymine (T). It also includes an INVALID value for error handling.
| Enumerator | |
|---|---|
| A | Adenine. |
| C | Cytosine. |
| G | Guanine. |
| T | Thymine. |
| INVALID | Invalid nucleotide. |
Definition at line 29 of file nucleotide.hpp.
Checks if a character represents a valid nucleotide.
Determines whether the provided character is a valid nucleotide representation (A, C, G, T in either uppercase or lowercase).
| nucleotide | The character to check. |
Definition at line 14 of file nucleotide.cpp.
| std::ostream & operator<< | ( | std::ostream & | os, |
| const Nucleotide & | nucleotide | ||
| ) |
Inserts a textual representation of a nucleotide into an output stream.
Converts the Nucleotide enum value to its character representation and inserts it into the provided output stream. Uses a switch statement to handle each nucleotide type explicitly and throws an std::invalid_argument exception for Nucleotide::INVALID rather than silently outputting a placeholder. This allows Nucleotide objects to be used directly with stream operators.
| os | The output stream to insert into. |
| nucleotide | The nucleotide to insert. |
| std::invalid_argument | if nucleotide is Nucleotide::INVALID. |
Definition at line 21 of file nucleotide.cpp.
|
staticconstexpr |
Lookup table for converting characters to nucleotides.
This constexpr array provides O(1) conversion from ASCII characters to Nucleotide enum values. It supports both uppercase and lowercase letters (A/a, C/c, G/g, T/t) and marks all other characters as INVALID. Using a lookup table avoids branching in critical code paths.
Definition at line 44 of file nucleotide.hpp.
|
staticconstexpr |
Lookup table for converting nucleotides to characters.
This array provides O(1) conversion from Nucleotide enum values to their corresponding ASCII character representation. The array is indexed by the underlying uint8_t value of the Nucleotide enum, so Nucleotide::A (0) maps to 'A', etc. Note that this array doesn't include a mapping for Nucleotide::INVALID.
Definition at line 69 of file nucleotide.hpp.