SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
type_traits.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 <ranges>
16#include <type_traits>
17
41
42namespace seqan3::detail
43{
44
45//------------------------------------------------------------------------------
46// chunked_indexed_sequence_pairs
47//------------------------------------------------------------------------------
48
61template <typename sequence_pairs_t>
62 requires sequence_pair_range<std::remove_reference_t<sequence_pairs_t>>
63struct chunked_indexed_sequence_pairs
64{
66 using type = decltype(views::zip(std::declval<sequence_pairs_t>(), std::views::iota(0)) | views::chunk(1));
67};
68
69//------------------------------------------------------------------------------
70// alignment_configuration_traits
71//------------------------------------------------------------------------------
72
80template <typename configuration_t>
81 requires is_type_specialisation_of_v<std::remove_cv_t<configuration_t>, configuration>
82struct alignment_configuration_traits
83{
84private:
95 template <arithmetic score_t>
96 using select_scalar_index_t = min_viable_uint_t<1ull << (bits_of<score_t> - 1)>;
97
99 static constexpr auto determine_alignment_result_type() noexcept
100 {
101 if constexpr (configuration_t::template exists<align_cfg::detail::result_type>())
102 {
104 std::declval<configuration_t>()))>;
105 return typename result_type_cfg_t::type{}; // Access the stored result_type.
106 }
107 else
108 {
109 return empty_type{};
110 }
111 }
112
113public:
115 static constexpr bool is_vectorised = configuration_t::template exists<align_cfg::vectorised>();
117 static constexpr bool is_parallel = configuration_t::template exists<align_cfg::parallel>();
119 static constexpr bool is_global = configuration_t::template exists<seqan3::align_cfg::method_global>();
121 static constexpr bool is_local = configuration_t::template exists<seqan3::align_cfg::method_local>();
123 static constexpr bool is_banded = configuration_t::template exists<align_cfg::band_fixed_size>();
125 static constexpr bool is_debug = configuration_t::template exists<detail::debug_mode>();
127 static constexpr bool is_one_way_execution = configuration_t::template exists<align_cfg::on_result>();
129 using scoring_scheme_type = decltype(get<align_cfg::scoring_scheme>(std::declval<configuration_t>()).scheme);
131 using scoring_scheme_alphabet_type = typename scoring_scheme_type::alphabet_type;
133 using original_score_type = typename std::remove_reference_t<decltype(std::declval<configuration_t>().get_or(
134 align_cfg::score_type<int32_t>{}))>::type;
136 using score_type = std::conditional_t<is_vectorised, simd_type_t<original_score_type>, original_score_type>;
138 using trace_type = std::conditional_t<is_vectorised, simd_type_t<original_score_type>, trace_directions>;
140 using alignment_result_type = decltype(determine_alignment_result_type());
142 using matrix_index_type =
145 using matrix_coordinate_type =
146 lazy_conditional_t<is_vectorised, lazy<simd_matrix_coordinate, matrix_index_type>, matrix_coordinate>;
147
149 static constexpr size_t alignments_per_vector = []() constexpr
150 {
151 if constexpr (is_vectorised)
152 return simd_traits<score_type>::length;
153 else
154 return 1;
155 }
156 ();
158 static constexpr bool compute_score = configuration_t::template exists<align_cfg::output_score>();
160 static constexpr bool compute_end_positions = configuration_t::template exists<align_cfg::output_end_position>();
162 static constexpr bool compute_begin_positions =
163 configuration_t::template exists<align_cfg::output_begin_position>();
165 static constexpr bool compute_sequence_alignment = configuration_t::template exists<align_cfg::output_alignment>();
167 static constexpr bool output_sequence1_id = configuration_t::template exists<align_cfg::output_sequence1_id>();
169 static constexpr bool output_sequence2_id = configuration_t::template exists<align_cfg::output_sequence2_id>();
171 static constexpr bool has_output_configuration = compute_score || compute_end_positions || compute_begin_positions
172 || compute_sequence_alignment || output_sequence1_id
173 || output_sequence2_id;
175 static constexpr bool requires_trace_information = compute_begin_positions || compute_sequence_alignment;
176};
177
178//------------------------------------------------------------------------------
179// alignment_function_traits
180//------------------------------------------------------------------------------
181
187template <typename function_t>
188struct alignment_function_traits
189{
191 using sequence_input_type = typename function_traits<function_t>::template argument_type_at<0>;
193 using callback_type = typename function_traits<function_t>::template argument_type_at<1>;
195 using alignment_result_type = typename function_traits<callback_type>::template argument_type_at<0>;
196};
197
198} // namespace seqan3::detail
Provides seqan3::detail::align_config_band.
Provides seqan3::align_cfg::detail::debug.
Provides global and local alignment configurations.
Provides seqan3::align_cfg::on_result.
Provides configuration for alignment output.
Provides seqan3::align_cfg::parallel configuration.
Provides seqan3::align_cfg::detail::result_type.
Provides alignment configuration seqan3::align_cfg::score_type.
Provides seqan3::align_cfg::scoring_scheme.
Provides seqan3::align_cfg::vectorised configuration.
Provides concepts needed internally for the alignment algorithms.
Provides utility functions for bit twiddling.
Provides seqan3::views::chunk.
Provides seqan3::configuration and utility functions.
Provides seqan3::detail::empty_type.
Provides various type traits for use on functions.
constexpr auto chunk
Divide a range in chunks.
Definition: chunk.hpp:835
constexpr auto zip
A view adaptor that takes several views and returns tuple-like values from every i-th element of each...
Definition: zip.hpp:573
Provides lazy template instantiation traits.
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
Provides seqan3::simd::simd_type.
Provides seqan3::simd::simd_traits.
Provides type traits for working with templates.
Provides the declaration of seqan3::detail::trace_directions.
Provides seqan3::views::zip.