SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
edit_distance_fwd.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
19 #include <seqan3/core/platform.hpp>
21 #include <seqan3/std/concepts>
22 #include <seqan3/std/ranges>
23 
24 namespace seqan3::detail
25 {
26 template <typename word_t, typename score_t, bool is_semi_global, bool use_max_errors>
27 class edit_distance_score_matrix_full; //forward declaration
28 
29 template <typename word_t, bool is_semi_global, bool use_max_errors>
30 class edit_distance_trace_matrix_full; //forward declaration
31 
33 template <typename state_t, typename...>
34 struct empty_state
35 {};
36 
38 template <bool enabled, typename state_t>
40 
45 template<bool B, template<typename...> typename T, template<typename...> typename F>
46 struct selector
47 {
49  template <typename ...args_t>
50  struct select : public std::conditional_t<B, T<args_t...>, F<args_t...>>
51  {};
52 };
53 
57 template <std::ranges::ViewableRange database_t,
59  typename align_config_t,
60  typename is_semi_global_t,
61  typename word_t = uint_fast64_t>
62 struct default_edit_distance_trait_type
63 {
65  using word_type = word_t;
66  static_assert(std::is_unsigned_v<word_type>, "the word type of edit_distance_unbanded must be unsigned.");
68  using score_type = int;
70  using database_type = std::remove_reference_t<database_t>;
72  using query_type = std::remove_reference_t<query_t>;
74  using align_config_type = std::remove_reference_t<align_config_t>;
75 
77  static constexpr uint8_t word_size = sizeof_bits<word_type>;
78  static_assert(sizeof_bits<word_type> <= 64u, "we assume at most uint64_t as word_type");
79 
81  using database_iterator = std::ranges::iterator_t<database_type>;
83  using query_alphabet_type = std::remove_reference_t<reference_t<query_type>>;
85  using result_value_type = typename align_result_selector<database_type, query_type, align_config_type>::type;
86 
89  static constexpr bool use_max_errors = align_config_type::template exists<align_cfg::max_error>();
91  static constexpr bool is_semi_global = is_semi_global_t::value;
93  static constexpr bool is_global = !is_semi_global;
94 
96  static constexpr bool compute_score = align_config_type::template exists<align_cfg::result<with_score_type>>() ||
97  !std::Same<decltype(result_value_type{}.back_coordinate), std::nullopt_t *>;
99  static constexpr bool compute_back_coordinate = !std::Same<decltype(result_value_type{}.back_coordinate),
100  std::nullopt_t *>;
102  static constexpr bool compute_front_coordinate = !std::Same<decltype(result_value_type{}.front_coordinate),
103  std::nullopt_t *>;
105  static constexpr bool compute_sequence_alignment = !std::Same<decltype(result_value_type{}.alignment),
106  std::nullopt_t *>;
108  static constexpr bool compute_score_matrix = false;
110  static constexpr bool compute_trace_matrix = compute_front_coordinate || compute_sequence_alignment;
112  static constexpr bool compute_matrix = compute_score_matrix || compute_trace_matrix;
113 
115  using trace_matrix_type = edit_distance_trace_matrix_full<word_type, is_semi_global, use_max_errors>;
117  using score_matrix_type = edit_distance_score_matrix_full<word_type, score_type, is_semi_global, use_max_errors>;
118 };
119 
121 template <bool enable_policy,
122  template<typename...> typename policy_t,
123  typename edit_traits,
124  typename derived_t>
125 using edit_distance_base =
126  invoke_deferred_crtp_base<deferred_crtp_base<selector<enable_policy, policy_t, empty_state>::template select,
127  edit_traits>,
128  derived_t>;
129 
131 template <std::ranges::ViewableRange database_t,
133  typename align_config_t,
134  typename traits_t = default_edit_distance_trait_type<database_t, query_t, align_config_t, std::false_type>>
135 class edit_distance_unbanded; //forward declaration
137 
138 } // namespace seqan3::detail
Specifies the requirements of a Range type that is either a std::ranges::View or an lvalue-reference...
Provides seqan3::align_cfg::max_error configuration.
Provides platform and dependency checks.
Provides seqan3::detail::deferred_crtp_base.
The Concepts library.
::ranges::iterator_t iterator_t
Alias for ranges::iterator_t. Obtains the iterator type of a range.
Definition: ranges:204
Adaptations of concepts from the Ranges TS.
Definition: aligned_sequence_concept.hpp:35
Provides seqan3::detail::align_result_selector.
Provides utility functions for bit twiddling.
Provides configuration for alignment output.
The concept std::Same<T, U> is satisfied if and only if T and U denote the same type.