Browse Source

Move genetics folder out of game folder, document subnamespaces of genetics namespace, move genetics::translation_table to genetics::codon::table

master
C. J. Howard 3 years ago
parent
commit
461e864c49
12 changed files with 44 additions and 24 deletions
  1. +0
    -1
      CMakeLists.txt
  2. +1
    -1
      src/game/states/play-state.cpp
  3. +2
    -0
      src/genetics/amino-acid.hpp
  4. +0
    -0
      src/genetics/base.cpp
  5. +4
    -0
      src/genetics/base.hpp
  6. +0
    -0
      src/genetics/codon.cpp
  7. +16
    -0
      src/genetics/codon.hpp
  8. +1
    -1
      src/genetics/genetics.hpp
  9. +2
    -0
      src/genetics/matrix.hpp
  10. +2
    -0
      src/genetics/protein.hpp
  11. +8
    -5
      src/genetics/sequence.hpp
  12. +8
    -16
      src/genetics/standard-code.hpp

+ 0
- 1
CMakeLists.txt View File

@ -14,7 +14,6 @@ find_package(SDL2 REQUIRED COMPONENTS SDL2::SDL2-static SDL2::SDL2main CONFIG)
find_package(OpenAL REQUIRED CONFIG)
find_library(physfs REQUIRED NAMES physfs-static PATHS "${CMAKE_PREFIX_PATH}/lib")
# Determine dependencies
set(STATIC_LIBS
dr_wav

+ 1
- 1
src/game/states/play-state.cpp View File

@ -63,7 +63,7 @@
#include "utility/gamma.hpp"
#include "utility/bit-math.hpp"
#include "game/genetics/genetics.hpp"
#include "genetics/genetics.hpp"
#include <iostream>
#include <bitset>
#include <ctime>

src/game/genetics/amino-acid.hpp → src/genetics/amino-acid.hpp View File

@ -23,6 +23,8 @@
#include <type_traits>
namespace genetics {
/// Functions which operate on IUPAC amino acid symbols.
namespace amino_acid {
/**

src/game/genetics/base.cpp → src/genetics/base.cpp View File


src/game/genetics/base.hpp → src/genetics/base.hpp View File

@ -21,6 +21,8 @@
#define ANTKEEPER_GENETICS_BASE_HPP
namespace genetics {
/// Functions which operate on IUPAC degenerate base symbols.
namespace base {
/**
@ -40,6 +42,7 @@ int compare(char a, char b);
*/
char transcribe(char symbol);
/// Functions which operate on IUPAC degenerate **DNA** base symbols.
namespace dna
{
/**
@ -51,6 +54,7 @@ namespace dna
char complement(char symbol);
}
/// Functions which operate on IUPAC degenerate **RNA** base symbols.
namespace rna
{
/**

src/game/genetics/codon.cpp → src/genetics/codon.cpp View File


src/game/genetics/codon.hpp → src/genetics/codon.hpp View File

@ -21,8 +21,24 @@
#define ANTKEEPER_GENETICS_CODON_HPP
namespace genetics {
/// Functions and structures related to triplets of IUPAC base symbols.
namespace codon {
/**
* Table for translating codons to amino acids.
*
* @see https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi
*/
struct table
{
/// String of 64 IUPAC amino acid base symbols, in TCAG order.
const char* aas;
/// String of 64 IUPAC amino acid base symbols, in TCAG order, where symbols other than `-` and `*` indicate a start codon and its amino acid.
const char* starts;
};
/**
* Returns `true` if a codon is a start codon.
*

src/game/genetics/genetics.hpp → src/genetics/genetics.hpp View File

@ -29,6 +29,6 @@ namespace genetics {}
#include "matrix.hpp"
#include "protein.hpp"
#include "sequence.hpp"
#include "translation-table.hpp"
#include "standard-code.hpp"
#endif // ANTKEEPER_GENETICS_HPP

src/game/genetics/matrix.hpp → src/genetics/matrix.hpp View File

@ -21,6 +21,8 @@
#define ANTKEEPER_GENETICS_MATRIX_HPP
namespace genetics {
/// Substitution matrix constants.
namespace matrix {
/**

src/game/genetics/protein.hpp → src/genetics/protein.hpp View File

@ -24,6 +24,8 @@
#include <type_traits>
namespace genetics {
/// Functions which operate on sequences of IUPAC amino acid symbols.
namespace protein {
/**

src/game/genetics/sequence.hpp → src/genetics/sequence.hpp View File

@ -22,12 +22,13 @@
#include "base.hpp"
#include "codon.hpp"
#include "translation-table.hpp"
#include <algorithm>
#include <iterator>
#include <random>
namespace genetics {
/// Functions and structures related to sequences of IUPAC degenerate base symbols.
namespace sequence {
/**
@ -75,7 +76,7 @@ void crossover_n(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, Size co
* @return First ORF in the sequence, or `{last, last}` if no ORF was found.
*/
template <class ForwardIt>
orf<ForwardIt> find_orf(ForwardIt first, ForwardIt last, const translation_table& table);
orf<ForwardIt> find_orf(ForwardIt first, ForwardIt last, const codon::table& table);
/**
* Applies the given function to a randomly selected element in a range.
@ -129,8 +130,9 @@ OutputIt transcribe(InputIt first, InputIt last, OutputIt d_first);
* @return Output iterator to the element past the last element translated.
*/
template <class InputIt, class OutputIt>
OutputIt translate(InputIt first, InputIt last, OutputIt d_first, const translation_table& table);
OutputIt translate(InputIt first, InputIt last, OutputIt d_first, const codon::table& table);
/// Functions which operate on sequences of IUPAC degenerate **DNA** base symbols.
namespace dna
{
/**
@ -144,6 +146,7 @@ namespace dna
OutputIt complement(InputIt first, InputIt last, OutputIt d_first);
}
/// Functions which operate on sequences of IUPAC degenerate **RNA** base symbols.
namespace rna
{
/**
@ -192,7 +195,7 @@ void crossover_n(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, Size co
}
template <class ForwardIt>
orf<ForwardIt> find_orf(ForwardIt first, ForwardIt last, const translation_table& table)
orf<ForwardIt> find_orf(ForwardIt first, ForwardIt last, const codon::table& table)
{
ForwardIt second;
ForwardIt third;
@ -307,7 +310,7 @@ inline OutputIt transcribe(InputIt first, InputIt last, OutputIt d_first)
}
template <class InputIt, class OutputIt>
OutputIt translate(InputIt first, InputIt last, OutputIt d_first, const translation_table& table)
OutputIt translate(InputIt first, InputIt last, OutputIt d_first, const codon::table& table)
{
auto length = std::distance(first, last);

src/game/genetics/translation-table.hpp → src/genetics/standard-code.hpp View File

@ -17,27 +17,19 @@
* along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef ANTKEEPER_GENETICS_TRANSLATION_TABLE_HPP
#define ANTKEEPER_GENETICS_TRANSLATION_TABLE_HPP
#ifndef ANTKEEPER_GENETICS_STANDARD_CODE_HPP
#define ANTKEEPER_GENETICS_STANDARD_CODE_HPP
#include "codon.hpp"
namespace genetics {
/**
* Genetic code translation table.
* Codon table for standard genetic code.
*
* @see https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi
* @see https://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi#SG1
*/
struct translation_table
{
/// String of 64 IUPAC amino acid base symbols, in TCAG order.
const char* aas;
/// String of 64 IUPAC amino acid base symbols, in TCAG order, where symbols other than `-` and `*` indicate a start codon and its amino acid.
const char* starts;
};
/// Translation table for standard genetic code.
constexpr translation_table standard_code =
constexpr codon::table standard_code =
{
"FFLLSSSSYY**CC*WLLLLPPPPHHQQRRRRIIIMTTTTNNKKSSRRVVVVAAAADDEEGGGG",
"---M------**--*----M---------------M----------------------------",
@ -45,4 +37,4 @@ constexpr translation_table standard_code =
} // namespace genetics
#endif // ANTKEEPER_GENETICS_TRANSLATION_TABLE_HPP
#endif // ANTKEEPER_GENETICS_STANDARD_CODE_HPP

Loading…
Cancel
Save