SeqAn3 3.1.0
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
22namespace seqan3::detail::adl_only
23{
24
26template <typename ...args_t>
27void to_phred(args_t ...) = delete;
28
31struct 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
71namespace seqan3
72{
73
109inline constexpr auto to_phred = detail::adl_only::to_phred_cpo{};
111
117template <typename alphabet_type>
119 requires requires { { seqan3::to_phred(std::declval<alphabet_type>()) }; }
121using alphabet_phred_t = decltype(seqan3::to_phred(std::declval<alphabet_type>()));
122
123} // namespace seqan3
124
125// ============================================================================
126// assign_phred_to()
127// ============================================================================
128
129namespace seqan3::detail::adl_only
130{
131
133template <typename ...args_t>
134void assign_phred_to(args_t ...) = delete;
135
138struct 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
209namespace seqan3
210{
211
249inline constexpr auto assign_phred_to = detail::adl_only::assign_phred_to_cpo{};
251
252} // namespace seqan3
253
254// ============================================================================
255// seqan3::quality_alphabet
256// ============================================================================
257
258namespace seqan3
259{
260
291template <typename t>
292SEQAN3_CONCEPT quality_alphabet = alphabet<t> && requires(t qual)
293{
294 { seqan3::to_phred(qual) };
295};
297
298// ============================================================================
299// seqan3::writable_quality_alphabet
300// ============================================================================
301
331template <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:102
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
@ qual
The qualities, usually in Phred score notation.
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: cigar_operation_table.hpp:2
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition: concept.hpp:49