SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
alignment_optimum.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
12#include <concepts>
13#include <type_traits>
14
21
22namespace seqan3::detail
23{
24
38template <typename score_t>
40#if SEQAN3_DOXYGEN_ONLY(1) 0
41{
43 using index_t = IMPLEMENTATION_DEFINED;
44
50 score_t score = IMPLEMENTATION_DEFINED;
51
68 template <typename column_index_t, typename row_index_t>
69 void update_if_new_optimal_score(score_t const & compare_score,
72}
73#endif //SEQAN3_DOXYGEN_ONLY(1): This code block is only dis
74;
75
77template <arithmetic score_t>
78struct alignment_optimum<score_t>
79{
80 size_t column_index{};
81 size_t row_index{};
83
84 template <std::integral column_index_t, std::integral row_index_t>
85 constexpr void update_if_new_optimal_score(score_t const & compare_score,
86 column_index_type<column_index_t> column_index,
87 row_index_type<row_index_t> row_index) noexcept
88 {
89 score = (compare_score > score)
90 ? (this->column_index = column_index.get(), this->row_index = row_index.get(), compare_score)
91 : score;
92 }
93};
94
95template <simd_concept score_t>
96struct alignment_optimum<score_t>
97{
98 using scalar_t = typename simd_traits<score_t>::scalar_type;
99
100 score_t column_index{};
101 score_t row_index{};
102 score_t score{simd::fill<score_t>(std::numeric_limits<scalar_t>::lowest())};
103
104 template <std::integral column_index_t, std::integral row_index_t>
105 constexpr void update_if_new_optimal_score(score_t const & compare_score,
106 column_index_type<column_index_t> column_index,
107 row_index_type<row_index_t> row_index) noexcept
108 {
109 auto mask = compare_score > score;
110 score = mask ? compare_score : score;
111 this->column_index = mask ? simd::fill<score_t>(column_index.get()) : this->column_index;
112 this->row_index = mask ? simd::fill<score_t>(row_index.get()) : this->row_index;
113 }
114};
116
122alignment_optimum()->alignment_optimum<int32_t>;
123
125template <typename column_index_t, typename row_index_t, typename score_t>
126alignment_optimum(column_index_t, row_index_t, score_t) -> alignment_optimum<score_t>;
128
129} // namespace seqan3::detail
Provides algorithms to modify seqan3::simd::simd_type.
T lowest(T... args)
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
Provides seqan3::simd::simd_traits.
Stores the current optimum of the alignment algorithm.
Definition alignment_optimum.hpp:41
alignment_optimum() -> alignment_optimum< int32_t >
Default constructed objects deduce to int32_t.
IMPLEMENTATION_DEFINED index_t
The index type used to store the alignment coordinates of the optimum.
Definition alignment_optimum.hpp:43
index_t row_index
The index of the alignment matrix row.
Definition alignment_optimum.hpp:48
index_t column_index
The index of the alignment matrix column.
Definition alignment_optimum.hpp:46
score_t score
The optimal score whose initialisation is implementation defined.
Definition alignment_optimum.hpp:50
void update_if_new_optimal_score(score_t const &compare_score, column_index_type< column_index_t > column_index, row_index_type< row_index_t > row_index) noexcept
Compares the score with the given score and updates the optimum if the new score is bigger than the c...
alignment_optimum(column_index_t, row_index_t, score_t) -> alignment_optimum< score_t >
Construction from column index, row index and the score deduces the score type.
A strong type for designated initialisation of the column index of a matrix.
Definition matrix_coordinate.hpp:29
A strong type for designated initialisation of the row index of a matrix.
Definition matrix_coordinate.hpp:58
Provides type traits for working with templates.
Provides concepts that do not have equivalents in C++20.
Provides seqan3::simd::simd_concept.
Hide me