SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
seqan3::detail::alignment_configurator Struct Reference

Configures the alignment algorithm given the sequences and the configuration object. More...

#include <seqan3/alignment/pairwise/alignment_configurator.hpp>

+ Inheritance diagram for seqan3::detail::alignment_configurator:

Classes

struct  select_find_optimum_policy
 Transformation trait that chooses the correct find optimum policy. More...
 
struct  select_gap_policy
 Transformation trait that chooses the correct gap policy. More...
 
struct  select_gap_recursion_policy
 Selects the gap recursion policy. More...
 
struct  select_matrix_policy
 Transformation trait that chooses the correct matrix policy. More...
 

Static Public Member Functions

template<align_pairwise_range_input sequences_t, typename config_t >
requires is_type_specialisation_of_v<config_t, configuration>
static constexpr auto configure (config_t const &cfg)
 Configures the algorithm.
 

Private Types

template<typename traits_t , typename... args_t>
using select_alignment_algorithm_t = lazy_conditional_t< traits_t::is_banded, lazy< pairwise_alignment_algorithm_banded, args_t... >, lazy< pairwise_alignment_algorithm, args_t... > >
 Selects either the banded or the unbanded alignment algorithm based on the given traits type.
 

Static Private Member Functions

template<typename function_wrapper_t , typename config_t >
static constexpr function_wrapper_t configure_edit_distance (config_t const &cfg)
 Configures the edit distance algorithm.
 
template<typename function_wrapper_t , typename config_t >
static constexpr function_wrapper_t configure_scoring_scheme (config_t const &cfg)
 Configures the scoring scheme to use for the alignment computation.
 
template<typename function_wrapper_t , typename... policies_t, typename config_t >
static constexpr function_wrapper_t make_algorithm (config_t const &cfg)
 Constructs the actual alignment algorithm wrapped in the passed std::function object.
 
template<typename config_t >
static constexpr auto maybe_default_output (config_t const &config) noexcept
 Adds maybe the default output arguments if the user did not provide any.
 

Detailed Description

Configures the alignment algorithm given the sequences and the configuration object.

Member Function Documentation

◆ configure()

template<align_pairwise_range_input sequences_t, typename config_t >
requires is_type_specialisation_of_v<config_t, configuration>
static constexpr auto seqan3::detail::alignment_configurator::configure ( config_t const &  cfg)
inlinestaticconstexpr

Configures the algorithm.

Template Parameters
sequences_tThe range type containing the sequence pairs; must model std::ranges::forward_range.
config_tThe alignment configuration type; must be a specialisation of seqan3::configuration.
Parameters
[in]cfgThe configuration object.
Returns
a std::pair over std::function wrapper of the configured alignment algorithm and the adapted alignment configuration.

This function reads the seqan3::configuration object and generates the corresponding alignment algorithm type. During this process some runtime configurations are converted to static configurations if required. In case of a missing configuration that has a default, e.g. the seqan3::align_cfg::output_* options, the default version of this configuration element is added to the passed configuration object. The return type is a std::pair over a std::function object and the adapted configuration object. Thus, the calling function has access to the possibly modified configuration object. The function object type is determined using the following type trait:

// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: CC0-1.0
int main()
{
using first_seq_t = std::tuple_element_t<0, std::ranges::range_value_t<sequences_t>>;
using second_seq_t = std::tuple_element_t<1, std::ranges::range_value_t<sequences_t>>;
// Select the result type based on the sequences and the configuration.
using result_t =
config_t>::type>;
// Define the function wrapper type.
using function_wrapper_t = std::function<result_t(first_seq_t &, second_seq_t &)>;
static_assert(seqan3::detail::is_type_specialisation_of_v<function_wrapper_t, std::function>);
}
Provides seqan3::detail::alignment_selector.
Sets the global alignment method.
Definition align_config_method.hpp:119
Configures the alignment result to output the score.
Definition align_config_output.hpp:40
Stores the alignment results and gives access to score, alignment and the front and end positions.
Definition alignment_result.hpp:145
constexpr configuration edit_scheme
Shortcut for edit distance configuration.
Definition align_config_edit.hpp:48

The arguments to the function object are two ranges, which always need to be passed as lvalue references. Note that even if they are not passed as const lvalue reference (which is not possible, since not all views are const-iterable), they are not modified within the alignment algorithm.

◆ configure_edit_distance()

template<typename function_wrapper_t , typename config_t >
static constexpr function_wrapper_t seqan3::detail::alignment_configurator::configure_edit_distance ( config_t const &  cfg)
inlinestaticconstexprprivate

Configures the edit distance algorithm.

Template Parameters
function_wrapper_tThe invocable alignment function type-erased via std::function.
config_tThe alignment configuration type.
Parameters
[in]cfgThe passed configuration object.

◆ configure_scoring_scheme()

template<typename function_wrapper_t , typename config_t >
static constexpr function_wrapper_t seqan3::detail::alignment_configurator::configure_scoring_scheme ( config_t const &  cfg)
staticconstexprprivate

Configures the scoring scheme to use for the alignment computation.

Template Parameters
function_wrapper_tThe invocable alignment function type-erased via std::function.
config_tThe alignment configuration type.
Parameters
[in]cfgThe passed configuration object.
Returns
the configured alignment algorithm.

The correct scoring scheme is selected based on the vectorisation mode. If no vectorisation is enabled, the scoring scheme is the one configured in seqan3::align_cfg::scoring. If vectorisation is enabled, then the appropriate scoring scheme for the vectorised alignment algorithm is selected. This involves checking whether the passed scoring scheme is a matrix or a simple scoring scheme, which has only mismatch and match costs.

◆ make_algorithm()

template<typename function_wrapper_t , typename... policies_t, typename config_t >
static constexpr function_wrapper_t seqan3::detail::alignment_configurator::make_algorithm ( config_t const &  cfg)
inlinestaticconstexprprivate

Constructs the actual alignment algorithm wrapped in the passed std::function object.

Template Parameters
function_wrapper_tThe invocable alignment function type-erased via std::function.
policies_tA template parameter pack for the already configured policy types.
config_tThe alignment configuration type.
Parameters
[in]cfgThe passed configuration object.
Returns
the configured alignment algorithm.

Configures the matrix and the gap policy and constructs the algorithm with the configured policies.

◆ maybe_default_output()

template<typename config_t >
static constexpr auto seqan3::detail::alignment_configurator::maybe_default_output ( config_t const &  config)
inlinestaticconstexprprivatenoexcept

Adds maybe the default output arguments if the user did not provide any.

Template Parameters
config_tThe original type of the alignment configuration.
Parameters
[in]configThe original user configuration to check.
Returns
Either the original config if the user specified any output configuration or a new config with all output options enabled.

The documentation for this struct was generated from the following file:
Hide me