24# include <cereal/types/array.hpp>
39template <arithmetic score_type>
40struct match_score : detail::strong_type<score_type, match_score<score_type>, detail::strong_type_skill::convert>
42 using detail::strong_type<score_type,
match_score<score_type>, detail::strong_type_skill::convert>::strong_type;
51template <arithmetic score_type>
64template <arithmetic score_type>
65struct mismatch_score : detail::strong_type<score_type, mismatch_score<score_type>, detail::strong_type_skill::convert>
76template <arithmetic score_type>
98template <
typename derived_t, alphabet alphabet_t, arithmetic score_t>
146 template <arithmetic score_arg_t>
177 template <arithmetic score_arg_t>
185 throw std::invalid_argument{
"You passed a score value to set_simple_scheme that is out of range of the "
186 "scoring scheme's underlying type. Define your scoring scheme with a larger "
187 "template parameter or down-cast you score value beforehand to prevent "
193 matrix[i][j] = (i == j) ?
static_cast<score_t
>(i_ms) :
static_cast<score_t
>(i_mms);
215 template <
typename alph1_t,
typename alph2_t>
217 constexpr score_t &
score(alph1_t
const alph1, alph2_t
const alph2)
noexcept
219 return matrix[
to_rank(
static_cast<alphabet_t
>(alph1))][
to_rank(
static_cast<alphabet_t
>(alph2))];
223 template <
typename alph1_t,
typename alph2_t>
225 constexpr score_t
score(alph1_t
const alph1, alph2_t
const alph2)
const noexcept
227 return matrix[
to_rank(
static_cast<alphabet_t
>(alph1))][
to_rank(
static_cast<alphabet_t
>(alph2))];
235 constexpr bool operator==(derived_t
const & rhs)
const noexcept
237 return matrix == rhs.matrix;
241 constexpr bool operator!=(derived_t
const & rhs)
const noexcept
243 return matrix != rhs.matrix;
254 template <cereal_archive archive_t>
255 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
Core alphabet concept and free function/type trait wrappers.
Adaptions of concepts from the Cereal library.
A CRTP base class for scoring schemes.
Definition: scoring_scheme_base.hpp:100
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:178
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:166
constexpr scoring_scheme_base(scoring_scheme_base &&) noexcept=default
Defaulted.
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:225
alphabet_t alphabet_type
Type of the underlying alphabet.
Definition: scoring_scheme_base.hpp:108
constexpr scoring_scheme_base(scoring_scheme_base const &) noexcept=default
Defaulted.
constexpr bool operator!=(derived_t const &rhs) const noexcept
Checks whether *this is not equal to rhs.
Definition: scoring_scheme_base.hpp:241
constexpr bool operator==(derived_t const &rhs) const noexcept
Checks whether *this is equal to rhs.
Definition: scoring_scheme_base.hpp:235
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:120
constexpr scoring_scheme_base(matrix_type const &matrix) noexcept
Constructor for a custom scheme (delegates to set_custom_matrix()).
Definition: scoring_scheme_base.hpp:155
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:199
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:147
score_t score_type
Type of the score values.
Definition: scoring_scheme_base.hpp:106
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:217
static constexpr matrix_size_type matrix_size
Size of the matrix dimensions (i.e. size of the alphabet).
Definition: scoring_scheme_base.hpp:114
constexpr auto to_rank
Return the rank representation of a (semi-)alphabet object.
Definition: concept.hpp:155
Checks whether from can be explicitly converted to to.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides basic data structure for strong types.
A strong type of underlying type score_type that represents the score of two matching characters.
Definition: scoring_scheme_base.hpp:41
match_score(score_type) -> match_score< score_type >
Deduce the score type from the provided argument.
A strong type of underlying type score_type that represents the score two different characters.
Definition: scoring_scheme_base.hpp:66
mismatch_score(score_type) -> mismatch_score< score_type >
Deduce the score type from the provided argument.
Provides concepts that do not have equivalents in C++20.