SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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 // ============================================================================
19 // to_phred()
20 // ============================================================================
21 
22 namespace seqan3::detail::adl_only
23 {
24 
26 template <typename ...args_t>
27 void to_phred(args_t ...) = delete;
28 
31 struct to_phred_cpo : public detail::customisation_point_object<to_phred_cpo, 2>
32 {
34  using base_t = detail::customisation_point_object<to_phred_cpo, 2>;
36  using base_t::base_t;
37 
42  template <typename alphabet_t>
43  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)
44  (
45  /*return*/ seqan3::custom::alphabet<alphabet_t>::to_phred(std::forward<alphabet_t>(alphabet)) /*;*/
46  );
47 
52  template <typename alphabet_t>
53  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)
54  (
55  /*return*/ to_phred(std::forward<alphabet_t>(alphabet)) /*;*/
56  );
57 
62  template <typename alphabet_t>
63  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)
64  (
65  /*return*/ std::forward<alphabet_t>(alphabet).to_phred() /*;*/
66  );
67 };
68 
69 } // namespace seqan3::detail::adl_only
70 
71 namespace seqan3
72 {
73 
109 inline constexpr auto to_phred = detail::adl_only::to_phred_cpo{};
111 
117 template <typename alphabet_type>
119  requires requires { { seqan3::to_phred(std::declval<alphabet_type>()) }; }
121 using alphabet_phred_t = decltype(seqan3::to_phred(std::declval<alphabet_type>()));
122 
123 } // namespace seqan3
124 
125 // ============================================================================
126 // assign_phred_to()
127 // ============================================================================
128 
129 namespace seqan3::detail::adl_only
130 {
131 
133 template <typename ...args_t>
134 void assign_phred_to(args_t ...) = delete;
135 
138 struct assign_phred_to_cpo : public detail::customisation_point_object<assign_phred_to_cpo, 2>
139 {
141  using base_t = detail::customisation_point_object<assign_phred_to_cpo, 2>;
143  using base_t::base_t;
144 
158  template <typename alphabet_t>
159  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>,
161  alphabet_t && alphabet)
162  (
163  /*return*/ static_cast<alphabet_t>(seqan3::custom::alphabet<alphabet_t>::assign_phred_to(phred, alphabet)) /*;*/
164  );
165 
180  template <typename alphabet_t>
181  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>,
183  alphabet_t && alphabet)
184  (
185  /*return*/ static_cast<alphabet_t>(assign_phred_to(phred, alphabet)) /*;*/
186  );
187 
198  template <typename alphabet_t>
199  static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>,
201  alphabet_t && alphabet)
202  (
203  /*return*/ static_cast<alphabet_t>(alphabet.assign_phred(phred)) /*;*/
204  );
205 };
206 
207 } // namespace seqan3::detail::adl_only
208 
209 namespace seqan3
210 {
211 
249 inline constexpr auto assign_phred_to = detail::adl_only::assign_phred_to_cpo{};
251 
252 } // namespace seqan3
253 
254 // ============================================================================
255 // seqan3::quality_alphabet
256 // ============================================================================
257 
258 namespace seqan3
259 {
260 
291 template <typename t>
292 SEQAN3_CONCEPT quality_alphabet = alphabet<t> && requires(t qual)
293 {
294  { seqan3::to_phred(qual) };
295 };
297 
298 // ============================================================================
299 // seqan3::writable_quality_alphabet
300 // ============================================================================
301 
331 template <typename t>
334  requires(t v, alphabet_phred_t<t> c)
335 {
336  { seqan3::assign_phred_to(c, v) };
337 };
339 
340 } // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
#define SEQAN3_CPO_OVERLOAD(...)
A macro that helps to define a seqan3::detail::customisation_point_object.
Definition: customisation_point.hpp:113
constexpr auto to_phred
The public getter function for the Phred representation of a quality score.
Definition: concept.hpp:100
decltype(seqan3::to_phred(std::declval< alphabet_type >())) alphabet_phred_t
The phred_type of the alphabet; defined as the return type of seqan3::to_phred.
Definition: concept.hpp:112
constexpr auto assign_phred_to
Assign a Phred score to a quality alphabet object.
Definition: concept.hpp:231
The generic alphabet concept that covers most data types used in ranges.
A concept that indicates whether an alphabet represents quality scores.
Refines seqan3::alphabet and adds assignability.
A concept that indicates whether a writable alphabet represents quality scores.
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition: concept.hpp:49