SeqAn3 3.3.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// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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 <iterator>
16#include <ranges>
17#include <span>
18
24
25namespace seqan3::detail
26{
27
41template <typename score_t>
44 public alignment_matrix_column_major_range_base<alignment_score_matrix_one_column<score_t>>
45{
46private:
48 "The score type must be either an arithmetic type or a simd vector type.");
53
56
57protected:
58 using typename matrix_base_t::element_type;
59 using typename range_base_t::alignment_column_type;
62
64
65public:
77 using typename matrix_base_t::size_type;
78 using typename matrix_base_t::underlying_type;
80
85 constexpr alignment_score_matrix_one_column() = default;
96
110 template <std::ranges::forward_range first_sequence_t, std::ranges::forward_range second_sequence_t>
111 constexpr alignment_score_matrix_one_column(first_sequence_t && first,
112 second_sequence_t && second,
113 score_t const initial_value = score_t{})
114 {
115 matrix_base_t::num_cols = static_cast<size_type>(std::ranges::distance(first) + 1);
116 matrix_base_t::num_rows = static_cast<size_type>(std::ranges::distance(second) + 1);
117 matrix_base_t::pool.resize(matrix_base_t::num_rows + 1, element_type{initial_value, initial_value});
118 }
120
121private:
123 constexpr alignment_column_type initialise_column(size_type const SEQAN3_DOXYGEN_ONLY(column_index)) noexcept
124 {
125 return alignment_column_type{
126 *this,
128 }
129
131 template <std::random_access_iterator iter_t>
132 constexpr value_type make_proxy(iter_t host_iter) noexcept
133 {
134 return {std::get<0>(*host_iter), // current
135 std::get<0>(matrix_base_t::cache), // last diagonal
136 std::get<1>(*host_iter), // last left (read)
137 std::get<1>(*host_iter), // next left (write)
138 std::get<2>(matrix_base_t::cache)}; // last up
139 }
140
142 template <std::random_access_iterator iter_t>
143 constexpr void on_column_iterator_creation(iter_t host_iter) noexcept
144 {
145 // Cache the next diagonal value.
146 std::get<1>(matrix_base_t::cache) = std::get<0>(*host_iter);
147 }
148
150 template <std::random_access_iterator iter_t>
151 constexpr void before_column_iterator_increment(iter_t SEQAN3_DOXYGEN_ONLY(host_iter)) noexcept
152 {
153 // Update the last diagonal value.
154 std::get<0>(matrix_base_t::cache) = std::move(std::get<1>(matrix_base_t::cache));
155 }
156
158 template <std::random_access_iterator iter_t>
159 constexpr void after_column_iterator_increment(iter_t host_iter) noexcept
160 {
161 // Cache the next diagonal value.
162 std::get<1>(matrix_base_t::cache) = std::move(std::get<0>(*host_iter));
163 }
164};
165
166} // 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.
Provides a range interface for alignment matrices.
Definition: alignment_matrix_column_major_range_base.hpp:63
std::default_sentinel_t sentinel
The type of sentinel.
Definition: alignment_matrix_column_major_range_base.hpp:480
iterator_type iterator
The type of the iterator.
Definition: alignment_matrix_column_major_range_base.hpp:478
An alignment score matrix storing only a single column for the computation.
Definition: alignment_score_matrix_one_column.hpp:45
alignment_score_matrix_proxy< score_t > value_type
The proxy type of an alignment matrix.
Definition: alignment_score_matrix_one_column.hpp:70
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:132
size_t size_type
The size type.
Definition: alignment_score_matrix_one_column_base.hpp:51
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:111
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:143
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:159
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:74
friend range_base_t
Befriend the range base class.
Definition: alignment_score_matrix_one_column.hpp:55
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:151
typename range_base_t::sentinel sentinel
The type of sentinel.
Definition: alignment_score_matrix_one_column.hpp:76
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:123
std::tuple< underlying_type, underlying_type > element_type
The actual element type.
Definition: alignment_score_matrix_one_column_base.hpp:45
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.
A type that satisfies std::is_arithmetic_v<t>.
The generic simd concept.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
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:37
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:57
pool_type pool
The linearised memory pool storing only one column of the matrix.
Definition: alignment_score_matrix_one_column_base.hpp:55
size_t size_type
The size type.
Definition: alignment_score_matrix_one_column_base.hpp:51
score_t underlying_type
The underlying type of the scores.
Definition: alignment_score_matrix_one_column_base.hpp:43
size_type num_rows
The number of num_rows.
Definition: alignment_score_matrix_one_column_base.hpp:61
std::tuple< underlying_type, underlying_type > element_type
The actual element type.
Definition: alignment_score_matrix_one_column_base.hpp:45
size_type num_cols
The number of columns.
Definition: alignment_score_matrix_one_column_base.hpp:59
A proxy type for a unified access to the score matrix during alignment computation.
Definition: alignment_score_matrix_proxy.hpp:36
Provides concepts that do not have equivalents in C++20.
Provides seqan3::simd::simd_concept.