SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
alignment_score_matrix_one_column.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 <iterator>
13#include <ranges>
14#include <span>
15
21
22namespace seqan3::detail
23{
24
38template <typename score_t>
41 public alignment_matrix_column_major_range_base<alignment_score_matrix_one_column<score_t>>
42{
43private:
45 "The score type must be either an arithmetic type or a simd vector type.");
50
53
54protected:
56 using typename range_base_t::alignment_column_type;
59
61
62public:
77
82 constexpr alignment_score_matrix_one_column() = default;
93
107 template <std::ranges::forward_range first_sequence_t, std::ranges::forward_range second_sequence_t>
109 second_sequence_t && second,
110 score_t const initial_value = score_t{})
111 {
112 matrix_base_t::num_cols = static_cast<size_type>(std::ranges::distance(first) + 1);
113 matrix_base_t::num_rows = static_cast<size_type>(std::ranges::distance(second) + 1);
115 }
117
118private:
120 constexpr alignment_column_type initialise_column(size_type const SEQAN3_DOXYGEN_ONLY(column_index)) noexcept
121 {
122 return alignment_column_type{
123 *this,
125 }
126
128 template <std::random_access_iterator iter_t>
129 constexpr value_type make_proxy(iter_t host_iter) noexcept
130 {
131 return {std::get<0>(*host_iter), // current
132 std::get<0>(matrix_base_t::cache), // last diagonal
133 std::get<1>(*host_iter), // last left (read)
134 std::get<1>(*host_iter), // next left (write)
135 std::get<2>(matrix_base_t::cache)}; // last up
136 }
137
139 template <std::random_access_iterator iter_t>
140 constexpr void on_column_iterator_creation(iter_t host_iter) noexcept
141 {
142 // Cache the next diagonal value.
143 std::get<1>(matrix_base_t::cache) = std::get<0>(*host_iter);
144 }
145
147 template <std::random_access_iterator iter_t>
149 {
150 // Update the last diagonal value.
151 std::get<0>(matrix_base_t::cache) = std::move(std::get<1>(matrix_base_t::cache));
152 }
153
155 template <std::random_access_iterator iter_t>
156 constexpr void after_column_iterator_increment(iter_t host_iter) noexcept
157 {
158 // Cache the next diagonal value.
159 std::get<1>(matrix_base_t::cache) = std::move(std::get<0>(*host_iter));
160 }
161};
162
163} // namespace seqan3::detail
T addressof(T... args)
Provides seqan3::detail::alignment_matrix_column_major_range_base.
Provides seqan3::detail::alignment_score_matrix_one_column_base.
Provides seqan3::detail::alignment_score_matrix_proxy.
Allocates uninitialized storage whose memory-alignment is specified by alignment.
Definition aligned_allocator.hpp:74
Provides a range interface for alignment matrices.
Definition alignment_matrix_column_major_range_base.hpp:60
std::default_sentinel_t sentinel
The type of sentinel.
Definition alignment_matrix_column_major_range_base.hpp:477
iterator_type iterator
The type of the iterator.
Definition alignment_matrix_column_major_range_base.hpp:475
An alignment score matrix storing only a single column for the computation.
Definition alignment_score_matrix_one_column.hpp:42
alignment_score_matrix_proxy< score_t > value_type
The proxy type of an alignment matrix.
Definition alignment_score_matrix_one_column.hpp:67
constexpr value_type make_proxy(iter_t host_iter) noexcept
Creates the proxy value returned when dereferencing the alignment-column-iterator.
Definition alignment_score_matrix_one_column.hpp:129
size_t size_type
The size type.
Definition alignment_score_matrix_one_column_base.hpp:48
constexpr alignment_score_matrix_one_column & operator=(alignment_score_matrix_one_column const &)=default
Defaulted.
constexpr alignment_score_matrix_one_column(first_sequence_t &&first, second_sequence_t &&second, score_t const initial_value=score_t{})
Construction from two ranges.
Definition alignment_score_matrix_one_column.hpp:108
constexpr alignment_score_matrix_one_column(alignment_score_matrix_one_column &&)=default
Defaulted.
constexpr void on_column_iterator_creation(iter_t host_iter) noexcept
Allows additional initialisations when calling begin on an alignment-column.
Definition alignment_score_matrix_one_column.hpp:140
constexpr void after_column_iterator_increment(iter_t host_iter) noexcept
Allows to perform additional steps after incrementing the alignment-column-iterator.
Definition alignment_score_matrix_one_column.hpp:156
constexpr alignment_score_matrix_one_column()=default
Defaulted.
typename range_base_t::iterator iterator
The type of the iterator.
Definition alignment_score_matrix_one_column.hpp:71
friend range_base_t
Befriend the range base class.
Definition alignment_score_matrix_one_column.hpp:52
constexpr void before_column_iterator_increment(iter_t host_iter) noexcept
Allows to perform additional steps before incrementing the alignment-column-iterator.
Definition alignment_score_matrix_one_column.hpp:148
typename range_base_t::sentinel sentinel
The type of sentinel.
Definition alignment_score_matrix_one_column.hpp:73
constexpr alignment_column_type initialise_column(size_type const column_index) noexcept
Returns the current alignment-column at the given column_index.
Definition alignment_score_matrix_one_column.hpp:120
std::tuple< underlying_type, underlying_type > element_type
The actual element type.
Definition alignment_score_matrix_one_column_base.hpp:42
constexpr alignment_score_matrix_one_column(alignment_score_matrix_one_column const &)=default
Defaulted.
constexpr alignment_score_matrix_one_column & operator=(alignment_score_matrix_one_column &&)=default
Defaulted.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
T resize(T... args)
A base class for alignment score matrices using only one column to compute the matrix.
Definition alignment_score_matrix_one_column_base.hpp:34
std::array< underlying_type, 3 > cache
Internal cache for the last diagonal and vertical value during the alignment computation.
Definition alignment_score_matrix_one_column_base.hpp:54
pool_type pool
The linearised memory pool storing only one column of the matrix.
Definition alignment_score_matrix_one_column_base.hpp:52
size_t size_type
The size type.
Definition alignment_score_matrix_one_column_base.hpp:48
score_t underlying_type
The underlying type of the scores.
Definition alignment_score_matrix_one_column_base.hpp:40
size_type num_rows
The number of num_rows.
Definition alignment_score_matrix_one_column_base.hpp:58
std::tuple< underlying_type, underlying_type > element_type
The actual element type.
Definition alignment_score_matrix_one_column_base.hpp:42
aligned_allocator< element_type, sizeof(element_type)> allocator_type
The allocator type.
Definition alignment_score_matrix_one_column_base.hpp:44
size_type num_cols
The number of columns.
Definition alignment_score_matrix_one_column_base.hpp:56
Provides concepts that do not have equivalents in C++20.
Provides seqan3::simd::simd_concept.
Hide me