SeqAn3 3.4.0-rc.1
The Modern C++ library for sequence analysis.
Loading...
Searching...
No Matches
alphabet/quality/concept.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2006-2024 Knut Reinert & Freie Universität Berlin
2// SPDX-FileCopyrightText: 2016-2024 Knut Reinert & MPI für molekulare Genetik
3// SPDX-License-Identifier: BSD-3-Clause
4
11#pragma once
12
14
15// ============================================================================
16// to_phred()
17// ============================================================================
18
19namespace seqan3::detail::adl_only
20{
21
23template <typename... args_t>
24void to_phred(args_t...) = delete;
25
28struct to_phred_cpo : public detail::customisation_point_object<to_phred_cpo, 2>
29{
31 using base_t = detail::customisation_point_object<to_phred_cpo, 2>;
33 using base_t::base_t;
34
39 template <typename alphabet_t>
40 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<2>, alphabet_t && alphabet)(
41 /*return*/ seqan3::custom::alphabet<alphabet_t>::to_phred(std::forward<alphabet_t>(alphabet)) /*;*/
42 );
43
48 template <typename alphabet_t>
49 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
50 /*return*/ to_phred(std::forward<alphabet_t>(alphabet)) /*;*/
51 );
52
57 template <typename alphabet_t>
58 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
59 /*return*/ std::forward<alphabet_t>(alphabet).to_phred() /*;*/
60 );
61};
62
63} // namespace seqan3::detail::adl_only
64
65namespace seqan3
66{
67
103inline constexpr auto to_phred = detail::adl_only::to_phred_cpo{};
105
111template <typename alphabet_type>
112 requires requires {
113 { seqan3::to_phred(std::declval<alphabet_type>()) };
114 }
115using alphabet_phred_t = decltype(seqan3::to_phred(std::declval<alphabet_type>()));
116
117} // namespace seqan3
118
119// ============================================================================
120// assign_phred_to()
121// ============================================================================
122
123namespace seqan3::detail::adl_only
124{
125
127template <typename... args_t>
128void assign_phred_to(args_t...) = delete;
129
132struct assign_phred_to_cpo : public detail::customisation_point_object<assign_phred_to_cpo, 2>
133{
135 using base_t = detail::customisation_point_object<assign_phred_to_cpo, 2>;
137 using base_t::base_t;
138
152 template <typename alphabet_t>
153 static constexpr auto
154 SEQAN3_CPO_OVERLOAD(priority_tag<2>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
155 /*return*/ static_cast<alphabet_t>(seqan3::custom::alphabet<alphabet_t>::assign_phred_to(phred, alphabet)) /*;*/
156 );
157
172 template <typename alphabet_t>
173 static constexpr auto
174 SEQAN3_CPO_OVERLOAD(priority_tag<1>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
175 /*return*/ static_cast<alphabet_t>(assign_phred_to(phred, alphabet)) /*;*/
176 );
177
188 template <typename alphabet_t>
189 static constexpr auto
190 SEQAN3_CPO_OVERLOAD(priority_tag<0>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
191 /*return*/ static_cast<alphabet_t>(alphabet.assign_phred(phred)) /*;*/
192 );
193};
194
195} // namespace seqan3::detail::adl_only
196
197namespace seqan3
198{
199
237inline constexpr auto assign_phred_to = detail::adl_only::assign_phred_to_cpo{};
239
240} // namespace seqan3
241
242// ============================================================================
243// seqan3::quality_alphabet
244// ============================================================================
245
246namespace seqan3
247{
248
279template <typename t>
280concept quality_alphabet = alphabet<t> && requires (t qual) {
282};
284
285// ============================================================================
286// seqan3::writable_quality_alphabet
287// ============================================================================
288
318template <typename t>
320 writable_alphabet<t> && quality_alphabet<t> && requires (t v, alphabet_phred_t<t> c) {
321 { seqan3::assign_phred_to(c, v) };
322 };
324
325} // namespace seqan3
Core alphabet concept and free function/type trait wrappers.
A "pretty printer" for most SeqAn data structures and related types.
Definition debug_stream_type.hpp:79
#define SEQAN3_CPO_OVERLOAD(...)
A macro that helps to define a seqan3::detail::customisation_point_object.
Definition customisation_point.hpp:104
constexpr auto to_phred
The public getter function for the Phred representation of a quality score.
Definition alphabet/quality/concept.hpp:97
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 alphabet/quality/concept.hpp:109
constexpr auto assign_phred_to
Assign a Phred score to a quality alphabet object.
Definition alphabet/quality/concept.hpp:225
@ 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 aligned_sequence_concept.hpp:26
A type that can be specialised to provide customisation point implementations so that third party typ...
Definition alphabet/concept.hpp:46
Hide me