43 #include <range/v3/algorithm/copy.hpp> 51 #if SEQAN3_WITH_CEREAL 52 #include <cereal/types/array.hpp> 53 #endif // SEQAN3_WITH_CEREAL 67 template <arithmetic_concept score_type>
68 struct match_score : detail::strong_type<score_type, match_score<score_type>, detail::strong_type_skill::convert>
70 using detail::strong_type<score_type, match_score<score_type>, detail::strong_type_skill::convert>::strong_type;
77 template <arithmetic_concept score_type>
90 template <arithmetic_concept score_type>
91 struct mismatch_score : detail::strong_type<score_type, mismatch_score<score_type>, detail::strong_type_skill::convert>
93 using detail::strong_type<score_type, mismatch_score<score_type>, detail::strong_type_skill::convert>::strong_type;
100 template <arithmetic_concept score_type>
118 template <
typename derived_t, alphabet_concept alphabet_t, arithmetic_concept score_t>
128 using matrix_size_type = std::remove_const_t<decltype(alphabet_size_v<alphabet_t>)>;
132 static constexpr matrix_size_type matrix_size = alphabet_size_v<alphabet_t>;
137 using matrix_type = std::array<std::array<score_type, matrix_size>, matrix_size>;
158 set_hamming_distance();
164 template <arithmetic_concept score_arg_t>
167 set_simple_scheme(ms, mms);
175 set_custom_matrix(_matrix);
183 constexpr
void set_hamming_distance() noexcept
195 template <arithmetic_concept score_arg_t>
198 std::conditional_t<std::Integral<score_t>, int64_t,
double> i_ms =
static_cast<score_arg_t
>(ms);
199 std::conditional_t<std::Integral<score_t>, int64_t,
double> i_mms =
static_cast<score_arg_t
>(mms);
200 if ((i_ms < std::numeric_limits<score_t>::lowest() || i_ms > std::numeric_limits<score_t>::max()) ||
201 (i_mms < std::numeric_limits<score_t>::lowest() || i_mms > std::numeric_limits<score_t>::max()))
203 throw std::invalid_argument{
"You passed a score value to set_simple_scheme that is out of range of the " 204 "scoring scheme's underlying type. Define your scoring scheme with a larger " 205 "template parameter or down-cast you score value beforehand to prevent " 209 for (matrix_size_type i = 0; i < matrix_size; ++i)
210 for (matrix_size_type j = 0; j < matrix_size; ++j)
211 matrix[i][j] = (i == j) ?
static_cast<score_t
>(i_ms) : static_cast<score_t>(i_mms);
233 template <explicitly_convertible_to_concept<alphabet_t> alph1_t,
234 explicitly_convertible_to_concept<alphabet_t> alph2_t>
235 constexpr score_t &
score(alph1_t
const alph1, alph2_t
const alph2) noexcept
237 return matrix[
to_rank(static_cast<alphabet_t>(alph1))][
to_rank(static_cast<alphabet_t>(alph2))];
241 template <explicitly_convertible_to_concept<alphabet_t> alph1_t,
242 explicitly_convertible_to_concept<alphabet_t> alph2_t>
243 constexpr score_t
score(alph1_t
const alph1, alph2_t
const alph2)
const noexcept
245 return matrix[
to_rank(static_cast<alphabet_t>(alph1))][
to_rank(static_cast<alphabet_t>(alph2))];
251 constexpr
bool operator==(derived_t
const & rhs)
const noexcept
253 return matrix == rhs.matrix;
256 constexpr
bool operator!=(derived_t
const & rhs)
const noexcept
258 return matrix != rhs.matrix;
269 template <cereal_archive_concept archive_t>
270 void CEREAL_SERIALIZE_FUNCTION_NAME(archive_t & archive)
Contains basic data structure for strong types.
A CRTP base class for scoring schemes.
Definition: scoring_scheme_base.hpp:119
Contains various shortcuts for common std::ranges functions.
score_t score_type
Type of the score values.
Definition: scoring_scheme_base.hpp:126
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:165
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:235
::ranges::copy copy
Alias for ranges::copy. Copies a range of elements to a new location.
Definition: ranges:200
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
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:217
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:243
A strong type of underlying type score_type that represents the score of two matching characters...
Definition: scoring_scheme_base.hpp:68
A strong type of underlying type score_type that represents the score two different characters...
Definition: scoring_scheme_base.hpp:91
Adaptations of concepts from the Ranges TS.
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:196
Adaptions of concepts from the Cereal library.
constexpr scoring_scheme_base(matrix_type const &_matrix) noexcept
Constructor for a custom scheme (delegates to set_custom_matrix()).
Definition: scoring_scheme_base.hpp:173
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:138
Core alphabet concept and free function/metafunction wrappers.
constexpr underlying_rank_t< alphabet_type > to_rank(alphabet_type const alph) requires requires(alphabet_type alph)
Implementation of seqan3::semi_alphabet_concept::to_rank() that delegates to a member function...
Definition: member_exposure.hpp:97