19#include <seqan3/utility/simd/algorithm.hpp>
20#include <seqan3/utility/simd/concept.hpp>
22namespace seqan3::detail
62template <simd_concept simd_score_t, semialphabet alphabet_t,
typename alignment_t>
63 requires (seqan3::alphabet_size<alphabet_t> > 1)
64 && (std::same_as<alignment_t, align_cfg::method_local> || std::same_as<alignment_t, align_cfg::method_global>)
65class simd_match_mismatch_scoring_scheme
69 using scalar_type =
typename simd_traits<simd_score_t>::scalar_type;
71 using alphabet_ranks_type = simd_score_t;
75 static constexpr scalar_type padding_symbol =
static_cast<scalar_type
>(1u << (bits_of<scalar_type> - 1));
81 constexpr simd_match_mismatch_scoring_scheme() =
default;
83 constexpr simd_match_mismatch_scoring_scheme(simd_match_mismatch_scoring_scheme
const &) =
default;
85 constexpr simd_match_mismatch_scoring_scheme(simd_match_mismatch_scoring_scheme &&) =
default;
87 constexpr simd_match_mismatch_scoring_scheme & operator=(simd_match_mismatch_scoring_scheme
const &) =
default;
89 constexpr simd_match_mismatch_scoring_scheme & operator=(simd_match_mismatch_scoring_scheme &&) =
default;
91 ~simd_match_mismatch_scoring_scheme() =
default;
94 template <
typename scoring_scheme_t>
96 constexpr explicit simd_match_mismatch_scoring_scheme(scoring_scheme_t
const & scoring_scheme)
98 initialise_from_scalar_scoring_scheme(scoring_scheme);
102 template <
typename scoring_scheme_t>
104 constexpr simd_match_mismatch_scoring_scheme & operator=(scoring_scheme_t
const & scoring_scheme)
106 initialise_from_scalar_scoring_scheme(scoring_scheme);
140 constexpr simd_score_t score(alphabet_ranks_type
const & ranks1, alphabet_ranks_type
const & ranks2)
const noexcept
142 typename simd_traits<simd_score_t>::mask_type mask;
145 if constexpr (std::same_as<alignment_t, align_cfg::method_global>)
146 mask = (ranks1 ^ ranks2) <= simd::fill<simd_score_t>(0);
148 mask = (ranks1 ^ ranks2) == simd::fill<simd_score_t>(0);
150 return mask ? match_score : mismatch_score;
155 constexpr auto padding_match_score() noexcept
157 return match_score[0];
161 template <
typename alphabet_ranks_t>
162 requires std::same_as<std::remove_cvref_t<alphabet_ranks_t>, alphabet_ranks_type>
163 constexpr alphabet_ranks_t make_score_profile(alphabet_ranks_t && ranks)
const noexcept
165 return std::forward<alphabet_ranks_t>(ranks);
184 template <
typename scoring_scheme_t>
185 constexpr void initialise_from_scalar_scoring_scheme(scoring_scheme_t
const & scoring_scheme)
187 using score_t =
decltype(std::declval<scoring_scheme_t const &>().score(alphabet_t{}, alphabet_t{}));
188 using simd_scalar_t =
typename simd_traits<simd_score_t>::scalar_type;
190 score_t scalar_match_score =
192 score_t scalar_mismatch_score =
196 if constexpr (
sizeof(simd_scalar_t) <
sizeof(score_t))
202 "for the selected scalar type of the simd type."};
206 match_score = simd::fill<simd_score_t>(
static_cast<simd_scalar_t
>(scalar_match_score));
207 mismatch_score = simd::fill<simd_score_t>(
static_cast<simd_scalar_t
>(scalar_mismatch_score));
210 simd_score_t match_score;
211 simd_score_t mismatch_score;
Provides global and local alignment configurations.
Core alphabet concept and free function/type trait wrappers.
Provides utility functions for bit twiddling.
Adaptions of concepts from the Cereal library.
constexpr auto assign_rank_to
Assign a rank to an alphabet object.
Definition alphabet/concept.hpp:290
A concept that requires that type be able to score two letters.
Provides seqan3::scoring_scheme_for.