cuSBF
Loading...
Searching...
No Matches
Static Public Member Functions | Static Public Attributes | List of all members
cusbf::DnaAlphabet Struct Reference

An alphabet for encoding DNA sequences, consisting of the symbols A, C, G, and T. More...

Static Public Member Functions

constexpr __host__ __device__ static __forceinline__ uint8_t encode (const char *input)
 Maps one byte to a 2-bit symbol index, or invalidSymbol.
 

Static Public Attributes

static constexpr uint64_t symbolWidth = 1
 Input bytes per encoded symbol.
 
static constexpr uint64_t symbolCount = 4
 Number of valid symbols (A, C, G, T).
 
static constexpr uint8_t invalidSymbol = 0xFFu
 Sentinel returned by encode for invalid input bytes.
 
static constexpr uint8_t separator = 'N'
 Byte value used between concatenated records (must not encode as a valid symbol).
 
static constexpr char validBytes [] = "ACGT"
 Representative valid bytes for compile-time separator checks.
 

Detailed Description

An alphabet for encoding DNA sequences, consisting of the symbols A, C, G, and T.

Each symbol is encoded as a 2-bit value: A=0, C=1, T=2, G=3. Invalid bytes are encoded as 0xFF.

Definition at line 113 of file Alphabet.cuh.

Member Function Documentation

◆ encode()

constexpr __host__ __device__ static __forceinline__ uint8_t cusbf::DnaAlphabet::encode ( const char *  input)
inlinestaticconstexpr

Maps one byte to a 2-bit symbol index, or invalidSymbol.

Accepts A/C/G/T in either case.

Parameters
inputPointer to one raw byte.

Definition at line 132 of file Alphabet.cuh.

134 {
135 const auto byte = static_cast<uint8_t>(input[0]);
136 const uint8_t upper = byte & 0xDFu; // force upper for validation only
137 const uint8_t x = (byte >> 1u) & 3u; // A=0, C=1, T=2, G=3
138 const uint8_t valid = (upper == 'A') | (upper == 'C') | (upper == 'G') | (upper == 'T');
139 const uint8_t mask = -valid;
140 return (x & mask) | (invalidSymbol & ~mask);
141 }
static constexpr uint8_t invalidSymbol
Sentinel returned by encode for invalid input bytes.
Definition Alphabet.cuh:119
Here is the caller graph for this function:

Member Data Documentation

◆ invalidSymbol

constexpr uint8_t cusbf::DnaAlphabet::invalidSymbol = 0xFFu
staticconstexpr

Sentinel returned by encode for invalid input bytes.

Definition at line 119 of file Alphabet.cuh.

◆ separator

constexpr uint8_t cusbf::DnaAlphabet::separator = 'N'
staticconstexpr

Byte value used between concatenated records (must not encode as a valid symbol).

Definition at line 121 of file Alphabet.cuh.

◆ symbolCount

constexpr uint64_t cusbf::DnaAlphabet::symbolCount = 4
staticconstexpr

Number of valid symbols (A, C, G, T).

Definition at line 117 of file Alphabet.cuh.

◆ symbolWidth

constexpr uint64_t cusbf::DnaAlphabet::symbolWidth = 1
staticconstexpr

Input bytes per encoded symbol.

Definition at line 115 of file Alphabet.cuh.

◆ validBytes

constexpr char cusbf::DnaAlphabet::validBytes[] = "ACGT"
staticconstexpr

Representative valid bytes for compile-time separator checks.

Definition at line 123 of file Alphabet.cuh.


The documentation for this struct was generated from the following file: