22 namespace seqan3::detail
26 template <
typename configuration_t>
27 #if !SEQAN3_WORKAROUND_GCC_93467
29 requires is_type_specialisation_of_v<configuration_t, configuration>
32 class policy_alignment_result_builder;
46 template <
typename sequence1_id_t,
47 typename sequence2_id_t,
54 struct alignment_result_value_type
57 sequence1_id_t sequence1_id{};
59 sequence2_id_t sequence2_id{};
63 end_positions_t end_positions{};
65 begin_positions_t begin_positions{};
70 score_debug_matrix_t score_debug_matrix{};
72 trace_debug_matrix_t trace_debug_matrix{};
80 alignment_result_value_type()
81 -> alignment_result_value_type<std::nullopt_t *, std::nullopt_t *, std::nullopt_t *>;
84 template <
typename sequence1_
id_t,
typename sequence2_
id_t,
typename score_t>
85 alignment_result_value_type(sequence1_id_t, sequence2_id_t, score_t)
86 -> alignment_result_value_type<sequence1_id_t, sequence2_id_t, score_t>;
89 template <
typename sequence1_
id_t,
typename sequence2_
id_t,
typename score_t,
typename end_positions_t>
90 alignment_result_value_type(sequence1_id_t, sequence2_id_t, score_t, end_positions_t)
91 -> alignment_result_value_type<sequence1_id_t, sequence2_id_t, score_t, end_positions_t>;
94 template <
typename sequence1_id_t,
95 typename sequence2_id_t,
97 typename end_positions_t,
98 typename begin_positions_t>
99 alignment_result_value_type(sequence1_id_t, sequence2_id_t, score_t, end_positions_t, begin_positions_t)
100 -> alignment_result_value_type<sequence1_id_t, sequence2_id_t, score_t, end_positions_t, begin_positions_t>;
103 template <
typename sequence1_id_t,
104 typename sequence2_id_t,
106 typename end_positions_t,
107 typename begin_positions_t,
108 typename alignment_t>
109 alignment_result_value_type(sequence1_id_t, sequence2_id_t, score_t, end_positions_t, begin_positions_t, alignment_t)
110 -> alignment_result_value_type<sequence1_id_t,
119 template <
typename result_t>
120 struct alignment_result_value_type_accessor;
150 template <
typename alignment_result_value_t>
152 requires detail::is_type_specialisation_of_v<alignment_result_value_t, detail::alignment_result_value_type>
158 alignment_result_value_t data{};
165 using sequence1_id_t = decltype(data.sequence1_id);
167 using sequence2_id_t = decltype(data.sequence2_id);
169 using score_t = decltype(data.score);
171 using end_positions_t = decltype(data.end_positions);
173 using begin_positions_t = decltype(data.begin_positions);
175 using alignment_t = decltype(data.alignment);
179 template <
typename configuration_t>
180 #if !SEQAN3_WORKAROUND_GCC_93467
182 requires detail::is_type_specialisation_of_v<configuration_t, configuration>
185 friend class detail::policy_alignment_result_builder;
219 static_assert(!std::is_same_v<sequence1_id_t, std::nullopt_t *>,
220 "Trying to access the id of the first sequence, although it was not requested in the"
221 " alignment configuration.");
222 return data.sequence1_id;
230 static_assert(!std::is_same_v<sequence2_id_t, std::nullopt_t *>,
231 "Trying to access the id of the second sequence, although it was not requested in the"
232 " alignment configuration.");
233 return data.sequence2_id;
239 constexpr score_t
score() const noexcept
241 static_assert(!std::is_same_v<score_t, std::nullopt_t *>,
242 "Trying to access the score, although it was not requested in the alignment configuration.");
254 static_assert(!std::is_same_v<end_positions_t, std::nullopt_t *>,
255 "Trying to access the end position of the first sequence, although it was not requested in the"
256 " alignment configuration.");
257 return data.end_positions.first;
268 static_assert(!std::is_same_v<end_positions_t, std::nullopt_t *>,
269 "Trying to access the end position of the second sequence, although it was not requested in the"
270 " alignment configuration.");
271 return data.end_positions.second;
286 static_assert(!std::is_same_v<begin_positions_t, std::nullopt_t *>,
287 "Trying to access the begin position of the first sequence, although it was not requested in the"
288 " alignment configuration.");
289 return data.begin_positions.first;
304 static_assert(!std::is_same_v<begin_positions_t, std::nullopt_t *>,
305 "Trying to access the begin position of the second sequence, although it was not requested in the"
306 " alignment configuration.");
307 return data.begin_positions.second;
316 constexpr alignment_t
const &
alignment() const noexcept
318 static_assert(!std::is_same_v<alignment_t, std::nullopt_t *>,
319 "Trying to access the alignment, although it was not requested in the alignment configuration.");
320 return data.alignment;
336 constexpr
auto const & score_matrix() const noexcept
339 "Trying to access the score matrix, although it was not requested in the alignment configuration.");
340 return data.score_debug_matrix;
354 constexpr
auto const & trace_matrix() const noexcept
357 "Trying to access the trace matrix, although it was not requested in the alignment configuration.");
358 return data.trace_debug_matrix;
364 namespace seqan3::detail
376 template <
typename result_value_t>
377 struct alignment_result_value_type_accessor<alignment_result<result_value_t>>
380 using type = result_value_t;
396 template <
typename char_t,
typename alignment_result_t>
398 requires detail::is_type_specialisation_of_v<std::remove_cvref_t<alignment_result_t>, alignment_result>
400 inline debug_stream_type<char_t> &
operator<<(debug_stream_type<char_t> & stream, alignment_result_t && result)
403 using result_data_t =
404 typename detail::alignment_result_value_type_accessor<std::remove_cvref_t<alignment_result_t>>::type;
406 constexpr
bool has_sequence1_id = !std::is_same_v<decltype(std::declval<result_data_t>().sequence1_id), disabled_t>;
407 constexpr
bool has_sequence2_id = !std::is_same_v<decltype(std::declval<result_data_t>().sequence2_id), disabled_t>;
408 constexpr
bool has_score = !std::is_same_v<decltype(std::declval<result_data_t>().score), disabled_t>;
409 constexpr
bool has_end_positions = !std::is_same_v<decltype(std::declval<result_data_t>().end_positions),
411 constexpr
bool has_begin_positions = !std::is_same_v<decltype(std::declval<result_data_t>().begin_positions),
413 constexpr
bool has_alignment = !std::is_same_v<decltype(std::declval<result_data_t>().alignment), disabled_t>;
415 bool prepend_comma =
false;
416 auto append_to_stream = [&] (
auto && ...args)
418 ((stream << (prepend_comma ?
std::string{
", "} :
std::string{})) << ... << std::forward<decltype(args)>(args));
419 prepend_comma =
true;
423 if constexpr (has_sequence1_id)
424 append_to_stream(
"sequence1 id: ", result.sequence1_id());
425 if constexpr (has_sequence2_id)
426 append_to_stream(
"sequence2 id: ", result.sequence2_id());
427 if constexpr (has_score)
428 append_to_stream(
"score: ", result.score());
429 if constexpr (has_begin_positions)
430 append_to_stream(
"begin: (", result.sequence1_begin_position(),
",", result.sequence2_begin_position(),
")");
431 if constexpr (has_end_positions)
432 append_to_stream(
"end: (", result.sequence1_end_position(),
",", result.sequence2_end_position(),
")");
433 if constexpr (has_alignment)
434 append_to_stream(
"\nalignment:\n", result.alignment());
Stores the alignment results and gives access to score, alignment and the front and end positionss.
Definition: alignment_result.hpp:155
constexpr sequence2_id_t sequence2_id() const noexcept
Returns the alignment identifier of the second sequence.
Definition: alignment_result.hpp:228
constexpr alignment_t const & alignment() const noexcept
Returns the actual alignment, i.e. the base pair matching.
Definition: alignment_result.hpp:316
alignment_result & operator=(alignment_result &&)=default
Defaulted.
constexpr sequence1_id_t sequence1_id() const noexcept
Returns the alignment identifier of the first sequence.
Definition: alignment_result.hpp:217
constexpr auto sequence2_end_position() const noexcept
Returns the end position of the second sequence of the alignment.
Definition: alignment_result.hpp:266
constexpr auto sequence1_begin_position() const noexcept
Returns the begin position of the first sequence of the alignment.
Definition: alignment_result.hpp:284
alignment_result(alignment_result const &)=default
Defaulted.
constexpr auto sequence2_begin_position() const noexcept
Returns the begin position of the second sequence of the alignment.
Definition: alignment_result.hpp:302
~alignment_result()=default
Defaulted.
constexpr score_t score() const noexcept
Returns the alignment score.
Definition: alignment_result.hpp:239
constexpr auto sequence1_end_position() const noexcept
Returns the end position of the first sequence of the alignment.
Definition: alignment_result.hpp:252
alignment_result & operator=(alignment_result const &)=default
Defaulted.
alignment_result()=default
alignment_result(alignment_result &&)=default
Defaulted.
Provides seqan3::configuration and utility functions.
Provides seqan3::debug_stream and related types.
Provides type traits for working with templates.
debug_stream_type< char_t > & operator<<(debug_stream_type< char_t > &stream, alignment_t &&alignment)
Stream operator for alignments, which are represented as tuples of aligned sequences.
Definition: debug_stream_alignment.hpp:101
@ alignment
The (pairwise) alignment stored in an object that models seqan3::detail::pairwise_alignment.
auto const move
A view that turns lvalue-references into rvalue-references.
Definition: move.hpp:74
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29