SeqAn3 3.2.0
The Modern C++ library for sequence analysis.
concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2006-2022, Knut Reinert & Freie Universität Berlin
3// Copyright (c) 2016-2022, 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 /*return*/ seqan3::custom::alphabet<alphabet_t>::to_phred(std::forward<alphabet_t>(alphabet)) /*;*/
45 );
46
51 template <typename alphabet_t>
52 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<1>, alphabet_t && alphabet)(
53 /*return*/ to_phred(std::forward<alphabet_t>(alphabet)) /*;*/
54 );
55
60 template <typename alphabet_t>
61 static constexpr auto SEQAN3_CPO_OVERLOAD(priority_tag<0>, alphabet_t && alphabet)(
62 /*return*/ std::forward<alphabet_t>(alphabet).to_phred() /*;*/
63 );
64};
65
66} // namespace seqan3::detail::adl_only
67
68namespace seqan3
69{
70
106inline constexpr auto to_phred = detail::adl_only::to_phred_cpo{};
108
114template <typename alphabet_type>
115 requires requires {
116 {
117 seqan3::to_phred(std::declval<alphabet_type>())
118 };
119 }
120using alphabet_phred_t = decltype(seqan3::to_phred(std::declval<alphabet_type>()));
121
122} // namespace seqan3
123
124// ============================================================================
125// assign_phred_to()
126// ============================================================================
127
128namespace seqan3::detail::adl_only
129{
130
132template <typename... args_t>
133void assign_phred_to(args_t...) = delete;
134
137struct assign_phred_to_cpo : public detail::customisation_point_object<assign_phred_to_cpo, 2>
138{
140 using base_t = detail::customisation_point_object<assign_phred_to_cpo, 2>;
142 using base_t::base_t;
143
157 template <typename alphabet_t>
158 static constexpr auto
159 SEQAN3_CPO_OVERLOAD(priority_tag<2>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
160 /*return*/ static_cast<alphabet_t>(seqan3::custom::alphabet<alphabet_t>::assign_phred_to(phred, alphabet)) /*;*/
161 );
162
177 template <typename alphabet_t>
178 static constexpr auto
179 SEQAN3_CPO_OVERLOAD(priority_tag<1>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
180 /*return*/ static_cast<alphabet_t>(assign_phred_to(phred, alphabet)) /*;*/
181 );
182
193 template <typename alphabet_t>
194 static constexpr auto
195 SEQAN3_CPO_OVERLOAD(priority_tag<0>, seqan3::alphabet_phred_t<alphabet_t> const phred, alphabet_t && alphabet)(
196 /*return*/ static_cast<alphabet_t>(alphabet.assign_phred(phred)) /*;*/
197 );
198};
199
200} // namespace seqan3::detail::adl_only
201
202namespace seqan3
203{
204
242inline constexpr auto assign_phred_to = detail::adl_only::assign_phred_to_cpo{};
244
245} // namespace seqan3
246
247// ============================================================================
248// seqan3::quality_alphabet
249// ============================================================================
250
251namespace seqan3
252{
253
284template <typename t>
285concept quality_alphabet = alphabet<t> && requires (t qual) {
286 {
287 seqan3::to_phred(qual)
288 };
289 };
291
292// ============================================================================
293// seqan3::writable_quality_alphabet
294// ============================================================================
295
325template <typename t>
327 writable_alphabet<t> && quality_alphabet<t> && requires (t v, alphabet_phred_t<t> c) {
328 {
330 };
331 };
333
334} // 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:107
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:114
constexpr auto assign_phred_to
Assign a Phred score to a quality alphabet object.
Definition: concept.hpp:230
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