SeqAn3  3.0.2
The Modern C++ library for sequence analysis.
edit_distance_algorithm.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 <tuple>
16 
20 
21 namespace seqan3::detail
22 {
23 
38 template <typename config_t, typename traits_t>
39 class edit_distance_algorithm
40 {
41 private:
43  using configuration_traits_type = alignment_configuration_traits<config_t>;
45  using alignment_result_type = typename configuration_traits_type::alignment_result_type;
46 
47  static_assert(!std::same_as<alignment_result_type, empty_type>, "Alignment result type was not configured.");
48 
49 public:
53  constexpr edit_distance_algorithm() = default;
54  constexpr edit_distance_algorithm(edit_distance_algorithm const &) = default;
55  constexpr edit_distance_algorithm(edit_distance_algorithm &&) = default;
56  constexpr edit_distance_algorithm & operator=(edit_distance_algorithm const &) = default;
57  constexpr edit_distance_algorithm & operator=(edit_distance_algorithm &&) = default;
58  ~edit_distance_algorithm() = default;
59 
71  constexpr edit_distance_algorithm(config_t const & cfg) : cfg_ptr{new config_t(cfg)}
72  {}
74 
92  template <indexed_sequence_pair_range indexed_sequence_pairs_t, typename callback_t>
94  requires std::invocable<callback_t, alignment_result_type>
96  constexpr void operator()(indexed_sequence_pairs_t && indexed_sequence_pairs, callback_t && callback)
97  {
98  using std::get;
99 
100  for (auto && [sequence_pair, index] : indexed_sequence_pairs)
101  compute_single_pair(index,
102  get<0>(sequence_pair),
103  get<1>(sequence_pair),
104  std::forward<callback_t>(callback));
105  }
106 private:
107 
119  template <std::ranges::forward_range first_range_t, std::ranges::forward_range second_range_t, typename callback_t>
120  constexpr void compute_single_pair(size_t const idx,
121  first_range_t && first_range,
122  second_range_t && second_range,
123  callback_t && callback)
124  {
125  using edit_traits = default_edit_distance_trait_type<first_range_t,
126  second_range_t,
127  config_t,
128  typename traits_t::is_semi_global_type>;
129  edit_distance_unbanded algo{first_range, second_range, *cfg_ptr, edit_traits{}};
130  algo(idx, callback);
131  }
132 
135 };
136 
137 } // namespace seqan3::detail
std::shared_ptr
tuple
seqan3::views::get
auto const get
A view calling std::get on each element in a range.
Definition: get.hpp:65
edit_distance_unbanded.hpp
Provides a pairwise alignment algorithm for edit distance but without band.
concept.hpp
Provides concepts needed internally for the alignment algorithms.
align_config_edit.hpp
Provides seqan3::align_cfg::edit_scheme.