SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
|
Implements the tracker to store the global optimum for a particular alignment computation. More...
#include <seqan3/alignment/pairwise/detail/policy_optimum_tracker_simd.hpp>
Protected Types | |
using | base_policy_t = policy_optimum_tracker< alignment_configuration_t, optimum_updater_t > |
The type of the base class. | |
using | original_score_type = typename traits_type::original_score_type |
The original non-simd score type. | |
using | scalar_type = typename simd::simd_traits< score_type >::scalar_type |
The scalar type of the simd vector. | |
using | score_type = typename traits_type::score_type |
The configured score type. | |
using | traits_type = alignment_configuration_traits< alignment_configuration_t > |
The configuration traits type. | |
Protected Types inherited from seqan3::detail::policy_optimum_tracker< alignment_configuration_t, optimum_updater_t > | |
using | matrix_coordinate_type = typename traits_type::matrix_coordinate_type |
The matrix coordinate type that is used to locate a cell inside of the alignment matrix. | |
using | score_type = typename traits_type::score_type |
The configured score type. | |
using | traits_type = alignment_configuration_traits< alignment_configuration_t > |
The configuration traits type. | |
Protected Member Functions | |
template<std::ranges::input_range sequence1_collection_t, std::ranges::input_range sequence2_collection_t> | |
void | initialise_tracker (sequence1_collection_t &sequence1_collection, sequence2_collection_t &sequence2_collection) |
Initialises the tracker and possibly the binary update operation. | |
void | reset_optimum () |
Resets the optimum such that a new alignment can be computed. | |
Constructors, destructor and assignment | |
policy_optimum_tracker_simd ()=default | |
Defaulted. | |
policy_optimum_tracker_simd (policy_optimum_tracker_simd const &)=default | |
Defaulted. | |
policy_optimum_tracker_simd (policy_optimum_tracker_simd &&)=default | |
Defaulted. | |
policy_optimum_tracker_simd & | operator= (policy_optimum_tracker_simd const &)=default |
Defaulted. | |
policy_optimum_tracker_simd & | operator= (policy_optimum_tracker_simd &&)=default |
Defaulted. | |
~policy_optimum_tracker_simd ()=default | |
Defaulted. | |
policy_optimum_tracker_simd (alignment_configuration_t const &config) | |
Construction and initialisation using the alignment configuration. | |
Protected Member Functions inherited from seqan3::detail::policy_optimum_tracker< alignment_configuration_t, optimum_updater_t > | |
template<typename cell_t > | |
void | invoke_comparator (cell_t &&cell, matrix_coordinate_type coordinate) noexcept |
Handles the invocation of the optimum comparator and updater. | |
void | reset_optimum () noexcept |
Resets the optimum such that a new alignment can be computed. | |
template<typename cell_t > | |
decltype(auto) | track_cell (cell_t &&cell, matrix_coordinate_type coordinate) noexcept |
Tracks any cell within the alignment matrix. | |
template<typename cell_t > | |
decltype(auto) | track_final_cell (cell_t &&cell, matrix_coordinate_type coordinate) noexcept |
Tracks the final cell of the alignment matrix. | |
template<typename cell_t > | |
decltype(auto) | track_last_column_cell (cell_t &&cell, matrix_coordinate_type coordinate) noexcept |
Tracks the last cell of a column within the alignment matrix. | |
template<typename cell_t > | |
decltype(auto) | track_last_row_cell (cell_t &&cell, matrix_coordinate_type coordinate) noexcept |
Tracks the last cell of a row within the alignment matrix. | |
policy_optimum_tracker ()=default | |
Defaulted. | |
policy_optimum_tracker (policy_optimum_tracker const &)=default | |
Defaulted. | |
policy_optimum_tracker (policy_optimum_tracker &&)=default | |
Defaulted. | |
policy_optimum_tracker & | operator= (policy_optimum_tracker const &)=default |
Defaulted. | |
policy_optimum_tracker & | operator= (policy_optimum_tracker &&)=default |
Defaulted. | |
~policy_optimum_tracker ()=default | |
Defaulted. | |
policy_optimum_tracker (alignment_configuration_t const &config) | |
Construction and initialisation using the alignment configuration. | |
Protected Attributes | |
optimum_updater_t | compare_and_set_optimum |
The function object to compare and exchange the optimum. | |
matrix_coordinate_type | optimal_coordinate |
The matrix coordinate of the tracked optimum. | |
score_type | optimal_score |
The tracked score of the global optimum. | |
std::array< original_score_type, simd_traits< score_type >::length > | padding_offsets {} |
The individual offsets used for padding the sequences. | |
Protected Attributes inherited from seqan3::detail::policy_optimum_tracker< alignment_configuration_t, optimum_updater_t > | |
optimum_updater_t | compare_and_set_optimum {} |
The function object to compare and exchange the optimum. | |
matrix_coordinate_type | optimal_coordinate {} |
The matrix coordinate of the tracked optimum. | |
score_type | optimal_score {} |
The tracked score of the global optimum. | |
bool | test_every_cell {false} |
Whether every cell of the alignment matrix shall be tracked. | |
bool | test_last_column_cell {false} |
Whether cells of the last column shall be tracked. | |
bool | test_last_row_cell {false} |
Whether cells of the last row shall be tracked. | |
Implements the tracker to store the global optimum for a particular alignment computation.
alignment_configuration_t | The type of the alignment configuration; must be a type specialisation of seqan3::configuration. |
optimum_updater_t | The type of the optimum update operation, which compares and updates the alignment optimum with the current cell; must model std::semiregular. |
Implements the interface to track the alignment optimum. It updates the currently stored optimum using the optimum update operation. The optimum update operation is stored inside of the class and can have a state. The optimum updater must be invokable with a reference to the optimal score and coordinate and the score and coordinate of the current cell. Special methods are offered to track any cell (for example when computing the local alignment), the last cell of a column or a row (for example when using free-end gaps), or the final cell of the entire matrix (for example in the standard global alignment). The optimum needs to be reset in between alignment computations in order to ensure that the correct result is tracked.
|
inlineprotected |
Construction and initialisation using the alignment configuration.
[in] | config | The alignment configuration (not used in this context). |
Initialises the object to always track the last row and column, since this is needed for the vectorised global alignment.
|
inlineprotected |
Initialises the tracker and possibly the binary update operation.
sequence1_collection_t | The type of the sequence collection; must model std::ranges::input_range. |
sequence2_collection_t | The type of the sequence collection; must model std::ranges::input_range. |
[in] | sequence1_collection | The collection over sequences used for the initialisation of the tracker. |
[in] | sequence2_collection | The collection over sequences used for the initialisation of the tracker. |
Initialises the binary max score operation by pre-computing the coordinates for each individual matrix at which the global alignment score can be found. Inside of the inter-sequence vectorisation layout the sequences might have different sizes. Thus, the end coordinate for each individual alignment matrix can differ. The score is populated to the end of the matrix and only the respective coordinates are tracked for the optimal score. Finally, the added offset is removed from the score to obtain the true value.
Consider the following collections: collection 1: ["aaa", "aa", "a"] collection 2: [ "a", "aa", "aaa"]
Based on the length of the sequences the encompassing alignment matrix has the dimensions 4x4. The following graphic depicts this matrix. The number i
marks the last cell for the contained matrix given the sequence pair from above: 1 -> (3,1); 2 -> (2,2); 3 -> (1,3)
As can be seen, the end of each matrix must not necessarily be the end of the encompassing matrix. To avoid tracking every cell in the matrix the end point candidates will be projected along the diagonal to the last row or column of the encompassing matrix. In the example above, 1 and 3 are projected with an offset of 0
, while 2 is projected to the coordinate (3,3) with an projection offset of 1
. During the computation of the alignment the simd scoring scheme ensures that outside of the original matrix a fixed cost is added to every cell. The original score is shifted by this cost multiplied with the computed projection offset. In the global alignment it is suffcient to only track the optimal score in the last row and column of the encompassing matrix and only at the precomputed coordinate projections. Eventually, the score offset is subtracted to obtain the original score.
|
inlineprotected |
Resets the optimum such that a new alignment can be computed.