SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::max_score_banded_updater Struct Reference

A function object that compares and possibly updates the alignment optimum with the current cell. More...

#include <seqan3/alignment/pairwise/detail/policy_optimum_tracker.hpp>

Public Member Functions

template<typename score_t , typename coordinate_t >
requires (std::totally_ordered<score_t> && std::assignable_from<score_t &, score_t const &> && std::assignable_from<coordinate_t &, coordinate_t const &>)
void operator() (score_t &optimal_score, coordinate_t &optimal_coordinate, score_t current_score, coordinate_t current_coordinate) const noexcept
 Compares and updates the optimal score-coordinate pair.
 
void set_target_indices (row_index_type< size_t > row_index, column_index_type< size_t > col_index) noexcept
 Sets the target index for the last row and column of the matrix.
 

Private Attributes

size_t target_col_index {}
 The column index indicating the last column of the alignment matrix.
 
size_t target_row_index {}
 The row index indicating the last row of the alignment matrix.
 

Detailed Description

A function object that compares and possibly updates the alignment optimum with the current cell.

This special function object is used for global alignments including free end-gaps. It updates the current alignment optimum with the new score and the respective coordinate if the new score is greater or equal to the score of the current optimum and the cell is either in the target row or column. For the banded alignment this additional check is needed because the band might not reach the last row of the matrix for all columns. Thus, the last cell of a column will only be checked if the corresponding coordinate points to the last row of the matrix.

Example

Consider the following banded matrix:

0 1
012345678901
____________
0 | \ |
1 | \ |
2 |\ \ |
3 | \ \ |
4 | \ *|
5 | \ *|
6 | ********|
––––––––––––

When computing the columns from index 0 to 3 the last row of the matrix is not covered by the band. But the algorithm that computes the column does not know if the last computed cell of it is in fact also the last cell of the matrix (row index 6). Thus, by comparing the cell coordinate, which corresponds to the absolute matrix coordinate, with the initialised target row and column index of this function object, it can be guaranteed that only the scores of the cells are tracked that are in the last row or column (cells marked with an * in the picture above).

See also
seqan3::detail::max_score_updater

Member Function Documentation

◆ operator()()

template<typename score_t , typename coordinate_t >
requires (std::totally_ordered<score_t> && std::assignable_from<score_t &, score_t const &> && std::assignable_from<coordinate_t &, coordinate_t const &>)
void seqan3::detail::max_score_banded_updater::operator() ( score_t &  optimal_score,
coordinate_t &  optimal_coordinate,
score_t  current_score,
coordinate_t  current_coordinate 
) const
inlinenoexcept

Compares and updates the optimal score-coordinate pair.

Template Parameters
score_tThe type of the score to track; must model std::totally_ordered and std::assignable_from const & score_t.
coordinate_tThe type of the coordinate to track; must model std::assignable_from const & coordinate_t.
Parameters
[in,out]optimal_scoreThe optimal score to update.
[in,out]optimal_coordinateThe optimal coordinate to update.
[in]current_scoreThe score of the current cell.
[in]current_coordinateThe coordinate of the current cell.

First, checks if the coordinate of the current alignment cell is either in the target row or column, i.e. the last row/column of the alignment matrix. If this is not the case the score won't be updated. Otherwise, compares the current_score with the optimal score and updates the optimal score and coordinate accordingly.

◆ set_target_indices()

void seqan3::detail::max_score_banded_updater::set_target_indices ( row_index_type< size_t >  row_index,
column_index_type< size_t >  col_index 
)
inlinenoexcept

Sets the target index for the last row and column of the matrix.

Parameters
row_indexThe target index of the last row.
col_indexThe target index of the last column.

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