20 #ifndef ANTKEEPER_GENETICS_PROTEIN_HPP
21 #define ANTKEEPER_GENETICS_PROTEIN_HPP
24 #include <type_traits>
38 template <
class T,
class ForwardIt1,
class ForwardIt2>
39 T
identity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2);
49 template <
class ForwardIt1,
class ForwardIt2,
class Matrix>
50 typename std::remove_all_extents<Matrix>::type
score(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
const Matrix& matrix);
59 template <
class T,
class ForwardIt1,
class ForwardIt2,
class Matrix>
60 typename T
similarity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
const Matrix& matrix);
62 template <
class T,
class ForwardIt1,
class ForwardIt2>
63 T
identity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2)
68 for (; first1 != last1; ++first1, ++first2)
69 if (*first1 == *first2)
75 template <
class ForwardIt1,
class ForwardIt2,
class Matrix>
76 typename std::remove_all_extents<Matrix>::type
score(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
const Matrix& matrix)
78 typename std::remove_all_extents<Matrix>::type result = 0;
79 for (; first1 != last1; ++first1, ++first2)
84 template <
class T,
class ForwardIt1,
class ForwardIt2,
class Matrix>
85 typename T
similarity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2,
const Matrix& matrix)
88 T positive_count = T(0);
90 for (; first1 != last1; ++first1, ++first2)
94 return positive_count /
length;
std::remove_all_extents< Matrix >::type score(char a, char b, const Matrix &matrix)
Scores two amino acids using a substitution matrix.
T similarity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, const Matrix &matrix)
Returns the percent similarity between two proteins.
std::remove_all_extents< Matrix >::type score(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2, const Matrix &matrix)
Scores two proteins using a substitution matrix.
T identity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2)
Returns the percent identity between two proteins.
T length(const quaternion< T > &q)
Calculates the length of a quaternion.
T distance(const vector< T, N > &p0, const vector< T, N > &p1)
Calculates the distance between two points.
constexpr T sum(const vector< T, N > &x) noexcept
Calculates the sum of all elements in a vector.