SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
policy_affine_gap_with_trace_recursion.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
13
14namespace seqan3::detail
15{
16
22template <typename alignment_configuration_t>
23class policy_affine_gap_with_trace_recursion : protected policy_affine_gap_recursion<alignment_configuration_t>
24{
25protected:
28
29 // Import base types.
30 using typename base_t::affine_score_tuple_t;
31 using typename base_t::score_type;
32 using typename base_t::traits_type;
33
40
41 // Import base member.
46
58
60 explicit policy_affine_gap_with_trace_recursion(alignment_configuration_t const & config) : base_t{config}
61 {}
63
65 template <typename affine_cell_t>
67 affine_cell_t previous_cell,
68 score_type const sequence_score) const noexcept
69 {
70 diagonal_score += sequence_score;
71 score_type horizontal_score = previous_cell.horizontal_score();
72 score_type vertical_score = previous_cell.vertical_score();
74
75 diagonal_score = (diagonal_score < vertical_score)
76 ? (best_trace = previous_cell.vertical_trace(), vertical_score)
77 : (best_trace |= previous_cell.vertical_trace(), diagonal_score);
78 diagonal_score =
79 (diagonal_score < horizontal_score)
80 ? (best_trace = previous_cell.horizontal_trace() | (best_trace & trace_directions::carry_up_open),
81 horizontal_score)
82 : (best_trace |= previous_cell.horizontal_trace(), diagonal_score);
83
84 score_type tmp = diagonal_score + gap_open_score;
85 vertical_score += gap_extension_score;
86 horizontal_score += gap_extension_score;
87
88 // store the vertical_score and horizontal_score value in the next path
89 trace_directions next_vertical_trace = trace_directions::up;
90 trace_directions next_horizontal_trace = trace_directions::left;
91
92 vertical_score =
93 (vertical_score < tmp) ? (next_vertical_trace = trace_directions::up_open, tmp) : vertical_score;
94 horizontal_score =
95 (horizontal_score < tmp) ? (next_horizontal_trace = trace_directions::left_open, tmp) : horizontal_score;
96
97 return {{diagonal_score, horizontal_score, vertical_score},
98 {best_trace, next_horizontal_trace, next_vertical_trace}};
99 }
100
109
111 template <typename affine_cell_t>
112 affine_cell_type initialise_first_column_cell(affine_cell_t previous_cell) const noexcept
113 {
114 return {base_t::initialise_first_column_cell(previous_cell),
115 {previous_cell.vertical_trace(),
118 }
119
121 template <typename affine_cell_t>
122 affine_cell_type initialise_first_row_cell(affine_cell_t previous_cell) const noexcept
123 {
124 return {base_t::initialise_first_row_cell(previous_cell),
125 {previous_cell.horizontal_trace(),
128 }
129};
130} // namespace seqan3::detail
A proxy for an affine score matrix cell.
Definition affine_cell_proxy.hpp:114
decltype(auto) horizontal_score() &noexcept
Access the horizontal score of the wrapped score matrix cell.
Definition affine_cell_proxy.hpp:210
decltype(auto) vertical_trace() &noexcept
Access the vertical score of the wrapped score matrix cell.
Definition affine_cell_proxy.hpp:307
decltype(auto) horizontal_trace() &noexcept
Access the horizontal score of the wrapped score matrix cell.
Definition affine_cell_proxy.hpp:282
Implements the alignment recursion function for the alignment algorithm using affine gap costs.
Definition policy_affine_gap_recursion.hpp:42
bool first_row_is_free
Initialisation state of the first row of the alignment.
Definition policy_affine_gap_recursion.hpp:61
affine_cell_type initialise_first_row_cell(affine_cell_t previous_cell) const noexcept
Initialises the first cell of a alignment matrix column.
Definition policy_affine_gap_recursion.hpp:194
affine_cell_type initialise_origin_cell() const noexcept
Initialises the first cell of the alignment matrix in the top left corner of the matrix.
Definition policy_affine_gap_recursion.hpp:149
score_type gap_extension_score
The score for a gap extension.
Definition policy_affine_gap_recursion.hpp:56
typename traits_type::score_type score_type
The configured score type.
Definition policy_affine_gap_recursion.hpp:49
score_type gap_open_score
The score for a gap opening including the gap extension.
Definition policy_affine_gap_recursion.hpp:58
bool first_column_is_free
Initialisation state of the first column of the alignment.
Definition policy_affine_gap_recursion.hpp:63
std::tuple< score_type, score_type, score_type > affine_score_tuple_t
The internal tuple storing the scores of an affine cell.
Definition policy_affine_gap_recursion.hpp:51
affine_cell_type initialise_first_column_cell(affine_cell_t previous_cell) const noexcept
Initialises a cell of the first alignment matrix column.
Definition policy_affine_gap_recursion.hpp:171
alignment_configuration_traits< alignment_configuration_t > traits_type
The configuration traits type.
Definition policy_affine_gap_recursion.hpp:45
Implements the alignment recursion function for the alignment algorithm using affine gap costs with t...
Definition policy_affine_gap_with_trace_recursion.hpp:24
policy_affine_gap_with_trace_recursion(policy_affine_gap_with_trace_recursion const &)=default
Defaulted.
policy_affine_gap_with_trace_recursion(alignment_configuration_t const &config)
Defaulted.
Definition policy_affine_gap_with_trace_recursion.hpp:60
policy_affine_gap_with_trace_recursion & operator=(policy_affine_gap_with_trace_recursion const &)=default
Defaulted.
bool first_row_is_free
Initialisation state of the first row of the alignment.
Definition policy_affine_gap_recursion.hpp:61
policy_affine_gap_with_trace_recursion(policy_affine_gap_with_trace_recursion &&)=default
Defaulted.
typename traits_type::trace_type trace_type
The trace type to use.
Definition policy_affine_gap_with_trace_recursion.hpp:35
affine_cell_type initialise_first_column_cell(affine_cell_t previous_cell) const noexcept
Initialises a cell of the first alignment matrix column.
Definition policy_affine_gap_with_trace_recursion.hpp:112
score_type gap_extension_score
The score for a gap extension.
Definition policy_affine_gap_recursion.hpp:56
typename traits_type::score_type score_type
The configured score type.
Definition policy_affine_gap_recursion.hpp:49
affine_cell_type initialise_origin_cell() const noexcept
Initialises the first cell of the alignment matrix in the top left corner of the matrix.
Definition policy_affine_gap_with_trace_recursion.hpp:102
score_type gap_open_score
The score for a gap opening including the gap extension.
Definition policy_affine_gap_recursion.hpp:58
bool first_column_is_free
Initialisation state of the first column of the alignment.
Definition policy_affine_gap_recursion.hpp:63
affine_cell_type compute_inner_cell(score_type diagonal_score, affine_cell_t previous_cell, score_type const sequence_score) const noexcept
Computes an inner cell of the alignment matrix.
Definition policy_affine_gap_with_trace_recursion.hpp:66
affine_cell_type initialise_first_row_cell(affine_cell_t previous_cell) const noexcept
Initialises the first cell of a alignment matrix column.
Definition policy_affine_gap_with_trace_recursion.hpp:122
policy_affine_gap_with_trace_recursion & operator=(policy_affine_gap_with_trace_recursion &&)=default
Defaulted.
trace_directions
The possible directions a trace can have. The values can be combined by the logical |-operator.
Definition trace_directions.hpp:26
@ up
Trace comes from the above entry.
@ left
Trace comes from the left entry.
@ diagonal
Trace comes from the diagonal entry.
@ carry_up_open
Carry bit for the last up open even if it is not the maximum value.
@ left_open
Trace comes from the left entry, while opening the gap.
@ up_open
Trace comes from the above entry, while opening the gap.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides seqan3::detail::policy_affine_gap_recursion.
std::conditional_t< is_vectorised, simd_type_t< original_score_type >, trace_directions > trace_type
The trace directions type for the alignment algorithm.
Definition alignment/pairwise/detail/type_traits.hpp:135
Hide me