Loading...
Searching...
No Matches
alignment/pairwise/detail/type_traits.hpp
Go to the documentation of this file.
// SPDX-FileCopyrightText: 2006-2025 Knut Reinert & Freie Universität Berlin
// SPDX-FileCopyrightText: 2016-2025 Knut Reinert & MPI für molekulare Genetik
// SPDX-License-Identifier: BSD-3-Clause
#pragma once
#include <ranges>
#include <type_traits>
#include <seqan3/alignment/configuration/align_config_band.hpp>
#include <seqan3/alignment/configuration/align_config_debug.hpp>
#include <seqan3/alignment/configuration/align_config_method.hpp>
#include <seqan3/alignment/configuration/align_config_on_result.hpp>
#include <seqan3/alignment/configuration/align_config_output.hpp>
#include <seqan3/alignment/configuration/align_config_parallel.hpp>
#include <seqan3/alignment/configuration/align_config_result_type.hpp>
#include <seqan3/alignment/configuration/align_config_score_type.hpp>
#include <seqan3/alignment/configuration/align_config_scoring_scheme.hpp>
#include <seqan3/alignment/configuration/align_config_vectorised.hpp>
#include <seqan3/alignment/matrix/detail/matrix_coordinate.hpp>
#include <seqan3/alignment/matrix/detail/trace_directions.hpp>
#include <seqan3/alignment/pairwise/detail/concept.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/empty_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>
#include <seqan3/utility/detail/bits_of.hpp>
#include <seqan3/utility/simd/simd.hpp>
#include <seqan3/utility/simd/simd_traits.hpp>
#include <seqan3/utility/type_traits/function_traits.hpp>
#include <seqan3/utility/type_traits/lazy_conditional.hpp>
#include <seqan3/utility/views/chunk.hpp>
#include <seqan3/utility/views/zip.hpp>
namespace seqan3::detail
{
//------------------------------------------------------------------------------
// chunked_indexed_sequence_pairs
//------------------------------------------------------------------------------
template <typename sequence_pairs_t>
requires sequence_pair_range<std::remove_reference_t<sequence_pairs_t>>
struct chunked_indexed_sequence_pairs
{
using type = decltype(views::zip(std::declval<sequence_pairs_t>(), std::views::iota(0)) | views::chunk(1));
};
//------------------------------------------------------------------------------
// alignment_configuration_traits
//------------------------------------------------------------------------------
template <typename configuration_t>
requires is_type_specialisation_of_v<std::remove_cv_t<configuration_t>, configuration>
struct alignment_configuration_traits
{
private:
template <arithmetic score_t>
using select_scalar_index_t = min_viable_uint_t<1ull << (bits_of<score_t> - 1)>;
static constexpr auto determine_alignment_result_type() noexcept
{
if constexpr (configuration_t::template exists<align_cfg::detail::result_type>())
{
using result_type_cfg_t = std::remove_cvref_t<decltype(seqan3::get<align_cfg::detail::result_type>(
std::declval<configuration_t>()))>;
return typename result_type_cfg_t::type{}; // Access the stored result_type.
}
else
{
return empty_type{};
}
}
public:
static constexpr bool is_vectorised = configuration_t::template exists<align_cfg::vectorised>();
static constexpr bool is_parallel = configuration_t::template exists<align_cfg::parallel>();
static constexpr bool is_global = configuration_t::template exists<seqan3::align_cfg::method_global>();
static constexpr bool is_local = configuration_t::template exists<seqan3::align_cfg::method_local>();
static constexpr bool is_banded = configuration_t::template exists<align_cfg::band_fixed_size>();
static constexpr bool is_debug = configuration_t::template exists<detail::debug_mode>();
static constexpr bool is_one_way_execution = configuration_t::template exists<align_cfg::on_result>();
using scoring_scheme_type = decltype(get<align_cfg::scoring_scheme>(std::declval<configuration_t>()).scheme);
using scoring_scheme_alphabet_type = typename scoring_scheme_type::alphabet_type;
using original_score_type = typename std::remove_reference_t<decltype(std::declval<configuration_t>().get_or(
align_cfg::score_type<int32_t>{}))>::type;
using score_type = std::conditional_t<is_vectorised, simd_type_t<original_score_type>, original_score_type>;
using trace_type = std::conditional_t<is_vectorised, simd_type_t<original_score_type>, trace_directions>;
using alignment_result_type = decltype(determine_alignment_result_type());
using matrix_index_type =
std::conditional_t<is_vectorised, simd_type_t<select_scalar_index_t<original_score_type>>, size_t>;
using matrix_coordinate_type =
lazy_conditional_t<is_vectorised, lazy<simd_matrix_coordinate, matrix_index_type>, matrix_coordinate>;
static constexpr size_t alignments_per_vector = []() constexpr
{
if constexpr (is_vectorised)
return simd_traits<score_type>::length;
else
return 1;
}();
static constexpr bool compute_score = configuration_t::template exists<align_cfg::output_score>();
static constexpr bool compute_end_positions = configuration_t::template exists<align_cfg::output_end_position>();
static constexpr bool compute_begin_positions =
configuration_t::template exists<align_cfg::output_begin_position>();
static constexpr bool compute_sequence_alignment = configuration_t::template exists<align_cfg::output_alignment>();
static constexpr bool output_sequence1_id = configuration_t::template exists<align_cfg::output_sequence1_id>();
static constexpr bool output_sequence2_id = configuration_t::template exists<align_cfg::output_sequence2_id>();
static constexpr bool has_output_configuration = compute_score || compute_end_positions || compute_begin_positions
|| compute_sequence_alignment || output_sequence1_id
|| output_sequence2_id;
static constexpr bool requires_trace_information = compute_begin_positions || compute_sequence_alignment;
};
//------------------------------------------------------------------------------
// alignment_function_traits
//------------------------------------------------------------------------------
template <typename function_t>
struct alignment_function_traits
{
using sequence_input_type = typename function_traits<function_t>::template argument_type_at<0>;
using callback_type = typename function_traits<function_t>::template argument_type_at<1>;
using alignment_result_type = typename function_traits<callback_type>::template argument_type_at<0>;
};
} // namespace seqan3::detail
align_config_band.hpp
Provides seqan3::detail::align_config_band.
align_config_debug.hpp
Provides seqan3::align_cfg::detail::debug.
align_config_method.hpp
Provides global and local alignment configurations.
align_config_on_result.hpp
Provides seqan3::align_cfg::on_result.
align_config_output.hpp
Provides configuration for alignment output.
align_config_parallel.hpp
Provides seqan3::align_cfg::parallel configuration.
align_config_result_type.hpp
Provides seqan3::align_cfg::detail::result_type.
align_config_score_type.hpp
Provides alignment configuration seqan3::align_cfg::score_type.
align_config_scoring_scheme.hpp
Provides seqan3::align_cfg::scoring_scheme.
align_config_vectorised.hpp
Provides seqan3::align_cfg::vectorised configuration.
concept.hpp
Provides concepts needed internally for the alignment algorithms.
bits_of.hpp
Provides utility functions for bit twiddling.
chunk.hpp
Provides seqan3::views::chunk.
seqan3::configuration::configuration
configuration(config_t) -> configuration< config_t >
Deduces the correct configuration element type from the passed seqan3::pipeable_config_element.
configuration.hpp
Provides seqan3::configuration and utility functions.
std::declval
T declval(T... args)
empty_type.hpp
Provides seqan3::detail::empty_type.
function_traits.hpp
Provides various type traits for use on functions.
seqan3::views::zip
seqan::stl::views::zip zip
A view adaptor that takes several views and returns tuple-like values from every i-th element of each...
Definition zip.hpp:24
seqan3::views::chunk
seqan::stl::views::chunk chunk
A view adaptor that divides a range into chunks. <dl class="no-api">This entity is not part of the Se...
Definition chunk.hpp:23
lazy_conditional.hpp
Provides lazy template instantiation traits.
matrix_coordinate.hpp
Provides seqan3::detail::matrix_index, seqan3::detail::matrix_coordinate and associated strong types.
seqan3::get
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:412
template_inspection.hpp
Provides type traits for working with templates.
trace_directions.hpp
Provides the declaration of seqan3::detail::trace_directions.
type_traits
zip.hpp
Provides seqan3::views::zip.
Hide me