|
SeqAn3
3.0.1
The Modern C++ library for sequence analysis.
|
|
Go to the documentation of this file.
16 #include <range/v3/algorithm/copy.hpp>
25 #if SEQAN3_WITH_CEREAL
26 #include <cereal/types/array.hpp>
27 #endif // SEQAN3_WITH_CEREAL
41 template <arithmetic score_type>
42 struct match_score : detail::strong_type<score_type, match_score<score_type>, detail::strong_type_skill::convert>
44 using detail::strong_type<score_type, match_score<score_type>, detail::strong_type_skill::convert>::strong_type;
52 template <arithmetic score_type>
66 template <arithmetic score_type>
67 struct mismatch_score : detail::strong_type<score_type, mismatch_score<score_type>, detail::strong_type_skill::convert>
69 using detail::strong_type<score_type, mismatch_score<score_type>, detail::strong_type_skill::convert>::strong_type;
77 template <arithmetic score_type>
99 template <
typename derived_t, alphabet alphabet_t, arithmetic score_t>
147 template <arithmetic score_arg_t>
178 template <arithmetic score_arg_t>
186 throw std::invalid_argument{
"You passed a score value to set_simple_scheme that is out of range of the "
187 "scoring scheme's underlying type. Define your scoring scheme with a larger "
188 "template parameter or down-cast you score value beforehand to prevent "
194 matrix[i][j] = (i == j) ? static_cast<score_t>(i_ms) : static_cast<score_t>(i_mms);
202 std::ranges::copy(matrix, this->matrix.
begin());
216 template <
typename alph1_t,
typename alph2_t>
220 constexpr score_t &
score(alph1_t
const alph1, alph2_t
const alph2) noexcept
222 return matrix[
to_rank(static_cast<alphabet_t>(alph1))][
to_rank(static_cast<alphabet_t>(alph2))];
226 template <
typename alph1_t,
typename alph2_t>
230 constexpr score_t
score(alph1_t
const alph1, alph2_t
const alph2)
const noexcept
232 return matrix[
to_rank(static_cast<alphabet_t>(alph1))][
to_rank(static_cast<alphabet_t>(alph2))];
240 constexpr
bool operator==(derived_t
const & rhs)
const noexcept
242 return matrix == rhs.matrix;
246 constexpr
bool operator!=(derived_t
const & rhs)
const noexcept
248 return matrix != rhs.matrix;
259 template <cereal_archive archive_t>
260 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
constexpr scoring_scheme_base() noexcept
The default constructor (delegates to set_hamming_distance()).
Definition: scoring_scheme_base.hpp:139
static constexpr matrix_size_type matrix_size
Size of the matrix dimensions (i.e. size of the alphabet).
Definition: scoring_scheme_base.hpp:115
constexpr bool operator!=(derived_t const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition: scoring_scheme_base.hpp:246
Provides various shortcuts for common std::ranges functions.
constexpr void set_hamming_distance() noexcept
Set the hamming scheme, a variant of the simple scheme where match is scored 0 and mismatch -1.
Definition: scoring_scheme_base.hpp:167
constexpr score_t score(alph1_t const alph1, alph2_t const alph2) const noexcept
Score two letters (either two nucleotids or two amino acids).
Definition: scoring_scheme_base.hpp:230
A CRTP base class for scoring schemes.
Definition: scoring_scheme_base.hpp:100
Resolves to std::ranges::explicitly_convertible_to<type1, type2>().
Provides basic data structure for strong types.
constexpr void set_custom_matrix(matrix_type const &matrix) noexcept
Set a custom scheme by passing a full matrix with arbitrary content.
Definition: scoring_scheme_base.hpp:200
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:142
constexpr score_t & score(alph1_t const alph1, alph2_t const alph2) noexcept
Score two letters (either two nucleotids or two amino acids).
Definition: scoring_scheme_base.hpp:220
Adaptations of algorithms from the Ranges TS.
A strong type of underlying type score_type that represents the score two different characters.
Definition: scoring_scheme_base.hpp:67
constexpr scoring_scheme_base(match_score< score_arg_t > const ms, mismatch_score< score_arg_t > const mms)
Constructor for the simple scheme (delegates to set_simple_scheme()).
Definition: scoring_scheme_base.hpp:148
Provides concepts for core language types and relations that don't have concepts in C++20 (yet).
score_t score_type
Type of the score values.
Definition: scoring_scheme_base.hpp:107
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
alphabet_t alphabet_type
Type of the underlying alphabet.
Definition: scoring_scheme_base.hpp:109
constexpr scoring_scheme_base(matrix_type const &matrix) noexcept
Constructor for a custom scheme (delegates to set_custom_matrix()).
Definition: scoring_scheme_base.hpp:156
Adaptions of concepts from the Cereal library.
constexpr bool operator==(derived_t const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition: scoring_scheme_base.hpp:240
std::array< std::array< score_type, matrix_size >, matrix_size > matrix_type
Type of the internal matrix (a two-dimensional array).
Definition: scoring_scheme_base.hpp:121
A strong type of underlying type score_type that represents the score of two matching characters.
Definition: scoring_scheme_base.hpp:42
constexpr void set_simple_scheme(match_score< score_arg_t > const ms, mismatch_score< score_arg_t > const mms)
Set the simple scheme (everything is either match or mismatch).
Definition: scoring_scheme_base.hpp:179
Core alphabet concept and free function/type trait wrappers.