SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
type_traits.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 <seqan3/std/ranges>
16 #include <type_traits>
17 
41 
42 namespace seqan3::detail
43 {
44 
45 //------------------------------------------------------------------------------
46 // chunked_indexed_sequence_pairs
47 //------------------------------------------------------------------------------
48 
61 template <typename sequence_pairs_t>
66 {
68  using type = decltype(views::zip(std::declval<sequence_pairs_t>(), std::views::iota(0)) | views::chunk(1));
69 };
70 
71 //------------------------------------------------------------------------------
72 // alignment_configuration_traits
73 //------------------------------------------------------------------------------
74 
82 template <typename configuration_t>
84  requires is_type_specialisation_of_v<std::remove_cv_t<configuration_t>, configuration>
87 {
88 private:
99  template <arithmetic score_t>
100  using select_scalar_index_t = min_viable_uint_t<1ull << (bits_of<score_t> - 1)>;
101 
103  static constexpr auto determine_alignment_result_type() noexcept
104  {
105  if constexpr (configuration_t::template exists<align_cfg::detail::result_type>())
106  {
107  using result_type_cfg_t =
109  decltype(seqan3::get<align_cfg::detail::result_type>(std::declval<configuration_t>()))
110  >;
111  return typename result_type_cfg_t::type{}; // Access the stored result_type.
112  }
113  else
114  {
115  return empty_type{};
116  }
117  }
118 
119 public:
121  static constexpr bool is_vectorised = configuration_t::template exists<align_cfg::vectorised>();
123  static constexpr bool is_parallel = configuration_t::template exists<align_cfg::parallel>();
125  static constexpr bool is_global =
126  configuration_t::template exists<seqan3::align_cfg::method_global>();
128  static constexpr bool is_local = configuration_t::template exists<seqan3::align_cfg::method_local>();
130  static constexpr bool is_banded = configuration_t::template exists<align_cfg::band_fixed_size>();
132  static constexpr bool is_debug = configuration_t::template exists<detail::debug_mode>();
134  static constexpr bool is_one_way_execution = configuration_t::template exists<align_cfg::on_result>();
136  using scoring_scheme_type = decltype(get<align_cfg::scoring_scheme>(std::declval<configuration_t>()).scheme);
138  using scoring_scheme_alphabet_type = typename scoring_scheme_type::alphabet_type;
140  using original_score_type = typename std::remove_reference_t<decltype(
141  std::declval<configuration_t>().get_or(align_cfg::score_type<int32_t>{}))>::type;
151  size_t>;
153  using matrix_coordinate_type = lazy_conditional_t<is_vectorised,
155  matrix_coordinate>;
156 
158  static constexpr size_t alignments_per_vector = [] () constexpr
159  {
160  if constexpr (is_vectorised)
162  else
163  return 1;
164  }();
166  static constexpr bool compute_score = configuration_t::template exists<align_cfg::output_score>();
168  static constexpr bool compute_end_positions =
169  configuration_t::template exists<align_cfg::output_end_position>();
171  static constexpr bool compute_begin_positions =
172  configuration_t::template exists<align_cfg::output_begin_position>();
174  static constexpr bool compute_sequence_alignment =
175  configuration_t::template exists<align_cfg::output_alignment>();
177  static constexpr bool output_sequence1_id =
178  configuration_t::template exists<align_cfg::output_sequence1_id>();
180  static constexpr bool output_sequence2_id =
181  configuration_t::template exists<align_cfg::output_sequence2_id>();
183  static constexpr bool has_output_configuration = compute_score ||
191 };
192 
193 //------------------------------------------------------------------------------
194 // alignment_function_traits
195 //------------------------------------------------------------------------------
196 
202 template <typename function_t>
204 {
206  using sequence_input_type = typename function_traits<function_t>::template argument_type_at<0>;
208  using callback_type = typename function_traits<function_t>::template argument_type_at<1>;
210  using alignment_result_type = typename function_traits<callback_type>::template argument_type_at<0>;
211 };
212 
213 } // 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.
A configuration element to set the score type used in the alignment algorithm.
Definition: align_config_score_type.hpp:36
Collection of elements to configure an algorithm.
Definition: configuration.hpp:46
Provides seqan3::configuration and utility functions.
Provides type traits for working with templates.
Provides seqan3::detail::empty_type.
Provides various type traits for use on functions.
trace_directions
The possible directions a trace can have. The values can be combined by the logical |-operator.
Definition: trace_directions.hpp:29
decltype(auto) get_or(record< field_types, field_ids > &r, or_type &&or_value)
Access an element in a std::tuple or seqan3::record; return or_value if not contained.
Definition: record.hpp:170
constexpr simd_t iota(typename simd_traits< simd_t >::scalar_type const offset)
Fills a seqan3::simd::simd_type vector with the scalar values offset, offset+1, offset+2,...
Definition: algorithm.hpp:299
typename simd_type< scalar_t, length, simd_backend >::type simd_type_t
Helper type of seqan3::simd::simd_type.
Definition: simd.hpp:59
A helper concept to check if a type is a range over seqan3::detail::sequence_pair.
Provides lazy template instantiation traits.
Provides seqan3::detail::alignment_coordinate and associated strong types.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Adaptations of concepts from the Ranges TS.
A traits type for the alignment algorithm that exposes static information stored within the alignment...
Definition: type_traits.hpp:87
static constexpr bool is_banded
Flag indicating whether banded alignment mode is enabled.
Definition: type_traits.hpp:130
static constexpr bool is_vectorised
Flag to indicate vectorised mode.
Definition: type_traits.hpp:121
typename std::remove_reference_t< decltype(std::declval< configuration_t >().get_or(align_cfg::score_type< int32_t >{}))>::type original_score_type
The original score type selected by the user.
Definition: type_traits.hpp:141
static constexpr bool is_local
Flag indicating whether local alignment mode is enabled.
Definition: type_traits.hpp:128
static constexpr bool requires_trace_information
Flag indicating whether the trace matrix needs to be computed.
Definition: type_traits.hpp:190
static constexpr bool has_output_configuration
Flag indicating if any output option was set.
Definition: type_traits.hpp:183
static constexpr bool output_sequence2_id
Flag indicating whether the id of the second sequence shall be returned.
Definition: type_traits.hpp:180
static constexpr bool is_parallel
Flag indicating whether parallel alignment mode is enabled.
Definition: type_traits.hpp:123
typename scoring_scheme_type::alphabet_type scoring_scheme_alphabet_type
The alphabet of the selected scoring scheme.
Definition: type_traits.hpp:138
static constexpr bool compute_sequence_alignment
Flag indicating whether the sequence alignment shall be computed.
Definition: type_traits.hpp:174
static constexpr size_t alignments_per_vector
The number of alignments that can be computed in one simd vector.
Definition: type_traits.hpp:158
static constexpr bool compute_begin_positions
Flag indicating whether the begin positions shall be computed.
Definition: type_traits.hpp:171
static constexpr auto determine_alignment_result_type() noexcept
Helper function to determine the alignment result type.
Definition: type_traits.hpp:103
static constexpr bool is_global
Flag indicating whether global alignment method is enabled.
Definition: type_traits.hpp:125
static constexpr bool is_debug
Flag indicating whether debug mode is enabled.
Definition: type_traits.hpp:132
decltype(get< align_cfg::scoring_scheme >(std::declval< configuration_t >()).scheme) scoring_scheme_type
The selected scoring scheme.
Definition: type_traits.hpp:136
static constexpr bool output_sequence1_id
Flag indicating whether the id of the first sequence shall be returned.
Definition: type_traits.hpp:177
lazy_conditional_t< is_vectorised, lazy< simd_matrix_coordinate, matrix_index_type >, matrix_coordinate > matrix_coordinate_type
The type of the matrix coordinate.
Definition: type_traits.hpp:155
decltype(determine_alignment_result_type()) alignment_result_type
The alignment result type if present. Otherwise seqan3::detail::empty_type.
Definition: type_traits.hpp:147
static constexpr bool is_one_way_execution
Flag indicating whether a user provided callback was given.
Definition: type_traits.hpp:134
static constexpr bool compute_end_positions
Flag indicating whether the end positions shall be computed.
Definition: type_traits.hpp:168
static constexpr bool compute_score
Flag indicating whether the score shall be computed.
Definition: type_traits.hpp:166
A traits class to provide a uniform access to the properties of the wrapped alignment algorithm.
Definition: type_traits.hpp:204
typename function_traits< function_t >::template argument_type_at< 1 > callback_type
The type of the callback function called when a result was computed.
Definition: type_traits.hpp:208
typename function_traits< function_t >::template argument_type_at< 0 > sequence_input_type
The type of the sequence input to the alignment algorithm.
Definition: type_traits.hpp:206
typename function_traits< callback_type >::template argument_type_at< 0 > alignment_result_type
The type of the alignment result to be computed.
Definition: type_traits.hpp:210
A transformation trait to retrieve the chunked range over indexed sequence pairs.
Definition: type_traits.hpp:66
decltype(views::zip(std::declval< sequence_pairs_t >(), std::views::iota(0))|views::chunk(1)) type
The transformed type that models seqan3::detail::indexed_sequence_pair_range.
Definition: type_traits.hpp:68
An empty class type used in meta programming.
Definition: empty_type.hpp:23
An empty type whose only purpose is to hold an uninstantiated template plus its arguments.
Definition: lazy_conditional.hpp:36
seqan3::simd::simd_traits is the trait class that provides uniform interface to the properties of sim...
Definition: simd_traits.hpp:41
Provides the declaration of seqan3::detail::trace_directions.
Provides seqan3::simd::simd_type.
Provides seqan3::simd::simd_traits.
Provides seqan3::views::zip.