74template <
typename range_type,
typename alignment_config_type>
84 using first_seq_t = std::tuple_element_t<0, std::ranges::range_value_t<unref_range_type>>;
86 using second_seq_t = std::tuple_element_t<1, std::ranges::range_value_t<unref_range_type>>;
94 && std::tuple_size_v<std::ranges::range_value_t<unref_range_type>> == 2;
100 if constexpr (alignment_config_type::template exists<align_cfg::scoring_scheme>())
103 decltype(get<align_cfg::scoring_scheme>(std::declval<alignment_config_type>()).scheme)>;
105 std::ranges::range_value_t<first_seq_t>,
106 std::ranges::range_value_t<second_seq_t>>);
117 bool const is_global = alignment_config_type::template exists<seqan3::align_cfg::method_global>();
118 bool const is_local = alignment_config_type::template exists<seqan3::align_cfg::method_local>();
120 return (is_global || is_local);
134 template <
typename traits_t>
140 !(traits_t::compute_begin_positions || traits_t::compute_sequence_alignment);
161 template <
typename traits_t>
166 using score_t =
typename traits_t::score_type;
183 template <
typename traits_t>
188 using score_t =
typename traits_t::score_type;
198 template <
typename traits_t,
typename... args_t>
206 template <
typename config_t>
258 template <align_pairwise_range_input sequences_t,
typename config_t>
259 requires is_type_specialisation_of_v<config_t, configuration>
263 using config_with_output_t =
decltype(config_with_output);
269 using first_seq_t = std::tuple_element_t<0, std::ranges::range_value_t<sequences_t>>;
270 using second_seq_t = std::tuple_element_t<1, std::ranges::range_value_t<sequences_t>>;
277 using indexed_sequence_pair_chunk_t = std::ranges::range_value_t<indexed_sequence_pair_range_t>;
282 config_with_output_t>::type;
284 using callback_on_result_t =
std::function<void(alignment_result_t)>;
286 using function_wrapper_t =
std::function<void(indexed_sequence_pair_chunk_t, callback_on_result_t)>;
297 static_assert(alignment_contract_t::expects_alignment_configuration(),
298 "Alignment configuration error: "
299 "The alignment can only be configured with alignment configurations.");
301 static_assert(alignment_contract_t::expects_tuple_like_value_type(),
302 "Alignment configuration error: "
303 "The value type of the sequence ranges must model the seqan3::tuple_like and must contain "
304 "exactly 2 elements.");
306 static_assert(alignment_contract_t::expects_valid_scoring_scheme(),
307 "Alignment configuration error: "
308 "Either the scoring scheme was not configured or the given scoring scheme cannot be invoked with "
309 "the value types of the passed sequences.");
317 auto const & gap_cost = config_with_result_type.get_or(edit_gap_cost);
318 auto const & scoring_scheme = get<align_cfg::scoring_scheme>(cfg).scheme;
320 if constexpr (config_t::template exists<seqan3::align_cfg::method_global>())
325 auto method_global_cfg = get<seqan3::align_cfg::method_global>(config_with_result_type);
327 bool const has_edit_distance_gaps = gap_cost.open_score == 0 && gap_cost.extension_score == -1;
328 bool const has_no_free_end_gaps_sequence2 = !method_global_cfg.free_end_gaps_sequence2_leading
329 && !method_global_cfg.free_end_gaps_sequence2_trailing;
330 bool const has_equal_free_end_gaps_sequence1 = method_global_cfg.free_end_gaps_sequence1_leading
331 == method_global_cfg.free_end_gaps_sequence1_trailing;
333 if (has_edit_distance_gaps && has_no_free_end_gaps_sequence2 && has_equal_free_end_gaps_sequence1)
335 return std::pair{configure_edit_distance<function_wrapper_t>(config_with_result_type),
336 config_with_result_type};
346 if (config_t::template exists<align_cfg::min_score>())
348 "specific edit distance computation."};
350 return std::pair{configure_scoring_scheme<function_wrapper_t>(config_with_result_type),
351 config_with_result_type};
364 template <
typename config_t>
369 if constexpr (traits_t::has_output_configuration)
382 template <
typename function_wrapper_t,
typename config_t>
391 if constexpr (traits_t::is_banded)
401 auto configure_edit_traits = [&](
auto is_semi_global)
403 struct edit_traits_type
405 using is_semi_global_type [[maybe_unused]] =
std::remove_cvref_t<
decltype(is_semi_global)>;
409 return function_wrapper_t{std::move(algorithm)};
413 auto has_free_ends_trailing = [&](
auto first)
constexpr
415 if constexpr (!
decltype(first)::value)
421 if (method_global_cfg.free_end_gaps_sequence1_trailing)
429 if (method_global_cfg.free_end_gaps_sequence1_leading)
451 template <
typename function_wrapper_t,
typename config_t>
468 template <
typename function_wrapper_t,
typename... policies_t,
typename config_t>
478 if constexpr (traits_t::is_local ||
479 traits_t::is_debug ||
480 traits_t::compute_sequence_alignment ||
481 (traits_t::is_banded && traits_t::compute_begin_positions)
483 (traits_t::is_vectorised && traits_t::compute_end_positions))
503 using scalar_optimum_updater_t =
506 using optimum_tracker_policy_t =
507 lazy_conditional_t<traits_t::is_vectorised,
527 using alignment_method_t = std::
528 conditional_t<traits_t::is_global, seqan3::align_cfg::method_global, seqan3::align_cfg::method_local>;
530 using score_t =
typename traits_t::score_type;
531 using scoring_scheme_t =
typename traits_t::scoring_scheme_type;
532 constexpr bool is_aminoacid_scheme =
533 is_type_specialisation_of_v<scoring_scheme_t, aminoacid_scoring_scheme>;
535 using simple_simd_scheme_t = lazy_conditional_t<traits_t::is_vectorised,
538 typename traits_t::scoring_scheme_alphabet_type,
541 using matrix_simd_scheme_t = lazy_conditional_t<traits_t::is_vectorised,
544 typename traits_t::scoring_scheme_alphabet_type,
548 using alignment_scoring_scheme_t =
562 using alignment_matrix_t =
575 optimum_tracker_policy_t,
576 result_builder_policy_t,
577 scoring_scheme_policy_t,
578 alignment_matrix_policy_t>;
579 return algorithm_t{cfg};
585template <
typename function_wrapper_t,
typename config_t>
588 using traits_t = alignment_configuration_traits<config_t>;
590 using scoring_scheme_t =
typename traits_t::scoring_scheme_type;
591 constexpr bool is_aminoacid_scheme = is_type_specialisation_of_v<scoring_scheme_t, aminoacid_scoring_scheme>;
592 using alignment_type_t =
typename std::
593 conditional_t<traits_t::is_global, seqan3::align_cfg::method_global, seqan3::align_cfg::method_local>;
595 using simple_simd_scheme_t = lazy_conditional_t<traits_t::is_vectorised,
596 lazy<simd_match_mismatch_scoring_scheme,
597 typename traits_t::score_type,
598 typename traits_t::scoring_scheme_alphabet_type,
601 using matrix_simd_scheme_t = lazy_conditional_t<traits_t::is_vectorised,
602 lazy<simd_matrix_scoring_scheme,
603 typename traits_t::score_type,
604 typename traits_t::scoring_scheme_alphabet_type,
608 using alignment_scoring_scheme_t =
613 using scoring_scheme_policy_t = deferred_crtp_base<scoring_scheme_policy, alignment_scoring_scheme_t>;
614 return make_algorithm<function_wrapper_t, scoring_scheme_policy_t>(cfg);
Provides seqan3::detail::affine_gap_init_policy.
Provides seqan3::detail::affine_gap_policy.
Provides configuration for alignment output.
Provides seqan3::align_cfg::detail::result_type.
Provides seqan3::detail::align_result_selector.
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_algorithm.
Provides seqan3::detail::alignment_matrix_policy.
Provides seqan3::alignment_result.
Provides seqan3::detail::alignment_score_matrix_one_column.
Provides seqan3::detail::alignment_score_matrix_one_column_banded.
Provides seqan3::detail::alignment_trace_matrix_full.
Provides seqan3::detail::alignment_trace_matrix_full_banded.
Provides seqan3::aminoacid_scoring_scheme.
Configuration element capturing the configured seqan3::alignment_result for the alignment algorithm.
Definition align_config_result_type.hpp:42
A configuration element for the affine gap cost scheme.
Definition align_config_gap_cost_affine.hpp:72
Sets the global alignment method.
Definition align_config_method.hpp:119
Configures the alignment result to output the alignment.
Definition align_config_output.hpp:168
Configures the alignment result to output the begin positions.
Definition align_config_output.hpp:128
Configures the alignment result to output the end position.
Definition align_config_output.hpp:84
Configures the alignment result to output the score.
Definition align_config_output.hpp:40
Configures the alignment result to output the id of the first sequence.
Definition align_config_output.hpp:208
Configures the alignment result to output the id of the second sequence.
Definition align_config_output.hpp:247
Stores the alignment results and gives access to score, alignment and the front and end positions.
Definition alignment_result.hpp:147
The alignment algorithm type to compute standard pairwise alignment using dynamic programming.
Definition alignment_algorithm.hpp:75
A banded alignment score matrix storing only a single banded column for the computation.
Definition alignment_score_matrix_one_column_banded.hpp:42
An alignment score matrix storing only a single column for the computation.
Definition alignment_score_matrix_one_column.hpp:42
An alignment traceback matrix storing the entire banded traceback matrix.
Definition alignment_trace_matrix_full_banded.hpp:53
An alignment traceback matrix storing the entire traceback matrix.
Definition alignment_trace_matrix_full.hpp:50
An alignment matrix that combines a score matrix with a trace matrix into a common interface.
Definition combined_score_and_trace_matrix.hpp:45
This algorithm unifies different edit distance implementations and uses the appropriate one depending...
Definition edit_distance_algorithm.hpp:37
The alignment algorithm type to compute the banded standard pairwise alignment using dynamic programm...
Definition pairwise_alignment_algorithm_banded.hpp:30
The alignment algorithm type to compute standard pairwise alignment using dynamic programming.
Definition pairwise_alignment_algorithm.hpp:44
Implements the alignment recursion function for the banded alignment algorithm using affine gap costs...
Definition policy_affine_gap_recursion_banded.hpp:23
Implements the alignment recursion function for the alignment algorithm using affine gap costs.
Definition policy_affine_gap_recursion.hpp:42
Implements the alignment recursion function for the banded alignment algorithm using affine gap costs...
Definition policy_affine_gap_with_trace_recursion_banded.hpp:25
Implements the alignment recursion function for the alignment algorithm using affine gap costs with t...
Definition policy_affine_gap_with_trace_recursion.hpp:24
A policy that provides a common interface to acquire the correct alignment matrices.
Definition policy_alignment_matrix.hpp:44
Implements the alignment result builder.
Definition policy_alignment_result_builder.hpp:34
Stores the configured scoring scheme used for this algorithm.
Definition policy_scoring_scheme.hpp:32
Score matrix for the pairwise alignment using only a single column.
Definition score_matrix_single_column.hpp:51
A vectorised scoring scheme handling matches and mismatches only.
Definition simd_match_mismatch_scoring_scheme.hpp:66
A vectorised scoring scheme to handle scoring matrices using gather strategy.
Definition simd_matrix_scoring_scheme.hpp:56
Trace matrix for the pairwise alignment using the full trace matrix.
Definition trace_matrix_full.hpp:50
A scoring scheme that assigns a score of 0 to matching letters and -1 to mismatching letters.
Definition hamming_scoring_scheme.hpp:33
Thrown if the configuration of the alignment algorithm is invalid.
Definition alignment/exception.hpp:32
Provides seqan3::detail::combined_score_and_trace_matrix.
Provides seqan3::detail::deferred_crtp_base.
Provides seqan3::detail::edit_distance_algorithm.
Provides seqan3::detail::find_optimum_policy.
A concept that requires that type be able to score two letters.
Whether a type behaves like a tuple.
Provides lazy template instantiation traits.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
decltype(views::type_reduce(std::declval< t >())) type_reduce_t
Deduces the return value of seqan3::views::type_reduce.
Definition type_reduce.hpp:159
Provides seqan3::nucleotide_scoring_scheme.
Provides seqan3::detail::pairwise_alignment_algorithm.
Provides seqan3::detail::pairwise_alignment_algorithm.
Provides seqan3::detail::policy_affine_gap_recursion.
Provides seqan3::detail::policy_affine_gap_recursion_banded.
Provides seqan3::detail::policy_affine_gap_with_trace_recursion.
Provides seqan3::detail::policy_affine_gap_with_trace_recursion_banded.
Provides seqan3::detail::policy_alignment_matrix.
Provides seqan3::detail::policy_alignment_result_builder.
Provides seqan3::detail::policy_optimum_tracker.
Provides seqan3::detail::policy_optimum_tracker_simd.
Provides seqan3::detail::policy_scoring_scheme.
Provides seqan3::detail::score_matrix_single_column.
Provides seqan3::detail::scoring_scheme_policy.
Provides seqan3::simd::simd_type.
Provides seqan3::detail::simd_affine_gap_policy.
Provides seqan3::detail::simd_find_optimum_policy.
Provides seqan3::detail::simd_match_mismatch_scoring_scheme.
Provides seqan3::detail::simd_matrix_scoring_scheme.
Helper metafunction to select the alignment result type based on the configuration.
Definition align_result_selector.hpp:42
A traits type for the alignment algorithm that exposes static information stored within the alignment...
Definition alignment/pairwise/detail/type_traits.hpp:80
static constexpr bool requires_trace_information
Flag indicating whether the trace matrix needs to be computed.
Definition alignment/pairwise/detail/type_traits.hpp:171
Transformation trait that chooses the correct find optimum policy.
Definition alignment_configurator.hpp:185
typename traits_t::score_type score_t
The score type for the alignment computation.
Definition alignment_configurator.hpp:188
Transformation trait that chooses the correct gap policy.
Definition alignment_configurator.hpp:163
typename traits_t::score_type score_t
The score type for the alignment computation.
Definition alignment_configurator.hpp:166
Selects the gap recursion policy.
Definition alignment_configurator.hpp:208
static constexpr bool with_trace
A flag indicating if trace is required.
Definition alignment_configurator.hpp:213
Transformation trait that chooses the correct matrix policy.
Definition alignment_configurator.hpp:136
static constexpr bool only_coordinates
Indicates whether only the coordinate is required to compute the alignment.
Definition alignment_configurator.hpp:139
Configures the alignment algorithm given the sequences and the configuration object.
Definition alignment_configurator.hpp:129
static constexpr auto maybe_default_output(config_t const &config) noexcept
Adds maybe the default output arguments if the user did not provide any.
Definition alignment_configurator.hpp:365
lazy_conditional_t< traits_t::is_banded, lazy< pairwise_alignment_algorithm_banded, args_t... >, lazy< pairwise_alignment_algorithm, args_t... > > select_alignment_algorithm_t
Selects either the banded or the unbanded alignment algorithm based on the given traits type.
Definition alignment_configurator.hpp:201
static constexpr function_wrapper_t make_algorithm(config_t const &cfg)
Constructs the actual alignment algorithm wrapped in the passed std::function object.
Definition alignment_configurator.hpp:469
static constexpr function_wrapper_t configure_edit_distance(config_t const &cfg)
Configures the edit distance algorithm.
Definition alignment_configurator.hpp:383
static constexpr auto configure(config_t const &cfg)
Configures the algorithm.
Definition alignment_configurator.hpp:260
static constexpr function_wrapper_t configure_scoring_scheme(config_t const &cfg)
Configures the scoring scheme to use for the alignment computation.
Provides several contracts to test when configuring the alignment algorithm.
Definition alignment_configurator.hpp:76
static constexpr bool expects_tuple_like_value_type()
Tests whether the value type of range_type is a tuple with exactly 2 members.
Definition alignment_configurator.hpp:91
static constexpr bool expects_valid_scoring_scheme()
Tests whether the scoring scheme is set and can be invoked with the sequences passed.
Definition alignment_configurator.hpp:98
std::tuple_element_t< 0, std::ranges::range_value_t< unref_range_type > > first_seq_t
The type of the first sequence.
Definition alignment_configurator.hpp:84
std::tuple_element_t< 1, std::ranges::range_value_t< unref_range_type > > second_seq_t
The type of the second sequence.
Definition alignment_configurator.hpp:86
static constexpr bool expects_alignment_configuration()
Expects alignment configurations.
Definition alignment_configurator.hpp:115
decltype(views::zip(std::declval< sequence_pairs_t >(), std::views::iota(0))|views::chunk(1)) type
The transformed type that models seqan3::detail::indexed_sequence_pair_range.
Definition alignment/pairwise/detail/type_traits.hpp:63
An invocable wrapper that defers the instantiation of a crtp_base class.
Definition deferred_crtp_base.hpp:40
An empty type whose only purpose is to hold an uninstantiated template plus its arguments.
Definition lazy_conditional.hpp:30
Provides type traits for working with templates.
Provides seqan3::detail::trace_matrix_full.
Provides seqan3::views::type_reduce.
Provides seqan3::tuple_like.
Provides seqan3::views::zip.