SeqAn3 3.3.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// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, Knut Reinert & MPI für molekulare Genetik
4// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
5// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md
6// -----------------------------------------------------------------------------------------------------
7
13#pragma once
14
20
21namespace seqan3::detail
22{
23
34template <typename alignment_configuration_t>
35 requires is_type_specialisation_of_v<alignment_configuration_t, configuration>
37{
38protected:
43
44 static_assert(!std::same_as<result_type, empty_type>, "The alignment result type was not configured.");
45
55
59 policy_alignment_result_builder(alignment_configuration_t const & SEQAN3_DOXYGEN_ONLY(config))
60 {}
62
87 template <typename sequence_pair_t,
88 typename index_t,
89 typename score_t,
90 typename matrix_coordinate_t,
91 typename alignment_matrix_t,
92 typename callback_t>
93 requires std::invocable<callback_t, result_type>
94 void make_result_and_invoke([[maybe_unused]] sequence_pair_t && sequence_pair,
95 [[maybe_unused]] index_t && id,
96 [[maybe_unused]] score_t score,
97 [[maybe_unused]] matrix_coordinate_t end_positions,
98 [[maybe_unused]] alignment_matrix_t const & alignment_matrix,
99 callback_t && callback)
100 {
101 using std::get;
102 using invalid_t = std::nullopt_t *;
103
104 result_type result{};
105
107 result.data.sequence1_id = id;
108
110 result.data.sequence2_id = id;
111
112 if constexpr (traits_type::compute_score)
113 {
114 static_assert(!std::same_as<decltype(result.data.score), invalid_t>,
115 "Invalid configuration. Expected result with score!");
116 result.data.score = std::move(score);
117 }
118
120 {
121 static_assert(!std::same_as<decltype(result.data.end_positions), invalid_t>,
122 "Invalid configuration. Expected result with end positions!");
123
124 result.data.end_positions.first = end_positions.col;
125 result.data.end_positions.second = end_positions.row;
126 }
127
129 {
130 aligned_sequence_builder builder{get<0>(sequence_pair), get<1>(sequence_pair)};
131 auto aligned_sequence_result = builder(alignment_matrix.trace_path(end_positions));
132
134 {
135 result.data.begin_positions.first = aligned_sequence_result.first_sequence_slice_positions.first;
136 result.data.begin_positions.second = aligned_sequence_result.second_sequence_slice_positions.first;
137 }
138 }
139
140 callback(std::move(result));
141 }
142};
143} // 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:117
Implements the alignment result builder.
Definition: policy_alignment_result_builder.hpp:37
typename traits_type::alignment_result_type result_type
The alignment result type.
Definition: policy_alignment_result_builder.hpp:42
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:59
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:94
Provides seqan3::configuration and utility functions.
Provides seqan3::detail::empty_type.
@ id
The identifier, usually a string.
A helper concept to check if a type is a sequence pair.
The internal SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
A traits type for the alignment algorithm that exposes static information stored within the alignment...
Definition: alignment/pairwise/detail/type_traits.hpp:83
static constexpr bool requires_trace_information
Flag indicating whether the trace matrix needs to be computed.
Definition: alignment/pairwise/detail/type_traits.hpp:175
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:169
static constexpr bool compute_begin_positions
Flag indicating whether the begin positions shall be computed.
Definition: alignment/pairwise/detail/type_traits.hpp:162
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:167
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:140
static constexpr bool compute_end_positions
Flag indicating whether the end positions shall be computed.
Definition: alignment/pairwise/detail/type_traits.hpp:160
static constexpr bool compute_score
Flag indicating whether the score shall be computed.
Definition: alignment/pairwise/detail/type_traits.hpp:158
Provides type traits for working with templates.