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 {
114 seqan3::to_phred(std::declval<alphabet_type>())
115 };
116 }
117using alphabet_phred_t = decltype(seqan3::to_phred(std::declval<alphabet_type>()));
118
119} // namespace seqan3
120
121// ============================================================================
122// assign_phred_to()
123// ============================================================================
124
125namespace seqan3::detail::adl_only
126{
127
129template <typename... args_t>
130void assign_phred_to(args_t...) = delete;
131
134struct assign_phred_to_cpo : public detail::customisation_point_object<assign_phred_to_cpo, 2>
135{
137 using base_t = detail::customisation_point_object<assign_phred_to_cpo, 2>;
139 using base_t::base_t;
140
154 template <typename alphabet_t>
155 static constexpr auto
156 SEQAN3_CPO_OVERLOAD(priority_tag<2>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
157 /*return*/ static_cast<alphabet_t>(seqan3::custom::alphabet<alphabet_t>::assign_phred_to(phred, alphabet)) /*;*/
158 );
159
174 template <typename alphabet_t>
175 static constexpr auto
176 SEQAN3_CPO_OVERLOAD(priority_tag<1>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
177 /*return*/ static_cast<alphabet_t>(assign_phred_to(phred, alphabet)) /*;*/
178 );
179
190 template <typename alphabet_t>
191 static constexpr auto
192 SEQAN3_CPO_OVERLOAD(priority_tag<0>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
193 /*return*/ static_cast<alphabet_t>(alphabet.assign_phred(phred)) /*;*/
194 );
195};
196
197} // namespace seqan3::detail::adl_only
198
199namespace seqan3
200{
201
239inline constexpr auto assign_phred_to = detail::adl_only::assign_phred_to_cpo{};
241
242} // namespace seqan3
243
244// ============================================================================
245// seqan3::quality_alphabet
246// ============================================================================
247
248namespace seqan3
249{
250
281template <typename t>
282concept quality_alphabet = alphabet<t> && requires (t qual) {
283 {
285 };
286 };
288
289// ============================================================================
290// seqan3::writable_quality_alphabet
291// ============================================================================
292
322template <typename t>
324 writable_alphabet<t> && quality_alphabet<t> && requires (t v, alphabet_phred_t<t> c) {
325 {
327 };
328 };
330
331} // 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: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:111
constexpr auto assign_phred_to
Assign a Phred score to a quality alphabet object.
Definition alphabet/quality/concept.hpp:227
@ 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