SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
A vectorised scoring scheme handling matches and mismatches only. More...
#include <seqan3/alignment/scoring/detail/simd_match_mismatch_scoring_scheme.hpp>
Public Member Functions | |
template<typename alphabet_ranks_t > requires std::same_as<std::remove_cvref_t<alphabet_ranks_t>, alphabet_ranks_type> | |
constexpr alphabet_ranks_t | make_score_profile (alphabet_ranks_t &&ranks) const noexcept |
Returns the given simd vector without changing it (no-op). | |
constexpr auto | padding_match_score () noexcept |
Returns the match score used for padded symbols. | |
Constructors, destructor and assignment | |
constexpr | simd_match_mismatch_scoring_scheme ()=default |
Defaulted. | |
constexpr | simd_match_mismatch_scoring_scheme (simd_match_mismatch_scoring_scheme const &)=default |
Defaulted. | |
constexpr | simd_match_mismatch_scoring_scheme (simd_match_mismatch_scoring_scheme &&)=default |
Defaulted. | |
constexpr simd_match_mismatch_scoring_scheme & | operator= (simd_match_mismatch_scoring_scheme const &)=default |
Defaulted. | |
constexpr simd_match_mismatch_scoring_scheme & | operator= (simd_match_mismatch_scoring_scheme &&)=default |
Defaulted. | |
~simd_match_mismatch_scoring_scheme ()=default | |
Defaulted. | |
template<typename scoring_scheme_t > requires scoring_scheme_for<scoring_scheme_t, alphabet_t> | |
constexpr | simd_match_mismatch_scoring_scheme (scoring_scheme_t const &scoring_scheme) |
Initialises the simd vector match score and mismatch score from the given scoring scheme. | |
template<typename scoring_scheme_t > requires scoring_scheme_for<scoring_scheme_t, alphabet_t> | |
constexpr simd_match_mismatch_scoring_scheme & | operator= (scoring_scheme_t const &scoring_scheme) |
Initialises the simd vector match score and mismatch score from the given scoring scheme. | |
Score computation | |
constexpr simd_score_t | score (alphabet_ranks_type const &ranks1, alphabet_ranks_type const &ranks2) const noexcept |
Computes the score for two simd vectors. | |
Static Public Attributes | |
static constexpr scalar_type | padding_symbol = static_cast<scalar_type>(1u << (bits_of<scalar_type> - 1)) |
The padding symbol used to fill up smaller sequences in a simd batch. | |
Private Types | |
using | alphabet_ranks_type = simd_score_t |
The type of the simd vector representing the alphabet ranks of one sequence batch. | |
using | scalar_type = typename simd_traits< simd_score_t >::scalar_type |
The underlying scalar type of the simd vector. | |
Private Member Functions | |
template<typename scoring_scheme_t > | |
constexpr void | initialise_from_scalar_scoring_scheme (scoring_scheme_t const &scoring_scheme) |
Initialises the simd vector match score and mismatch score from the given scoring scheme. | |
Private Attributes | |
simd_score_t | match_score |
The simd vector for a match score. | |
simd_score_t | mismatch_score |
The simd vector for a mismatch score. | |
A vectorised scoring scheme handling matches and mismatches only.
simd_score_t | The type of the simd vector; must model seqan3::detail::simd_concept. |
alphabet_t | The type of the alphabet over which to define the scoring scheme; must model seqan3::semialphabet and must have an alphabet size of at least 2. |
alignment_t | The type of the alignment to compute; must be either seqan3::align_cfg::method_global or seqan3::align_cfg::method_local. |
Wraps a regular scoring scheme by extracting the scores for a match and a mismatch and converts them into seqan3::detail::simd vectors. Only symmetric scoring schemes are preserved, i.e. in the vectorised scoring scheme elements with the same rank are assigned the match score and elements with a different rank are assigned the mismatch score. Note during the conversion to the simd vectors the alphabet type information is lost and only the ranks of the alphabet are used.
During the vectorised alignment multiple sequences are packed into one simd vector. To handle sequences with different sizes in the vectorised alignment algorithm the smaller sequences are filled up with special padding symbols. These padding symbols are chosen in a way that allows the computation of the alignments without the need of masking the results for invalid positions within the matrix because a specific position might have exceeded the original sequence size. To do so, the global alignment uses the same padding symbol for the first sequence pack and the second sequence pack. This padding symbol is distinct to any symbol in the underlying alphabet of the sequences. The score function is adapted in a way that a comparison with a padding symbol always yields a match. Thus, after the end of a sequence within the pack is reached the score can only grow. The respective score can then be inferred from the projected position of the last row or column of the vectorised matrix depending on the the corresponding alignment configuration.
In case of the local alignment the second sequence pack are padded with a symbol that is distinct to any symbol of the corresponding alphabet and to the padding symbol of the first sequence pack. Comparing any symbol with the padding symbols will yield a mismatch, such that the score can only get smaller after the end of a sequence has reached. This way the specific optimum of one sequence pair in the pack is not affected during the computation of the vectorised alignment.
|
inlineexplicitconstexpr |
Initialises the simd vector match score and mismatch score from the given scoring scheme.
scoring_scheme_t | The type of the underlying scoring scheme; must model seqan3::scoring_scheme for alphabet_t . |
[in] | scoring_scheme | The scoring scheme to initialise the vectorised match and mismatch score from. |
std::invalid_argument | if the value of the match or mismatch score exceed the value range of the scalar type of the used simd vector type simd_score_t . |
Obtains the score for a match and a mismatch respectively and fills the corresponding simd vectors with these scores. In addition, some safety checks are performed in order to avoid that a score is used which cannot be represented by the scalar type of the used simd vector.
|
inlineconstexprprivate |
Initialises the simd vector match score and mismatch score from the given scoring scheme.
scoring_scheme_t | The type of the underlying scoring scheme; must model seqan3::scoring_scheme for alphabet_t . |
[in] | scoring_scheme | The scoring scheme to initialise the vectorised match and mismatch score from. |
std::invalid_argument | if the value of the match or mismatch score exceed the value range of the scalar type of the used simd vector type simd_score_t . |
Obtains the score for a match and a mismatch respectively and fills the corresponding simd vectors with these scores. In addition, some safety checks are performed in order to avoid that a score is used which cannot be represented by the scalar type of the used simd vector.
|
inlineconstexpr |
Initialises the simd vector match score and mismatch score from the given scoring scheme.
scoring_scheme_t | The type of the underlying scoring scheme; must model seqan3::scoring_scheme for alphabet_t . |
[in] | scoring_scheme | The scoring scheme to initialise the vectorised match and mismatch score from. |
std::invalid_argument | if the value of the match or mismatch score exceed the value range of the scalar type of the used simd vector type simd_score_t . |
Obtains the score for a match and a mismatch respectively and fills the corresponding simd vectors with these scores. In addition, some safety checks are performed in order to avoid that a score is used which cannot be represented by the scalar type of the used simd vector.
|
inlineconstexprnoexcept |
Computes the score for two simd vectors.
[in] | ranks1 | The alphabet ranks of the first operand. |
[in] | ranks2 | The alphabet ranks of the second operand. |
This function compares packed elements in both simd vectors and returns a new simd vector filled with match and mismatch scores depending on the result of the comparison. For global alignments the comparison yields a match if any of the elements is a padding symbol. The padding symbol must have the signed bit set. For local alignments two different padding symbols are assumed, which will always yield a mismatch when compared with any other symbol.
No-throw guarantee.
Constant.
Thread-safe.