SeqAn3 3.1.0
The Modern C++ library for sequence analysis.
edit_distance_algorithm.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 <tuple>
16
20
21namespace seqan3::detail
22{
23
38template <typename config_t, typename traits_t>
39class edit_distance_algorithm
40{
41private:
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
49public:
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 }
106private:
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
Provides seqan3::align_cfg::edit_scheme.
Provides concepts needed internally for the alignment algorithms.
Provides a pairwise alignment algorithm for edit distance but without band.
constexpr auto const & get(configuration< configs_t... > const &config) noexcept
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: configuration.hpp:429