Loading...
Searching...
No Matches
policy_alignment_result_builder.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 <seqan3/alignment/matrix/detail/aligned_sequence_builder.hpp>
#include <seqan3/alignment/pairwise/detail/type_traits.hpp>
#include <seqan3/core/configuration/configuration.hpp>
#include <seqan3/core/detail/empty_type.hpp>
#include <seqan3/core/detail/template_inspection.hpp>
namespace seqan3::detail
{
template <typename alignment_configuration_t>
requires seqan3::detail::is_type_specialisation_of_v<alignment_configuration_t, configuration>
class policy_alignment_result_builder
{
protected:
using traits_type = alignment_configuration_traits<alignment_configuration_t>;
using result_type = typename traits_type::alignment_result_type;
static_assert(!std::same_as<result_type, empty_type>, "The alignment result type was not configured.");
policy_alignment_result_builder() = default;
policy_alignment_result_builder(policy_alignment_result_builder const &) = default;
policy_alignment_result_builder(policy_alignment_result_builder &&) = default;
policy_alignment_result_builder & operator=(policy_alignment_result_builder const &) = default;
policy_alignment_result_builder & operator=(policy_alignment_result_builder &&) = default;
~policy_alignment_result_builder() = default;
policy_alignment_result_builder(alignment_configuration_t const & SEQAN3_DOXYGEN_ONLY(config))
{}
template <typename sequence_pair_t,
typename index_t,
typename score_t,
typename matrix_coordinate_t,
typename alignment_matrix_t,
typename callback_t>
requires std::invocable<callback_t, result_type>
void make_result_and_invoke([[maybe_unused]] sequence_pair_t && sequence_pair,
[[maybe_unused]] index_t && id,
[[maybe_unused]] score_t score,
[[maybe_unused]] matrix_coordinate_t end_positions,
[[maybe_unused]] alignment_matrix_t const & alignment_matrix,
callback_t && callback)
{
using std::get;
using invalid_t = std::nullopt_t *;
result_type result{};
if constexpr (traits_type::output_sequence1_id)
result.data.sequence1_id = id;
if constexpr (traits_type::output_sequence2_id)
result.data.sequence2_id = id;
if constexpr (traits_type::compute_score)
{
static_assert(!std::same_as<decltype(result.data.score), invalid_t>,
"Invalid configuration. Expected result with score!");
result.data.score = std::move(score);
}
if constexpr (traits_type::compute_end_positions)
{
static_assert(!std::same_as<decltype(result.data.end_positions), invalid_t>,
"Invalid configuration. Expected result with end positions!");
result.data.end_positions.first = end_positions.col;
result.data.end_positions.second = end_positions.row;
}
if constexpr (traits_type::requires_trace_information)
{
aligned_sequence_builder builder{get<0>(sequence_pair), get<1>(sequence_pair)};
auto aligned_sequence_result = builder(alignment_matrix.trace_path(end_positions));
if constexpr (traits_type::compute_begin_positions)
{
result.data.begin_positions.first = aligned_sequence_result.first_sequence_slice_positions.first;
result.data.begin_positions.second = aligned_sequence_result.second_sequence_slice_positions.first;
}
}
callback(std::move(result));
}
};
} // namespace seqan3::detail
aligned_sequence_builder.hpp
Provides seqan3::detail::aligned_sequence_builder.
type_traits.hpp
Provides helper type traits for the configuration and execution of the alignment algorithm.
configuration.hpp
Provides seqan3::configuration and utility functions.
empty_type.hpp
Provides seqan3::detail::empty_type.
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.
Hide me