SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t > Class Template Reference

The CRTP-policy to determine the optimum of the dynamic programming matrix. More...

#include <seqan3/alignment/pairwise/policy/simd_find_optimum_policy.hpp>

+ Inheritance diagram for seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >:

Protected Member Functions

template<typename cell_t , typename score_t >
constexpr void check_score_of_cell (cell_t const &current_cell, alignment_algorithm_state< score_t > &state) const noexcept
 Checks if a given cell is a new optimum in the alignment.
 
template<typename alignment_column_t , typename score_t >
constexpr void check_score_of_cells_in_last_column (alignment_column_t &&last_column, alignment_algorithm_state< score_t > &state) const noexcept
 Checks all cells of the last alignment column for a new alignment optimum.
 
template<typename cell_t , typename score_t >
constexpr void check_score_of_last_cell (cell_t const &last_cell, alignment_algorithm_state< score_t > &state) const noexcept
 Checks if the last cell of the alignment matrix is a new optimum in the alignment.
 
template<typename cell_t , typename score_t >
constexpr void check_score_of_last_row_cell (cell_t const &last_row_cell, alignment_algorithm_state< score_t > &state) const noexcept
 Checks if a cell in the last row of the alignment matrix is a new optimum in the alignment.
 
template<std::ranges::forward_range sequence1_collection_t, std::ranges::forward_range sequence2_collection_t, arithmetic score_t>
void initialise_find_optimum_policy (sequence1_collection_t &&sequence1_collection, sequence2_collection_t &&sequence2_collection, score_t const padding_score)
 Initialises the global alignment state for the current batch of sequences.
 

Private Member Functions

template<typename cell_t , typename score_t >
constexpr void check_and_update (cell_t const &cell, alignment_algorithm_state< score_t > &state) const noexcept
 Tests if the score in the current cell is greater than the current alignment optimum.
 
template<bool in_last_row, typename cell_t , typename score_t >
constexpr void check_and_update (cell_t const &cell, alignment_algorithm_state< score_t > &state) const noexcept
 Tests if the current row, respectively column, is part of a global alignment to track.
 
Constructors, destructor and assignment
constexpr simd_find_optimum_policy ()=default
 Defaulted.
 
constexpr simd_find_optimum_policy (simd_find_optimum_policy const &)=default
 Defaulted.
 
constexpr simd_find_optimum_policy (simd_find_optimum_policy &&)=default
 Defaulted.
 
constexpr simd_find_optimum_policyoperator= (simd_find_optimum_policy const &)=default
 Defaulted.
 
constexpr simd_find_optimum_policyoperator= (simd_find_optimum_policy &&)=default
 Defaulted.
 
 ~simd_find_optimum_policy ()=default
 Defaulted.
 
template<typename configuration_t >
 simd_find_optimum_policy (configuration_t const &config)
 Initialise the policy.
 

Private Attributes

friend alignment_algorithm_t
 Befriends the derived class to grant it access to the private members.
 
bool is_global_alignment {false}
 A flag to check if global alignment is computed.
 
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.
 

Friends

template<typename other_alignment_algorithm_t >
class affine_gap_init_policy
 Allow seqan3::detail::affine_gap_init_policy to access check_score.
 
template<typename other_alignment_algorithm_t , simd_concept score_t, typename is_local_t >
class simd_affine_gap_policy
 Befriend the seqan3::detail::simd_affine_gap_policy to grant access to the check_score_of_cell function.
 

Additional Inherited Members

- Public Attributes inherited from seqan3::detail::simd_global_alignment_state< simd_t >
simd_t coordinate_offset {}
 A coordinate offset that needs to be subtracted for every alignment to get the correct end position.
 
simd_t last_column_mask {}
 A mask vector storing the row indices for alignments that end in the last column of the global matrix.
 
simd_t last_row_mask {}
 A mask vector storing the column indices for alignments that end in the last row of the global matrix.
 
simd_t score_offset {}
 The score offset that needs to be subtracted for every alignment to get the correct result.
 

Detailed Description

template<typename alignment_algorithm_t, simd::simd_concept simd_t>
class seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >

The CRTP-policy to determine the optimum of the dynamic programming matrix.

Template Parameters
alignment_algorithm_tThe derived type (seqan3::detail::alignment_algorithm) to be augmented with this CRTP-policy.
simd_tThe simd vector type used for computing the scores; must model seqan3::simd::simd_concept.

This class determines the matrix wide optimum. The search space can be further refined using the traits_type which configures the search space of the alignment matrix.

This class inherits from seqan3::detail::simd_global_alignment_state if it is a global alignment, otherwise it inherits from seqan3::detail::empty_type that is optimised away due to empty base class optimisation. The tracking behaviour for the optimum of the global alignment is slightly modified compared to the local alignment or free end gap computation. Specifically, instead of checking for a new optimal score the coordinates are checked. For the global alignment the cell which contains the optimum is already fixed (the sink of each matrix). To account for different sizes of the sequences a padding match score is used to always add match scores after the end of a smaller sequence has been reached. Accordingly, the target score will be mapped to a cell on the last row or last column of the global matrix. Note the dimensions of the global matrix is defined by the size of the longest sequence in collection 1 and 2 respectively. If the last cell of any of the contained matrices is projected to a cell on the last row (following the diagonal going through the sink of this particular matrix), then the column indices are tested to check if any sequence ends in this projected end point. Similarly, if the last cell is projected to a cell on the last column, then the row indices are compared. The found score as well as the indices are finally corrected to represent the original score and coordinates as if the sequence pair was computed in scalar mode.

Member Function Documentation

◆ check_and_update() [1/2]

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<typename cell_t , typename score_t >
constexpr void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::check_and_update ( cell_t const &  cell,
alignment_algorithm_state< score_t > &  state 
) const
inlineconstexprprivatenoexcept

Tests if the score in the current cell is greater than the current alignment optimum.

Template Parameters
cell_tThe type of the alignment matrix cell. The cell type corresponds to the value type of the range returned by seqan3::detail::alignment_matrix_policy::current_alignment_column.
score_tThe alignment algorithm score type.
Parameters
[in]cellThe current cell to get the score and the coordinate from.
[in,out]stateThe state with the current optimum to update.

◆ check_and_update() [2/2]

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<bool in_last_row, typename cell_t , typename score_t >
constexpr void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::check_and_update ( cell_t const &  cell,
alignment_algorithm_state< score_t > &  state 
) const
inlineconstexprprivatenoexcept

Tests if the current row, respectively column, is part of a global alignment to track.

Template Parameters
in_last_rowA bool constant to indicate whether this check is done for the last row.
cell_tThe type of the alignment matrix cell. The cell type corresponds to the value type of the range returned by seqan3::detail::alignment_matrix_policy::current_alignment_column.
score_tThe alignment algorithm score type.
Parameters
[in]cellThe current cell to get the score and the coordinate from.
[in,out]stateThe state with the current optimum to update.

Checks for the last row if the current column coordinate matches any column coordinate stored in the mask for the last row, respectively for the last column if the current row coordinate matches any row coordinate stored in the mask for the last column.

◆ check_score_of_cell()

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<typename cell_t , typename score_t >
constexpr void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::check_score_of_cell ( cell_t const &  current_cell,
alignment_algorithm_state< score_t > &  state 
) const
inlineconstexprprotectednoexcept

Checks if a given cell is a new optimum in the alignment.

Template Parameters
cell_tThe type of the alignment matrix cell.
score_tThe type of the score.
Parameters
[in]current_cellThe currently computed alignment matrix cell.
[in,out]stateThe state with the current optimum to update.

This function resolves to a "NO-OP" function if the trait for searching every cell is set to std::false_type.

◆ check_score_of_cells_in_last_column()

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<typename alignment_column_t , typename score_t >
constexpr void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::check_score_of_cells_in_last_column ( alignment_column_t &&  last_column,
alignment_algorithm_state< score_t > &  state 
) const
inlineconstexprprotectednoexcept

Checks all cells of the last alignment column for a new alignment optimum.

Template Parameters
alignment_column_tThe type of an alignment column.
score_tThe type of the optimal score.
Parameters
[in]last_columnThe last column of the alignment matrix.
[in,out]stateThe state with the current optimum to update.

This function resolves to a "NO-OP" function if the trait for searching the last column is set to std::false_type or if the trait for searching every cell is set to std::true_type.

◆ check_score_of_last_cell()

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<typename cell_t , typename score_t >
constexpr void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::check_score_of_last_cell ( cell_t const &  last_cell,
alignment_algorithm_state< score_t > &  state 
) const
inlineconstexprprotectednoexcept

Checks if the last cell of the alignment matrix is a new optimum in the alignment.

Template Parameters
cell_tThe type of the last cell.
score_tThe type of the score.
Parameters
[in]last_cellThe last cell of the alignment matrix.
[in,out]stateThe state with the current optimum to update.

This function resolves to a "NO-OP" function if the last cell has been checked already as part of the last row, last column, or in case every cell was checked.

◆ check_score_of_last_row_cell()

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<typename cell_t , typename score_t >
constexpr void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::check_score_of_last_row_cell ( cell_t const &  last_row_cell,
alignment_algorithm_state< score_t > &  state 
) const
inlineconstexprprotectednoexcept

Checks if a cell in the last row of the alignment matrix is a new optimum in the alignment.

Template Parameters
cell_tThe type of the alignment matrix cell.
score_tThe type of the score.
Parameters
[in]last_row_cellThe cell of the current column in the last row of the alignment matrix.
[in,out]stateThe state with the current optimum to update.

This function resolves to a "NO-OP" function if the trait for searching the last row is set to std::false_type or if the trait for searching every cell is set to std::true_type.

◆ initialise_find_optimum_policy()

template<typename alignment_algorithm_t , simd::simd_concept simd_t>
template<std::ranges::forward_range sequence1_collection_t, std::ranges::forward_range sequence2_collection_t, arithmetic score_t>
void seqan3::detail::simd_find_optimum_policy< alignment_algorithm_t, simd_t >::initialise_find_optimum_policy ( sequence1_collection_t &&  sequence1_collection,
sequence2_collection_t &&  sequence2_collection,
score_t const  padding_score 
)
inlineprotected

Initialises the global alignment state for the current batch of sequences.

Template Parameters
sequence1_collection_tThe type of the first collection; must model std::ranges::forward_range and the value type must model std::ranges::forward_range.
sequence2_collection_tThe type of the second collection; must model std::ranges::forward_range and the value type must model std::ranges::forward_range.
score_tThe type of the scoring scheme's padding score; must model seqan3::arithmetic.
Parameters
[in]sequence1_collectionThe first collection used for initialisation.
[in]sequence2_collectionThe second collection used for initialisation.
[in]padding_scoreThe padding match score used for determining the resulting score offset.

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