SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
qualified.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2019, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2019, 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 
13 #pragma once
14 
15 #include <iostream>
16 #include <string>
17 #include <utility>
18 
21 
22 namespace seqan3
23 {
24 
58 template <WritableAlphabet sequence_alphabet_t, WritableQualityAlphabet quality_alphabet_t>
59 class qualified :
60  public alphabet_tuple_base<qualified<sequence_alphabet_t, quality_alphabet_t>,
61  sequence_alphabet_t, quality_alphabet_t>
62 {
63 private:
66  sequence_alphabet_t, quality_alphabet_t>;
67 
68 public:
70  using sequence_alphabet_type = sequence_alphabet_t;
72  using quality_alphabet_type = quality_alphabet_t;
73 
78 
82  constexpr qualified() noexcept = default;
83  constexpr qualified(qualified const &) noexcept = default;
84  constexpr qualified(qualified &&) noexcept = default;
85  constexpr qualified & operator =(qualified const &) noexcept = default;
86  constexpr qualified & operator =(qualified &&) noexcept = default;
87  ~qualified() noexcept = default;
88 
89  using base_type::base_type; // Inherit non-default constructors
90 
91  // Inherit operators from base
92  using base_type::operator=;
93  using base_type::operator==;
94  using base_type::operator!=;
95  using base_type::operator>=;
96  using base_type::operator<=;
97  using base_type::operator<;
98  using base_type::operator>;
99 
101  SEQAN3_DOXYGEN_ONLY(( constexpr qualified(component_type const alph) noexcept {} ))
103  SEQAN3_DOXYGEN_ONLY(( constexpr qualified(indirect_component_type const alph) noexcept {} ))
105  SEQAN3_DOXYGEN_ONLY(( constexpr qualified & operator=(component_type const alph) noexcept {} ))
107  SEQAN3_DOXYGEN_ONLY(( constexpr qualified & operator=(indirect_component_type const alph) noexcept {} ))
109 
113  constexpr qualified & assign_char(char_type const c) noexcept
115  {
116  seqan3::assign_char_to(c, get<0>(*this));
117  return *this;
118  }
119 
122  {
123  seqan3::assign_char_strictly_to(c, get<0>(*this));
124  return *this;
125  }
126 
128  constexpr qualified & assign_phred(phred_type const c) noexcept
129  {
130  seqan3::assign_phred_to(c, get<1>(*this));
131  return *this;
132  }
134 
138  constexpr phred_type to_phred() const noexcept
140  {
141  return seqan3::to_phred(get<1>(*this));
142  }
143 
145  constexpr char_type to_char() const noexcept
146  {
147  return seqan3::to_char(get<0>(*this));
148  }
149 
154  constexpr qualified complement() const noexcept
155  requires NucleotideAlphabet<sequence_alphabet_t>
156  {
157  using seqan3::complement;
158  return qualified{complement(get<0>(*this)), get<1>(*this)};
159  }
161 
163  static constexpr bool char_is_valid(char_type const c) noexcept
164  {
165  return char_is_valid_for<sequence_alphabet_type>(c);
166  }
167 };
168 
171 template <typename sequence_alphabet_type, typename quality_alphabet_type>
172 qualified(sequence_alphabet_type &&, quality_alphabet_type &&)
173  -> qualified<std::decay_t<sequence_alphabet_type>, std::decay_t<quality_alphabet_type>>;
174 
175 } // namespace seqan3
quality_alphabet_t quality_alphabet_type
Second template parameter as member type.
Definition: qualified.hpp:72
constexpr qualified(indirect_component_type const alph) noexcept
Construction via a value of a subtype that is assignable to one of the components.
Definition: qualified.hpp:103
constexpr auto complement
Return the complement of a nucleotide object.
Definition: concept.hpp:104
constexpr auto to_char
Return the char representation of an alphabet object.
Definition: concept.hpp:285
alphabet_phred_t< quality_alphabet_type > phred_type
Equals the phred_type of the quality_alphabet_type.
Definition: qualified.hpp:77
sequence_alphabet_t sequence_alphabet_type
First template parameter as member type.
Definition: qualified.hpp:70
constexpr auto assign_char_strictly_to
Assign a character to an alphabet object, throw if the character is not valid.
Definition: concept.hpp:577
constexpr qualified & assign_phred(phred_type const c) noexcept
Assign from a phred value. This modifies the internal quality letter.
Definition: qualified.hpp:128
The main SeqAn3 namespace.
alphabet_char_t< sequence_alphabet_type > char_type
Equals the char_type of sequence_alphabet_type.
Definition: qualified.hpp:75
Joins an arbitrary alphabet with a quality alphabet.
Definition: qualified.hpp:59
constexpr char_type to_char() const noexcept
Return a character. This reads the internal sequence letter.
Definition: qualified.hpp:145
constexpr qualified & assign_char(char_type const c) noexcept
Assign from a character. This modifies the internal sequence letter.
Definition: qualified.hpp:114
static constexpr bool char_is_valid(char_type const c) noexcept
Validate whether a character is valid in the sequence alphabet.
Definition: qualified.hpp:163
constexpr auto assign_phred_to
Assign a phred score to a quality alphabet object.
Definition: concept.hpp:201
The CRTP base for a combined alphabet that contains multiple values of different alphabets at the sam...
Definition: alphabet_tuple_base.hpp:188
Provides seqan3::NucleotideAlphabet.
constexpr phred_type to_phred() const noexcept
Return the phred value. This reads the internal quality letter.
Definition: qualified.hpp:139
decltype(seqan3::to_char(std::declval< alphabet_type const >())) alphabet_char_t
The char_type of the alphabet; defined as the return type of seqan3::to_char.
Definition: concept.hpp:294
constexpr auto to_phred
The public getter function for the phred representation of a quality score.
Definition: concept.hpp:104
A concept that indicates whether an alphabet represents nucleotides.
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 qualified() noexcept=default
Defaulted.
constexpr qualified complement() const noexcept requires NucleotideAlphabet< sequence_alphabet_t >
Return a qualified where the quality is preserved, but the sequence letter is complemented.
Definition: qualified.hpp:154
Provides seqan3::alphabet_tuple_base.
constexpr auto assign_char_to
Assign a character to an alphabet object.
Definition: concept.hpp:395
qualified & assign_char_strictly(char_type const c)
Strict assign from a character. This modifies the internal sequence letter.
Definition: qualified.hpp:121