SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
alignment_result.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
28 template <typename id_t,
29  typename score_t,
30  typename back_coord_t = std::nullopt_t *,
31  typename front_coord_t = std::nullopt_t *,
32  typename alignment_t = std::nullopt_t *>
33 struct alignment_result_value_type
34 {
36  id_t id{};
38  score_t score{};
40  back_coord_t back_coordinate{};
42  front_coord_t front_coordinate{};
44  alignment_t alignment{};
45 };
46 
51 alignment_result_value_type()
53  -> alignment_result_value_type<std::nullopt_t *, std::nullopt_t *>;
54 
56 template <typename id_t, typename score_t>
57 alignment_result_value_type(id_t, score_t)
58  -> alignment_result_value_type<id_t, score_t>;
59 
61 template <typename id_t, typename score_t, typename back_coord_t>
62 alignment_result_value_type(id_t, score_t, back_coord_t)
63  -> alignment_result_value_type<id_t, score_t, back_coord_t>;
64 
66 template <typename id_t, typename score_t, typename back_coord_t, typename front_coord_t>
67 alignment_result_value_type(id_t, score_t, back_coord_t, front_coord_t)
68  -> alignment_result_value_type<id_t, score_t, back_coord_t, front_coord_t>;
69 
71 template <typename id_t, typename score_t, typename back_coord_t, typename front_coord_t, typename alignment_t>
72 alignment_result_value_type(id_t, score_t, back_coord_t, front_coord_t, alignment_t)
73  -> alignment_result_value_type<id_t, score_t, back_coord_t, front_coord_t, alignment_t>;
75 
76 } // namespace seqan3::detail
77 
78 namespace seqan3
79 {
80 
93 template <typename alignment_result_traits>
95  requires detail::is_type_specialisation_of_v<alignment_result_traits, detail::alignment_result_value_type>
98 {
99 private:
101  alignment_result_traits data;
102 
107  using id_t = decltype(data.id);
110  using score_t = decltype(data.score);
112  using back_coord_t = decltype(data.back_coordinate);
114  using front_coord_t = decltype(data.front_coordinate);
116  using alignment_t = decltype(data.alignment);
118 
119 public:
127  alignment_result(alignment_result_traits value) : data(value) {};
128 
129  alignment_result() = default;
130  alignment_result(alignment_result const &) = default;
131  alignment_result(alignment_result &&) = default;
132  alignment_result & operator=(alignment_result const &) = default;
134  ~alignment_result() = default;
135 
146  constexpr id_t id() const noexcept
147  {
148  static_assert(!std::is_same_v<id_t, std::nullopt_t *>,
149  "Failed to access the identifier.");
150  return data.id;
151  }
152 
157  constexpr score_t score() const noexcept
158  {
159  static_assert(!std::is_same_v<score_t, std::nullopt_t *>,
160  "Failed to access the score.");
161  return data.score;
162  }
163 
169  constexpr back_coord_t const & back_coordinate() const noexcept
170  {
171  static_assert(!std::is_same_v<back_coord_t, std::nullopt_t *>,
172  "Trying to access the back coordinate, although it was not requested in the alignment "
173  "configuration.");
174  return data.back_coordinate;
175  }
176 
183  constexpr front_coord_t const & front_coordinate() const noexcept
184  {
185  static_assert(!std::is_same_v<front_coord_t, std::nullopt_t *>,
186  "Trying to access the front coordinate, although it was not requested in the alignment "
187  "configuration.");
188  return data.front_coordinate;
189  }
190 
196  constexpr alignment_t const & alignment() const noexcept
197  {
198  static_assert(!std::is_same_v<alignment_t, std::nullopt_t *>,
199  "Trying to access the alignment, although it was not requested in the alignment configuration.");
200  return data.alignment;
201  }
203 };
204 
205 } // namespace seqan3
constexpr id_t id() const noexcept
Returns the alignment identifier.
Definition: alignment_result.hpp:146
constexpr back_coord_t const & back_coordinate() const noexcept
Returns the back coordinate of the alignment.
Definition: alignment_result.hpp:169
Provides seqan3::type_list and auxiliary type traits.
The main SeqAn3 namespace.
Stores the alignment results and gives access to score, alignment and the front and back coordinates...
Definition: alignment_result.hpp:97
alignment_result & operator=(alignment_result const &)=default
Defaulted.
Definition: aligned_sequence_concept.hpp:35
alignment_result()=default
Defaulted.
constexpr front_coord_t const & front_coordinate() const noexcept
Returns the front coordinate of the alignment.
Definition: alignment_result.hpp:183
constexpr score_t score() const noexcept
Returns the alignment score.
Definition: alignment_result.hpp:157
constexpr alignment_t const & alignment() const noexcept
Returns the actual alignment, i.e. the base pair matching.
Definition: alignment_result.hpp:196
alignment_result(alignment_result_traits value)
Constructs a seqan3::alignment_result from an alignment_result_traits object.
Definition: alignment_result.hpp:127