20 #include <type_traits>
130 template <
typename sequence_t,
typename alignment_config_t>
132 requires detail::align_pairwise_single_input<sequence_t> &&
133 std::copy_constructible<std::remove_reference_t<sequence_t>> &&
134 detail::is_type_specialisation_of_v<alignment_config_t, configuration>
136 constexpr
auto align_pairwise(sequence_t && seq, alignment_config_t
const & config)
140 if constexpr (std::is_lvalue_reference_v<sequence_t>)
147 "Alignment configuration error: Expects exactly two sequences for pairwise alignments.");
151 "Alignment configuration error: The tuple elements must model std::ranges::viewable_range.");
158 template <
typename sequence_t,
typename alignment_config_t>
159 requires detail::align_pairwise_range_input<sequence_t> &&
160 detail::is_type_specialisation_of_v<alignment_config_t, configuration>
162 alignment_config_t
const & config)
164 using first_seq_t = std::tuple_element_t<0, std::ranges::range_value_t<sequence_t>>;
165 using second_seq_t = std::tuple_element_t<1, std::ranges::range_value_t<sequence_t>>;
167 static_assert(std::ranges::random_access_range<first_seq_t> && std::ranges::sized_range<first_seq_t>,
168 "Alignment configuration error: The sequence must model random_access_range and sized_range.");
169 static_assert(std::ranges::random_access_range<second_seq_t> && std::ranges::sized_range<second_seq_t>,
170 "Alignment configuration error: The sequence must model random_access_range and sized_range.");
173 auto seq_view = std::forward<sequence_t>(sequences) | detail::persist;
175 auto && [algorithm, complete_config] = detail::alignment_configurator::configure<decltype(seq_view)>(config);
178 using traits_t = detail::alignment_configuration_traits<complete_config_t>;
180 auto indexed_sequence_chunk_view =
views::zip(seq_view, std::views::iota(0))
183 using indexed_sequences_t = decltype(indexed_sequence_chunk_view);
184 using alignment_result_t =
typename traits_t::alignment_result_type;
186 detail::execution_handler_parallel,
187 detail::execution_handler_sequential>;
188 using executor_t = detail::algorithm_executor_blocking<indexed_sequences_t,
191 execution_handler_t>;
194 auto select_execution_handler = [&] ()
196 if constexpr (std::same_as<execution_handler_t, detail::execution_handler_parallel>)
198 auto thread_count = get<align_cfg::parallel>(complete_config).thread_count;
200 throw std::runtime_error{
"You must configure the number of threads in seqan3::align_cfg::parallel."};
202 return execution_handler_t{*thread_count};
206 return execution_handler_t{};
210 if constexpr (traits_t::is_one_way_execution)
211 select_execution_handler().bulk_execute(algorithm,
212 indexed_sequence_chunk_view,
213 get<align_cfg::on_result>(complete_config).callback);
215 return algorithm_result_generator_range{executor_t{
std::move(indexed_sequence_chunk_view),
217 alignment_result_t{},
218 select_execution_handler()}};
Provides seqan3::detail::algorithm_executor_blocking.
Provides seqan3::detail::algorithm_result_generator_range.
Provides concepts needed internally for the alignment algorithms.
Provides helper type traits for the configuration and execution of the alignment algorithm.
Provides seqan3::detail::alignment_selector.
Provides seqan3::alignment_result.
constexpr auto align_pairwise(sequence_t &&seq, alignment_config_t const &config)
Computes the pairwise alignment for a pair of sequences or a range over sequence pairs.
Definition: align_pairwise.hpp:135
@ single
The text is a single range.
Definition: concept.hpp:83
constexpr auto get
A view calling get on each element in a range.
Definition: elements.hpp:114
constexpr auto chunk
A chunk view.
Definition: chunk.hpp:29
constexpr auto zip
A zip view.
Definition: zip.hpp:29
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:74
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::detail::persist.
Adaptations of concepts from the Ranges TS.
Provides seqan3::simd::simd_type.
Provides seqan3::simd::simd_traits.
Provides various type traits on generic types.