|
@ -26,11 +26,21 @@ |
|
|
namespace genetics { |
|
|
namespace genetics { |
|
|
namespace protein { |
|
|
namespace protein { |
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* Returns the percent identity between two proteins. |
|
|
|
|
|
* |
|
|
|
|
|
* @param first1,last1 Range of IUPAC amino acids which constitute the first protein. |
|
|
|
|
|
* @param first2 Beginning of the range of IUPAC amino acids which constitute the second protein. |
|
|
|
|
|
* @return Percent identity between the two proteins. |
|
|
|
|
|
*/ |
|
|
|
|
|
template <class T, class ForwardIt1, class ForwardIt2> |
|
|
|
|
|
T identity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2); |
|
|
|
|
|
|
|
|
/**
|
|
|
/**
|
|
|
* Scores two proteins using a substitution matrix. |
|
|
* Scores two proteins using a substitution matrix. |
|
|
* |
|
|
* |
|
|
* @param first1,last1 Sequence of IUPAC amino acid codes which constitute the first protein. |
|
|
|
|
|
* @param first2,last2 Sequence of IUPAC amino acid codes which constitute the second protein. |
|
|
|
|
|
|
|
|
* @param first1,last1 Range of IUPAC amino acid codes which constitute the first protein. |
|
|
|
|
|
* @param first2,last2 Range of IUPAC amino acid codes which constitute the second protein. |
|
|
* @param matrix Substitution matrix. |
|
|
* @param matrix Substitution matrix. |
|
|
* @return Score of the two proteins. |
|
|
* @return Score of the two proteins. |
|
|
*/ |
|
|
*/ |
|
@ -46,6 +56,19 @@ typename std::remove_all_extents::type score(ForwardIt1 first1, ForwardI |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
template <class T, class ForwardIt1, class ForwardIt2> |
|
|
|
|
|
T identity(ForwardIt1 first1, ForwardIt1 last1, ForwardIt2 first2) |
|
|
|
|
|
{ |
|
|
|
|
|
auto length = std::distance(first1, last1); |
|
|
|
|
|
|
|
|
|
|
|
T sum = 0; |
|
|
|
|
|
for (; first1 != last1; ++first1, ++first2) |
|
|
|
|
|
if (*first1 == *first2) |
|
|
|
|
|
++sum; |
|
|
|
|
|
|
|
|
|
|
|
return sum / static_cast<T>(length); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} // namespace protein
|
|
|
} // namespace protein
|
|
|
} // namespace genetics
|
|
|
} // namespace genetics
|
|
|
|
|
|
|
|
|