SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
policy_alignment_result_builder.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
10#pragma once
11
17
18namespace seqan3::detail
19{
20
31template <typename alignment_configuration_t>
32 requires seqan3::detail::is_type_specialisation_of_v<alignment_configuration_t, configuration>
34{
35protected:
40
41 static_assert(!std::same_as<result_type, empty_type>, "The alignment result type was not configured.");
42
52
56 policy_alignment_result_builder(alignment_configuration_t const & SEQAN3_DOXYGEN_ONLY(config))
57 {}
59
84 template <typename sequence_pair_t,
85 typename index_t,
86 typename score_t,
87 typename matrix_coordinate_t,
88 typename alignment_matrix_t,
89 typename callback_t>
90 requires std::invocable<callback_t, result_type>
91 void make_result_and_invoke([[maybe_unused]] sequence_pair_t && sequence_pair,
92 [[maybe_unused]] index_t && id,
93 [[maybe_unused]] score_t score,
94 [[maybe_unused]] matrix_coordinate_t end_positions,
95 [[maybe_unused]] alignment_matrix_t const & alignment_matrix,
96 callback_t && callback)
97 {
98 using std::get;
99 using invalid_t = std::nullopt_t *;
100
101 result_type result{};
102
104 result.data.sequence1_id = id;
105
107 result.data.sequence2_id = id;
108
109 if constexpr (traits_type::compute_score)
110 {
111 static_assert(!std::same_as<decltype(result.data.score), invalid_t>,
112 "Invalid configuration. Expected result with score!");
113 result.data.score = std::move(score);
114 }
115
117 {
118 static_assert(!std::same_as<decltype(result.data.end_positions), invalid_t>,
119 "Invalid configuration. Expected result with end positions!");
120
121 result.data.end_positions.first = end_positions.col;
122 result.data.end_positions.second = end_positions.row;
123 }
124
126 {
127 aligned_sequence_builder builder{get<0>(sequence_pair), get<1>(sequence_pair)};
128 auto aligned_sequence_result = builder(alignment_matrix.trace_path(end_positions));
129
131 {
132 result.data.begin_positions.first = aligned_sequence_result.first_sequence_slice_positions.first;
133 result.data.begin_positions.second = aligned_sequence_result.second_sequence_slice_positions.first;
134 }
135 }
136
137 callback(std::move(result));
138 }
139};
140} // namespace seqan3::detail
Provides seqan3::detail::aligned_sequence_builder.
Provides helper type traits for the configuration and execution of the alignment algorithm.
Builds the alignment for a given pair of sequences and the respective trace.
Definition aligned_sequence_builder.hpp:114
Implements the alignment result builder.
Definition policy_alignment_result_builder.hpp:34
typename traits_type::alignment_result_type result_type
The alignment result type.
Definition policy_alignment_result_builder.hpp:39
policy_alignment_result_builder(policy_alignment_result_builder const &)=default
Defaulted.
policy_alignment_result_builder(policy_alignment_result_builder &&)=default
Defaulted.
policy_alignment_result_builder & operator=(policy_alignment_result_builder &&)=default
Defaulted.
policy_alignment_result_builder(alignment_configuration_t const &config)
Construction and initialisation using the alignment configuration.
Definition policy_alignment_result_builder.hpp:56
policy_alignment_result_builder & operator=(policy_alignment_result_builder const &)=default
Defaulted.
void make_result_and_invoke(sequence_pair_t &&sequence_pair, index_t &&id, score_t score, matrix_coordinate_t end_positions, alignment_matrix_t const &alignment_matrix, callback_t &&callback)
Builds the seqan3::alignment_result based on the given alignment result type and then invokes the giv...
Definition policy_alignment_result_builder.hpp:91
Provides seqan3::configuration and utility functions.
Provides seqan3::detail::empty_type.
A helper concept to check if a type is a sequence pair.
The internal SeqAn3 namespace.
Definition aligned_sequence_concept.hpp:26
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
static constexpr bool output_sequence2_id
Flag indicating whether the id of the second sequence shall be returned.
Definition alignment/pairwise/detail/type_traits.hpp:165
static constexpr bool compute_begin_positions
Flag indicating whether the begin positions shall be computed.
Definition alignment/pairwise/detail/type_traits.hpp:158
static constexpr bool output_sequence1_id
Flag indicating whether the id of the first sequence shall be returned.
Definition alignment/pairwise/detail/type_traits.hpp:163
decltype(determine_alignment_result_type()) alignment_result_type
The alignment result type if present. Otherwise seqan3::detail::empty_type.
Definition alignment/pairwise/detail/type_traits.hpp:137
static constexpr bool compute_end_positions
Flag indicating whether the end positions shall be computed.
Definition alignment/pairwise/detail/type_traits.hpp:156
static constexpr bool compute_score
Flag indicating whether the score shall be computed.
Definition alignment/pairwise/detail/type_traits.hpp:154
Provides type traits for working with templates.
Hide me