BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
concept.hpp
Go to the documentation of this file.
1// -----------------------------------------------------------------------------------------------------
2// Copyright (c) 2022 deCODE Genetics
3// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin
4// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik
5// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License
6// shipped with this file and also available at: https://github.com/biocpp/biocpp-core/blob/main/LICENSE.md
7// -----------------------------------------------------------------------------------------------------
8
16#pragma once
17
19
20// ============================================================================
21// to_phred()
22// ============================================================================
23
24namespace bio::alphabet
25{
26
65inline constexpr auto to_phred = []<typename alph_t>(alph_t const a)
66 requires(requires {
67 {
68 tag_invoke(custom::to_phred{}, a)
69 } -> std::integral;
70 requires noexcept(tag_invoke(custom::to_phred{}, a));
71 })
72{
73 return tag_invoke(custom::to_phred{}, a);
74};
76
80template <typename alphabet_type>
81 requires(requires {
82 {
83 bio::alphabet::to_phred(std::declval<alphabet_type>())
84 };
85 })
86using phred_t = decltype(bio::alphabet::to_phred(std::declval<alphabet_type>()));
87
88// ============================================================================
89// assign_phred_to()
90// ============================================================================
91
128inline constexpr auto assign_phred_to =
129 []<typename alph_t>(bio::alphabet::phred_t<alph_t> const p, alph_t && a) -> alph_t
130 requires(requires {
131 {
132 tag_invoke(custom::assign_phred_to{}, p, a)
133 } -> std::same_as<alph_t &>;
134 requires noexcept(tag_invoke(custom::assign_phred_to{}, p, a));
135 })
136{
137 return tag_invoke(custom::assign_phred_to{}, p, a);
138};
140
141// ============================================================================
142// bio::alphabet::quality
143// ============================================================================
144
170template <typename t>
171concept quality = alphabet<t> && requires(t qual) {
172 {
174 };
175};
176
177// ============================================================================
178// bio::alphabet::writable_quality
179// ============================================================================
180
207template <typename t>
208concept writable_quality = writable_alphabet<t> && quality<t> && requires(t v, phred_t<t> c) {
209 {
211 };
212};
213
214} // namespace bio::alphabet
Core alphabet concept and free function/type trait wrappers.
The generic alphabet concept that covers most data types used in ranges.
Definition: concept.hpp:643
A concept that indicates whether an alphabet represents quality scores.
Definition: concept.hpp:171
Refines bio::alphabet::alphabet and adds assignability.
Definition: concept.hpp:688
A concept that indicates whether a writable alphabet represents quality scores.
Definition: concept.hpp:208
constexpr auto assign_phred_to
Assign a phred score to a quality alphabet object.
Definition: concept.hpp:128
decltype(bio::alphabet::to_phred(std::declval< alphabet_type >())) phred_t
The phred_type of the alphabet; defined as the return type of bio::alphabet::to_phred.
Definition: concept.hpp:86
constexpr auto to_phred
The public getter function for the phred representation of a quality score.
Definition: concept.hpp:65
The alphabet module's namespace.
Definition: aa10li.hpp:23
Customisation tag for bio::alphabet::assign_char_to.
Definition: tag.hpp:57
Customisation tag for bio::alphabet::assign_char_to.
Definition: tag.hpp:53