SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
edit_distance_fwd.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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/concepts>
16 #include <seqan3/std/ranges>
17 
22 #include <seqan3/core/platform.hpp>
24 
25 namespace seqan3::detail
26 {
27 template <typename word_t, typename score_t, bool is_semi_global, bool use_max_errors>
28 class edit_distance_score_matrix_full; //forward declaration
29 
30 template <typename word_t, bool is_semi_global, bool use_max_errors>
31 class edit_distance_trace_matrix_full; //forward declaration
32 
34 template <typename state_t, typename ...>
35 struct empty_state
36 {};
37 
39 template <bool enabled, typename state_t>
41 
46 template <bool B, template <typename ...> typename T, template <typename ...> typename F>
47 struct selector
48 {
50  template <typename ...args_t>
51  struct select : public std::conditional_t<B, T<args_t...>, F<args_t...>>
52  {};
53 };
54 
58 template <std::ranges::viewable_range database_t,
59  std::ranges::viewable_range query_t,
60  typename align_config_t,
61  typename is_semi_global_t,
62  typename word_t = uint_fast64_t>
63 struct default_edit_distance_trait_type
64 {
66  using align_config_type = std::remove_reference_t<align_config_t>;
68  using alignment_traits_type = alignment_configuration_traits<align_config_type>;
70  using word_type = word_t;
71  static_assert(std::is_unsigned_v<word_type>, "the word type of edit_distance_unbanded must be unsigned.");
72  static_assert(alignment_traits_type::has_output_configuration, "We assume the result type was configured.");
74  using score_type = typename alignment_traits_type::original_score_type;
76  using database_type = std::remove_reference_t<database_t>;
78  using query_type = std::remove_reference_t<query_t>;
79 
81  static constexpr uint8_t word_size = bits_of<word_type>;
82  static_assert(bits_of<word_type> <= 64u, "we assume at most uint64_t as word_type");
83 
85  using database_iterator = std::ranges::iterator_t<database_type>;
89  using alignment_result_type = typename alignment_traits_type::alignment_result_type;
91  using result_value_type = typename alignment_result_value_type_accessor<alignment_result_type>::type;
92 
95  static constexpr bool use_max_errors = align_config_type::template exists<align_cfg::min_score>();
97  static constexpr bool is_semi_global = is_semi_global_t::value;
99  static constexpr bool is_global = !is_semi_global;
101  static constexpr bool compute_score = true;
103  static constexpr bool compute_sequence_alignment = alignment_traits_type::compute_sequence_alignment;
105  static constexpr bool compute_begin_positions = alignment_traits_type::compute_begin_positions ||
106  compute_sequence_alignment;
108  static constexpr bool compute_end_positions = alignment_traits_type::compute_end_positions ||
109  compute_begin_positions;
111  static constexpr bool compute_score_matrix = false;
113  static constexpr bool compute_trace_matrix = compute_begin_positions || compute_sequence_alignment;
115  static constexpr bool compute_matrix = compute_score_matrix || compute_trace_matrix;
116 
118  using trace_matrix_type = edit_distance_trace_matrix_full<word_type, is_semi_global, use_max_errors>;
120  using score_matrix_type = edit_distance_score_matrix_full<word_type, score_type, is_semi_global, use_max_errors>;
121 };
122 
124 template <bool enable_policy,
125  template <typename ...> typename policy_t,
126  typename edit_traits,
127  typename derived_t>
128 using edit_distance_base =
129  invoke_deferred_crtp_base<deferred_crtp_base<selector<enable_policy, policy_t, empty_state>::template select,
130  edit_traits>,
131  derived_t>;
132 
134 template <std::ranges::viewable_range database_t,
135  std::ranges::viewable_range query_t,
136  typename align_config_t,
137  typename traits_t>
138 class edit_distance_unbanded; //forward declaration
140 
141 } // namespace seqan3::detail
Provides seqan3::align_cfg::min_score configuration.
Provides seqan3::detail::align_result_selector.
Provides helper type traits for the configuration and execution of the alignment algorithm.
Provides utility functions for bit twiddling.
The Concepts library.
Provides seqan3::detail::deferred_crtp_base.
Provides platform and dependency checks.
Adaptations of concepts from the Ranges TS.