SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t > Class Template Reference

A vectorised scoring scheme to handle scoring matrices using gather strategy. More...

#include <seqan3/alignment/scoring/detail/simd_matrix_scoring_scheme.hpp>

Public Member Functions

constexpr simd_score_profile_type make_score_profile (simd_alphabet_ranks_type const &ranks) const noexcept
 Converts the simd alphabet ranks into a score profile used for scoring it later with the alphabet ranks of another sequence batch.
 
constexpr scalar_type padding_match_score () const noexcept
 Returns the score used when aligning a padding symbol.
 
Constructors, destructor and assignment
constexpr simd_matrix_scoring_scheme ()=default
 Defaulted.
 
constexpr simd_matrix_scoring_scheme (simd_matrix_scoring_scheme const &)=default
 Defaulted.
 
constexpr simd_matrix_scoring_scheme (simd_matrix_scoring_scheme &&)=default
 Defaulted.
 
constexpr simd_matrix_scoring_schemeoperator= (simd_matrix_scoring_scheme const &)=default
 Defaulted.
 
constexpr simd_matrix_scoring_schemeoperator= (simd_matrix_scoring_scheme &&)=default
 Defaulted.
 
 ~simd_matrix_scoring_scheme ()=default
 Defaulted.
 
template<typename scoring_scheme_t >
constexpr simd_matrix_scoring_scheme (scoring_scheme_t const &scoring_scheme)
 Store the given scoring scheme matrix into a private member variable.
 
template<typename scoring_scheme_t >
constexpr simd_matrix_scoring_schemeoperator= (scoring_scheme_t const &scoring_scheme)
 Store the given scoring scheme matrix into a private member variable.
 
Score computation
constexpr simd_score_t score (simd_score_profile_type const &score_profile, simd_alphabet_ranks_type const &ranks) const noexcept
 Given two simd vectors, compute an element-wise score and return another simd vector.
 

Static Public Attributes

static constexpr scalar_type padding_symbol = static_cast<scalar_type>(seqan3::alphabet_size<alphabet_t>)
 The padding symbol used to fill up smaller sequences in a simd batch.
 

Private Types

using scalar_type = typename simd_traits< simd_score_t >::scalar_type
 The underlying scalar type of the simd vector.
 
using simd_alphabet_ranks_type = simd_score_t
 The type of the simd vector representing the alphabet ranks of one sequence batch.
 
using simd_score_profile_type = simd_score_t
 The score profile type used for this scoring scheme, which is the same as the simd score type.
 

Private Member Functions

template<typename scoring_scheme_t >
requires scoring_scheme_for<scoring_scheme_t, alphabet_t>
constexpr void initialise_from_scalar_scoring_scheme (scoring_scheme_t const &scoring_scheme)
 Store the given scoring scheme matrix into a private member variable.
 

Private Attributes

std::vector< scalar_typescoring_scheme_data {}
 The scoring scheme stored as a linear array.
 

Static Private Attributes

static constexpr size_t index_offset = seqan3::alphabet_size<alphabet_t> + 1
 The offset used to jump to the correct index in the linearised scoring scheme data.
 
static constexpr bool is_global = std::same_as<alignment_t, align_cfg::method_global>
 A flag that indicates wether the alignment mode is global.
 
static constexpr scalar_type score_for_padding_symbol = (is_global) ? 1 : -1
 The score used for the padding symbol (global -> increases score; local -> decreases score).
 

Detailed Description

template<simd_concept simd_score_t, semialphabet alphabet_t, typename alignment_t>
requires (std::same_as<alignment_t, align_cfg::method_local> || std::same_as<alignment_t, align_cfg::method_global>)
class seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t >

A vectorised scoring scheme to handle scoring matrices using gather strategy.

Template Parameters
simd_score_tThe type of the simd vector; must model seqan3::simd::simd_concept.
alphabet_tThe type of the alphabet over which to define the scoring scheme; must model seqan3::semialphabet.
alignment_tThe type of the alignment to compute; must be either seqan3::align_cfg::method_global or seqan3::align_cfg::method_local.

When scoring two seqan3::detail::simd vectors, this performs element-wise lookups of the compared simd vectors using a gather operation on the scoring scheme. The given scoring scheme is first transferred into linear memory such that a simple index gather can be used to retrieve the actual score. The index for the column vector of the alignment matrix must be precomputed using the seqan3::detail::simd_matrix_scoring_scheme::make_score_profile member function. This function computes the starting index of the respective matrix entry within the linearised scoring scheme. To improve the performance this is only done once per column inside of the alignment algorithm.

This simd scoring scheme matrix only needs one padding symbol, whose rank is initialised with the size of the alphabet. Accordingly, the internal alphabet size increases by one. Depending on the selected algorithm method the corresponding score values are either set to 1 for the global alignment or -1 for the local alignment. In the global alignment the score with a padding symbol will always increase, and the projected maximum will be rescaled with the number of matches added. In the local alignment the score with a padding symbol will always decrease, and the optimum can only be found inside of the valid score matrix area.

Note
Note that the alphabet type information is lost during the conversion to the simd vectors and only the ranks of the alphabet are used.

Constructor & Destructor Documentation

◆ simd_matrix_scoring_scheme()

template<simd_concept simd_score_t, semialphabet alphabet_t, typename alignment_t >
template<typename scoring_scheme_t >
constexpr seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t >::simd_matrix_scoring_scheme ( scoring_scheme_t const &  scoring_scheme)
inlineexplicitconstexpr

Store the given scoring scheme matrix into a private member variable.

Template Parameters
scoring_scheme_tThe type of the scoring scheme; must model seqan3::scoring_scheme_for the given alphabet type.
Parameters
[in]scoring_schemeThe scoring scheme to initialise the vectorised match and mismatch score with.
Exceptions
std::invalid_argumentif the score of the given scoring scheme exceeds the score range covered by the selected simd vector type.

Member Function Documentation

◆ initialise_from_scalar_scoring_scheme()

template<simd_concept simd_score_t, semialphabet alphabet_t, typename alignment_t >
template<typename scoring_scheme_t >
requires scoring_scheme_for<scoring_scheme_t, alphabet_t>
constexpr void seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t >::initialise_from_scalar_scoring_scheme ( scoring_scheme_t const &  scoring_scheme)
inlineconstexprprivate

Store the given scoring scheme matrix into a private member variable.

Template Parameters
scoring_scheme_tThe type of the scoring scheme; must model seqan3::scoring_scheme_for the given alphabet type.
Parameters
[in]scoring_schemeThe scoring scheme to initialise the vectorised match and mismatch score with.
Exceptions
std::invalid_argumentif the score of the given scoring scheme exceeds the score range covered by the selected simd vector type.

◆ make_score_profile()

template<simd_concept simd_score_t, semialphabet alphabet_t, typename alignment_t >
constexpr simd_score_profile_type seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t >::make_score_profile ( simd_alphabet_ranks_type const &  ranks) const
inlineconstexprnoexcept

Converts the simd alphabet ranks into a score profile used for scoring it later with the alphabet ranks of another sequence batch.

In this implementation of the simd matrix gather operations are used to select the score values from the underlying scoring scheme. Since the scoring scheme matrix is represented as a linear vector, the corresponding indices are computed by the alphabet rank of one sequence batch times the alphabet size plus the alphabet rank of another sequence batch.

◆ operator=()

template<simd_concept simd_score_t, semialphabet alphabet_t, typename alignment_t >
template<typename scoring_scheme_t >
constexpr simd_matrix_scoring_scheme & seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t >::operator= ( scoring_scheme_t const &  scoring_scheme)
inlineconstexpr

Store the given scoring scheme matrix into a private member variable.

Template Parameters
scoring_scheme_tThe type of the scoring scheme; must model seqan3::scoring_scheme_for the given alphabet type.
Parameters
[in]scoring_schemeThe scoring scheme to initialise the vectorised match and mismatch score with.
Exceptions
std::invalid_argumentif the score of the given scoring scheme exceeds the score range covered by the selected simd vector type.

◆ score()

template<simd_concept simd_score_t, semialphabet alphabet_t, typename alignment_t >
constexpr simd_score_t seqan3::detail::simd_matrix_scoring_scheme< simd_score_t, alphabet_t, alignment_t >::score ( simd_score_profile_type const &  score_profile,
simd_alphabet_ranks_type const &  ranks 
) const
inlineconstexprnoexcept

Given two simd vectors, compute an element-wise score and return another simd vector.

Parameters
[in]score_profileThe precomputed score profile.
[in]ranksA simd vector over alphabet ranks.
Returns
A score simd vector computed based on the given score profile and alphabet ranks.

Exception

No-throw guarantee.

Complexity

Linear in the length of one input vector (score_profile and ranks are equally sized).

Thread safety

Thread-safe.

Attention
You need to call seqan3::detail::simd_matrix_scoring_scheme::make_score_profile before invoking the score interface to convert the column alphabet ranks into a column profile. Not doing this cannot be detected by the program and can lead to wrong results.

The documentation for this class was generated from the following file:
Hide me