SeqAn3
qualified.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 #include <utility>
45 
48 
49 namespace seqan3
50 {
51 
84 template <alphabet_concept sequence_alphabet_t, quality_concept quality_alphabet_t>
85 class qualified :
86  public cartesian_composition<qualified<sequence_alphabet_t, quality_alphabet_t>,
87  sequence_alphabet_t, quality_alphabet_t>
88 {
89 private:
92  sequence_alphabet_t, quality_alphabet_t>;
93 
94 public:
96  using sequence_alphabet_type = sequence_alphabet_t;
98  using quality_alphabet_type = quality_alphabet_t;
99 
104 
108  constexpr qualified() = default;
109  constexpr qualified(qualified const &) = default;
110  constexpr qualified(qualified &&) = default;
111  constexpr qualified & operator =(qualified const &) = default;
112  constexpr qualified & operator =(qualified &&) = default;
113  ~qualified() = default;
114 
115  using base_type::base_type; // Inherit non-default constructors
116 
117  // Inherit operators from base
118  using base_type::operator=;
119  using base_type::operator==;
120  using base_type::operator!=;
121  using base_type::operator>=;
122  using base_type::operator<=;
123  using base_type::operator<;
124  using base_type::operator>;
125 
127  SEQAN3_DOXYGEN_ONLY(( constexpr qualified(component_type const alph) {} ))
129  SEQAN3_DOXYGEN_ONLY(( constexpr qualified(indirect_component_type const alph) {} ))
131  SEQAN3_DOXYGEN_ONLY(( constexpr qualified & operator=(component_type const alph) {} ))
133  SEQAN3_DOXYGEN_ONLY(( constexpr qualified & operator=(indirect_component_type const alph) {} ))
135 
139  constexpr qualified & assign_char(char_type const c)
141  {
142  seqan3::assign_char(get<0>(*this), c);
143  return *this;
144  }
145 
147  constexpr qualified & assign_phred(phred_type const c)
148  {
149  seqan3::assign_phred(get<1>(*this), c);
150  return *this;
151  }
153 
157  constexpr phred_type to_phred() const noexcept
159  {
160  return seqan3::to_phred(get<1>(*this));
161  }
162 
164  constexpr char_type to_char() const noexcept
165  {
166  return seqan3::to_char(get<0>(*this));
167  }
168 
173  constexpr qualified complement() const noexcept
174  requires nucleotide_concept<sequence_alphabet_t>
175  {
176  using seqan3::complement;
177  return qualified{complement(get<0>(*this)), get<1>(*this)};
178  }
180 };
181 
184 template <typename sequence_alphabet_type, typename quality_alphabet_type>
186  -> qualified<std::decay_t<sequence_alphabet_type>, std::decay_t<quality_alphabet_type>>;
187 
188 } // namespace seqan3
char_t char_type
The type of the alphabet when converted to char (e.g. via to_char()).
Definition: alphabet_base.hpp:87
quality_alphabet_t quality_alphabet_type
Second template parameter as member type.
Definition: qualified.hpp:98
constexpr qualified complement() const noexcept requires nucleotide_concept< sequence_alphabet_t >
Return a qualified where the quality is preserved, but the sequence letter is complemented.
Definition: qualified.hpp:173
constexpr nucleotide_type complement(nucleotide_type const alph) requires requires(nucleotide_type alph)
Implementation of seqan3::nucleotide_concept::complement() that delegates to a member function...
Definition: member_exposure.hpp:220
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition: cartesian_composition.hpp:209
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: qualified.hpp:96
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 main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:58
Joins an arbitrary alphabet with a quality alphabet.
Definition: qualified.hpp:85
constexpr char_type to_char() const noexcept
Return a character. This reads the internal sequence letter.
Definition: qualified.hpp:164
constexpr qualified & assign_phred(phred_type const c)
Assign from a phred value. This modifies the internal quality letter.
Definition: qualified.hpp:147
typename underlying_phred< alphabet_type >::type underlying_phred_t
The internal phred type.
Definition: concept.hpp:88
Provides seqan3::nucleotide_concept.
constexpr qualified(component_type const alph)
Construction via a value of one of the components.
Definition: qualified.hpp:127
constexpr phred_type to_phred() const noexcept
Return the phred value. This reads the internal quality letter.
Definition: qualified.hpp:158
Provides seqan3::cartesian_composition.
underlying_phred_t< quality_alphabet_type > phred_type
Equals the phred_type of the quality_alphabet_type.
Definition: qualified.hpp:103
constexpr alphabet_type & assign_char(alphabet_type &alph, underlying_char_t< alphabet_type > const chr) requires requires(alphabet_type alph)
Implementation of seqan3::alphabet_concept::assign_char() that delegates to a member function...
Definition: member_exposure.hpp:178
constexpr qualified & assign_char(char_type const c)
Assign from a character. This modifies the internal sequence letter.
Definition: qualified.hpp:140
typename underlying_char< alphabet_type >::type underlying_char_t
The char_type of the alphabet. [type metafunction shortcut].
Definition: concept_pre.hpp:172
constexpr underlying_char_t< alphabet_type > to_char(alphabet_type const alph) requires requires(alphabet_type alph)
Implementation of seqan3::alphabet_concept::to_char() that delegates to a member function.
Definition: member_exposure.hpp:165
A concept that indicates whether an alphabet represents nucleotides.In addition to the requirements f...