SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
alignment_result.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2020, 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 
14 #pragma once
15 
17 
18 namespace seqan3::detail
19 {
20 
30 template <typename id_t,
31  typename score_t,
32  typename back_coord_t = std::nullopt_t *,
33  typename front_coord_t = std::nullopt_t *,
34  typename alignment_t = std::nullopt_t *,
35  typename score_debug_matrix_t = std::nullopt_t *,
36  typename trace_debug_matrix_t = std::nullopt_t *>
37 struct alignment_result_value_type
38 {
40  id_t id{};
42  score_t score{};
44  back_coord_t back_coordinate{};
46  front_coord_t front_coordinate{};
48  alignment_t alignment{};
49 
51  score_debug_matrix_t score_debug_matrix{};
53  trace_debug_matrix_t trace_debug_matrix{};
54 };
55 
60 alignment_result_value_type()
62  -> alignment_result_value_type<std::nullopt_t *, std::nullopt_t *>;
63 
65 template <typename id_t, typename score_t>
66 alignment_result_value_type(id_t, score_t)
67  -> alignment_result_value_type<id_t, score_t>;
68 
70 template <typename id_t, typename score_t, typename back_coord_t>
71 alignment_result_value_type(id_t, score_t, back_coord_t)
72  -> alignment_result_value_type<id_t, score_t, back_coord_t>;
73 
75 template <typename id_t, typename score_t, typename back_coord_t, typename front_coord_t>
76 alignment_result_value_type(id_t, score_t, back_coord_t, front_coord_t)
77  -> alignment_result_value_type<id_t, score_t, back_coord_t, front_coord_t>;
78 
80 template <typename id_t, typename score_t, typename back_coord_t, typename front_coord_t, typename alignment_t>
81 alignment_result_value_type(id_t, score_t, back_coord_t, front_coord_t, alignment_t)
82  -> alignment_result_value_type<id_t, score_t, back_coord_t, front_coord_t, alignment_t>;
84 
85 } // namespace seqan3::detail
86 
87 namespace seqan3
88 {
89 
102 template <typename alignment_result_traits>
104  requires detail::is_type_specialisation_of_v<alignment_result_traits, detail::alignment_result_value_type>
107 {
108 private:
110  alignment_result_traits data;
111 
116  using id_t = decltype(data.id);
119  using score_t = decltype(data.score);
121  using back_coord_t = decltype(data.back_coordinate);
123  using front_coord_t = decltype(data.front_coordinate);
125  using alignment_t = decltype(data.alignment);
127 
128 public:
136  alignment_result(alignment_result_traits value) : data(value) {};
137 
138  alignment_result() = default;
139  alignment_result(alignment_result const &) = default;
140  alignment_result(alignment_result &&) = default;
141  alignment_result & operator=(alignment_result const &) = default;
143  ~alignment_result() = default;
144 
154  constexpr id_t id() const noexcept
155  {
156  static_assert(!std::is_same_v<id_t, std::nullopt_t *>,
157  "Identifier is not available but should.");
158  return data.id;
159  }
160 
164  constexpr score_t score() const noexcept
165  {
166  static_assert(!std::is_same_v<score_t, std::nullopt_t *>,
167  "Alignment score is not available but should.");
168  return data.score;
169  }
170 
177  constexpr back_coord_t const & back_coordinate() const noexcept
178  {
179  static_assert(!std::is_same_v<back_coord_t, std::nullopt_t *>,
180  "Trying to access the back coordinate, although it was not requested in the alignment "
181  "configuration.");
182  return data.back_coordinate;
183  }
184 
195  constexpr front_coord_t const & front_coordinate() const noexcept
196  {
197  static_assert(!std::is_same_v<front_coord_t, std::nullopt_t *>,
198  "Trying to access the front coordinate, although it was not requested in the alignment "
199  "configuration.");
200  return data.front_coordinate;
201  }
202 
209  constexpr alignment_t const & alignment() const noexcept
210  {
211  static_assert(!std::is_same_v<alignment_t, std::nullopt_t *>,
212  "Trying to access the alignment, although it was not requested in the alignment configuration.");
213  return data.alignment;
214  }
216 
218 
229  constexpr auto const & score_matrix() const noexcept
230  {
231  static_assert(!std::is_same_v<decltype(data.score_debug_matrix), std::nullopt_t *>,
232  "Trying to access the score matrix, although it was not requested in the alignment configuration.");
233  return data.score_debug_matrix;
234  }
235 
247  constexpr auto const & trace_matrix() const noexcept
248  {
249  static_assert(!std::is_same_v<decltype(data.trace_debug_matrix), std::nullopt_t *>,
250  "Trying to access the trace matrix, although it was not requested in the alignment configuration.");
251  return data.trace_debug_matrix;
252  }
254 };
255 
256 } // namespace seqan3
std::is_same_v
T is_same_v
seqan3::alignment_result::front_coordinate
constexpr const front_coord_t & front_coordinate() const noexcept
Returns the front coordinate of the alignment.
Definition: alignment_result.hpp:195
seqan3::alignment_result::operator=
alignment_result & operator=(alignment_result const &)=default
Defaulted.
seqan3::alignment_result::~alignment_result
~alignment_result()=default
seqan3::alignment_result::id
constexpr id_t id() const noexcept
Returns the alignment identifier.
Definition: alignment_result.hpp:154
template_inspection.hpp
Provides seqan3::type_list and auxiliary type traits.
seqan3::alignment_result::alignment
constexpr const alignment_t & alignment() const noexcept
Returns the actual alignment, i.e. the base pair matching.
Definition: alignment_result.hpp:209
seqan3::alignment_result
Stores the alignment results and gives access to score, alignment and the front and back coordinates.
Definition: alignment_result.hpp:106
seqan3::alignment_result::alignment_result
alignment_result()=default
Defaulted.
seqan3
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:36
seqan3::alignment_result::score
constexpr score_t score() const noexcept
Returns the alignment score.
Definition: alignment_result.hpp:164
std::nullopt_t
seqan3::alignment_result::alignment_result
alignment_result(alignment_result_traits value)
Constructs a seqan3::alignment_result from an alignment_result_traits object.
Definition: alignment_result.hpp:136
seqan3::alignment_result::back_coordinate
constexpr const back_coord_t & back_coordinate() const noexcept
Returns the back coordinate of the alignment.
Definition: alignment_result.hpp:177
seqan3::field::alignment
The (pairwise) alignment stored in an seqan3::alignment object.