31 static inline unsigned char decode(
char symbol)
33 static constexpr
unsigned char bases[25] =
62 return (symbol < 'A' || symbol >=
'Z') ? 0 : bases[symbol -
'A'];
67 static constexpr
int popcount[16] =
69 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4
72 return popcount[decode(a) & decode(b)];
77 return (symbol ==
'T') ?
'U' : (symbol ==
'U') ?
'T' : symbol;
84 constexpr
const char* complements =
"TVGHZZCDZZMZKNZZZYSAABWZR";
85 return (symbol < 'A' || symbol >=
'Z') ?
'Z' : complements[symbol -
'A'];
93 constexpr
const char* complements =
"UVGHZZCDZZMZKNZZZYSAABWZR";
94 return (symbol < 'A' || symbol >=
'Z') ?
'Z' : complements[symbol -
'A'];
char complement(char symbol)
Returns the DNA complement of an IUPAC degenerate base symbol.
char complement(char symbol)
Returns the RNA complement of an IUPAC degenerate base symbol.
int compare(char a, char b)
Returns the number of bases that are represented by both IUPAC degenerate base symbols.
char transcribe(char symbol)
Transcribes an IUPAC degenerate base symbol between DNA and RNA, swapping T for U or U for T.