SeqAn3 3.2.0-rc.1
The Modern C++ library for sequence analysis.
alignment_optimum.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2021, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
15#include <concepts>
16#include <type_traits>
17
24
25namespace seqan3::detail
26{
27
41template <typename score_t>
43#if SEQAN3_DOXYGEN_ONLY(1)0
44{
46 using index_t = IMPLEMENTATION_DEFINED;
47
53 score_t score = IMPLEMENTATION_DEFINED;
54
71 template <typename column_index_t, typename row_index_t>
72 void update_if_new_optimal_score(score_t const & compare_score,
75}
76#endif //SEQAN3_DOXYGEN_ONLY(1): This code block is only dis
77;
78
80template <arithmetic score_t>
81struct alignment_optimum<score_t>
82{
83 size_t column_index{};
84 size_t row_index{};
86
87 template <std::integral column_index_t, std::integral row_index_t>
88 constexpr void update_if_new_optimal_score(score_t const & compare_score,
89 column_index_type<column_index_t> column_index,
90 row_index_type<row_index_t> row_index) noexcept
91 {
92 score = (compare_score > score)
93 ? (this->column_index = column_index.get(), this->row_index = row_index.get(), compare_score)
94 : score;
95 }
96};
97
98template <simd_concept score_t>
99struct alignment_optimum<score_t>
100{
101 using scalar_t = typename simd_traits<score_t>::scalar_type;
102
103 score_t column_index{};
104 score_t row_index{};
105 score_t score{simd::fill<score_t>(std::numeric_limits<scalar_t>::lowest())};
106
107 template <std::integral column_index_t, std::integral row_index_t>
108 constexpr void update_if_new_optimal_score(score_t const & compare_score,
109 column_index_type<column_index_t> column_index,
110 row_index_type<row_index_t> row_index) noexcept
111 {
112 auto mask = compare_score > score;
113 score = mask ? compare_score : score;
114 this->column_index = mask ? simd::fill<score_t>(column_index.get()) : this->column_index;
115 this->row_index = mask ? simd::fill<score_t>(row_index.get()) : this->row_index;
116 }
117};
119
126
128template <typename column_index_t, typename row_index_t, typename score_t>
129alignment_optimum(column_index_t, row_index_t, score_t) -> alignment_optimum<score_t>;
131
132} // 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:29
Provides seqan3::simd::simd_traits.
Stores the current optimum of the alignment algorithm.
Definition: alignment_optimum.hpp:44
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:46
index_t row_index
The index of the alignment matrix row.
Definition: alignment_optimum.hpp:51
index_t column_index
The index of the alignment matrix column.
Definition: alignment_optimum.hpp:49
score_t score
The optimal score whose initialisation is implementation defined.
Definition: alignment_optimum.hpp:53
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:34
A strong type for designated initialisation of the row index of a matrix.
Definition: matrix_coordinate.hpp:65
Provides type traits for working with templates.
Provides concepts that do not have equivalents in C++20.
Provides seqan3::simd::simd_concept.