Browse Source

Fix swapped DNA and RNA base complements

master
C. J. Howard 4 years ago
parent
commit
0694235553
2 changed files with 5 additions and 5 deletions
  1. +2
    -2
      src/game/genetics/base.cpp
  2. +3
    -3
      src/game/genetics/codon.hpp

+ 2
- 2
src/game/genetics/base.cpp View File

@ -81,7 +81,7 @@ namespace dna
{ {
char complement(char symbol) char complement(char symbol)
{ {
static constexpr char* complements = "UVGHZZCDZZMZKNZZZYSAABWZR";
static constexpr char* complements = "TVGHZZCDZZMZKNZZZYSAABWZR";
return (symbol < 'A' || symbol >= 'Z') ? 'Z' : complements[symbol - 'A']; return (symbol < 'A' || symbol >= 'Z') ? 'Z' : complements[symbol - 'A'];
} }
} }
@ -90,7 +90,7 @@ namespace rna
{ {
char complement(char symbol) char complement(char symbol)
{ {
static constexpr char* complements = "TVGHZZCDZZMZKNZZZYSAABWZR";
static constexpr char* complements = "UVGHZZCDZZMZKNZZZYSAABWZR";
return (symbol < 'A' || symbol >= 'Z') ? 'Z' : complements[symbol - 'A']; return (symbol < 'A' || symbol >= 'Z') ? 'Z' : complements[symbol - 'A'];
} }
} }

+ 3
- 3
src/game/genetics/codon.hpp View File

@ -29,7 +29,7 @@ namespace codon {
* @param base1 IUPAC base code of first nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base1 IUPAC base code of first nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param base2 IUPAC base code of second nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base2 IUPAC base code of second nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param base3 IUPAC base code of third nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base3 IUPAC base code of third nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param starts String of 64 IUPAC amino acid codes, ordered to match corresponding start codon indices.
* @param starts String of 64 IUPAC amino acid codes, in TCAG order.
* @return `true` if the codon is a start codon, `false` otherwise. * @return `true` if the codon is a start codon, `false` otherwise.
*/ */
bool is_start(char base1, char base2, char base3, const char* starts); bool is_start(char base1, char base2, char base3, const char* starts);
@ -40,7 +40,7 @@ bool is_start(char base1, char base2, char base3, const char* starts);
* @param base1 IUPAC base code of first nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base1 IUPAC base code of first nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param base2 IUPAC base code of second nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base2 IUPAC base code of second nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param base3 IUPAC base code of third nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base3 IUPAC base code of third nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param aas String of 64 IUPAC amino acid codes, ordered to match corresponding codon indices.
* @param aas String of 64 IUPAC amino acid codes, in TCAG order.
* @return `true` if the codon is a stop codon, `false` otherwise. * @return `true` if the codon is a stop codon, `false` otherwise.
*/ */
bool is_stop(char base1, char base2, char base3, const char* aas); bool is_stop(char base1, char base2, char base3, const char* aas);
@ -51,7 +51,7 @@ bool is_stop(char base1, char base2, char base3, const char* aas);
* @param base1 IUPAC base code of first nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base1 IUPAC base code of first nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param base2 IUPAC base code of second nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base2 IUPAC base code of second nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param base3 IUPAC base code of third nucleobase, either `U`, `T`, `C`, `A`, or `G`. * @param base3 IUPAC base code of third nucleobase, either `U`, `T`, `C`, `A`, or `G`.
* @param aas String of 64 IUPAC amino acid codes, ordered to match corresponding codon indices.
* @param aas String of 64 IUPAC amino acid codes, in TCAG order.
* @return IUPAC amino acid code of corresponding amino acid, or `-` if an invalid codon was supplied. * @return IUPAC amino acid code of corresponding amino acid, or `-` if an invalid codon was supplied.
*/ */
char translate(char base1, char base2, char base3, const char* aas); char translate(char base1, char base2, char base3, const char* aas);

Loading…
Cancel
Save