SeqAn3
concept.hpp
Go to the documentation of this file.
1 // ============================================================================
2 // SeqAn - The Library for Sequence Analysis
3 // ============================================================================
4 //
5 // Copyright (c) 2006-2018, Knut Reinert & Freie Universitaet Berlin
6 // Copyright (c) 2016-2018, Knut Reinert & MPI Molekulare Genetik
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // * Redistributions of source code must retain the above copyright
13 // notice, this list of conditions and the following disclaimer.
14 // * Redistributions in binary form must reproduce the above copyright
15 // notice, this list of conditions and the following disclaimer in the
16 // documentation and/or other materials provided with the distribution.
17 // * Neither the name of Knut Reinert or the FU Berlin nor the names of
18 // its contributors may be used to endorse or promote products derived
19 // from this software without specific prior written permission.
20 //
21 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 // ARE DISCLAIMED. IN NO EVENT SHALL KNUT REINERT OR THE FU BERLIN BE LIABLE
25 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
31 // DAMAGE.
32 //
33 // ============================================================================
34 
40 #pragma once
41 
42 #include <iostream>
43 #include <string>
44 
46 
47 namespace seqan3
48 {
49 
50 // ------------------------------------------------------------------
51 // Member exposure for the seqan3::quality_concept
52 // ------------------------------------------------------------------
53 
61 template <typename alphabet_type>
63 {};
64 
71 template <typename alphabet_with_member_type>
73  requires requires () { typename alphabet_with_member_type::phred_type; }
75 struct underlying_phred<alphabet_with_member_type>
76 {
78  using type = typename alphabet_with_member_type::phred_type;
79 };
80 
87 template <typename alphabet_type>
89 
98 template <typename alphabet_type>
100  requires requires (alphabet_type v) { { v.assign_phred('c') }; }
102 constexpr alphabet_type & assign_phred(alphabet_type & chr, char const in)
103 {
104  return chr.assign_phred(in);
105 }
106 
107 template <typename alphabet_type>
109  requires requires (alphabet_type v) { { v.assign_phred('c') }; }
111 constexpr alphabet_type assign_phred(alphabet_type && chr, char const in)
112 {
113  return chr.assign_phred(in);
114 }
115 
123 template <typename alphabet_type>
125  requires requires (alphabet_type v) { { v.to_phred() }; }
127 constexpr underlying_phred_t<alphabet_type> to_phred(alphabet_type const & chr)
128 {
129  return chr.to_phred();
130 }
131 //\}
132 
133 // ------------------------------------------------------------------
134 // seqan3::quality_concept
135 // ------------------------------------------------------------------
136 
151 template<typename q>
153 concept quality_concept = requires(q quality)
154 {
155  requires alphabet_concept<q>;
156 
157  { assign_phred(quality, typename q::rank_type{}) } -> q;
158  { to_phred(quality) } -> const typename q::phred_type;
159  typename underlying_phred<q>::type;
160 };
162 
163 } // namespace seqan
constexpr underlying_phred_t< alphabet_type > to_phred(alphabet_type const &chr)
The public getter function for the phred representation of a score.
Definition: concept.hpp:127
constexpr alphabet_type & assign_phred(alphabet_type &chr, char const in)
The public setter function of a phred score.
Definition: concept.hpp:102
The generic alphabet concept that covers most data types used in ranges.This is the core alphabet con...
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
typename underlying_phred< alphabet_type >::type underlying_phred_t
The internal phred type.
Definition: concept.hpp:88
A concept that indicates whether an alphabet represents quality scores.In addition to the requirement...
Definition: concept.hpp:62
Core alphabet concept and free function/metafunction wrappers.
typename alphabet_with_member_type::phred_type type
The underlying phred data type.
Definition: concept.hpp:78