SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
edit_distance_algorithm.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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
90 template <indexed_sequence_pair_range indexed_sequence_pairs_t, typename callback_t>
91 requires std::invocable<callback_t, alignment_result_type>
92 constexpr void operator()(indexed_sequence_pairs_t && indexed_sequence_pairs, callback_t && callback)
93 {
94 using std::get;
95
96 for (auto && [sequence_pair, index] : indexed_sequence_pairs)
97 compute_single_pair(index,
98 get<0>(sequence_pair),
99 get<1>(sequence_pair),
100 std::forward<callback_t>(callback));
101 }
102
103private:
115 template <std::ranges::forward_range first_range_t, std::ranges::forward_range second_range_t, typename callback_t>
116 constexpr void compute_single_pair(size_t const idx,
117 first_range_t && first_range,
118 second_range_t && second_range,
119 callback_t && callback)
120 {
121 using edit_traits = default_edit_distance_trait_type<first_range_t,
122 second_range_t,
123 config_t,
124 typename traits_t::is_semi_global_type>;
125 edit_distance_unbanded algo{first_range, second_range, *cfg_ptr, edit_traits{}};
126 algo(idx, callback);
127 }
128
131};
132
133} // 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:415