SeqAn3  3.0.3
The Modern C++ library for sequence analysis.
phred42.hpp
Go to the documentation of this file.
1 // -----------------------------------------------------------------------------------------------------
2 // Copyright (c) 2006-2021, Knut Reinert & Freie Universität Berlin
3 // Copyright (c) 2016-2021, 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 
16 
17 namespace seqan3
18 {
19 
46 class phred42 : public phred_base<phred42, 42>
47 {
48 private:
51 
53  friend base_t;
55  friend base_t::base_t;
57 
58 public:
62  constexpr phred42() noexcept = default;
63  constexpr phred42(phred42 const &) noexcept = default;
64  constexpr phred42(phred42 &&) noexcept = default;
65  constexpr phred42 & operator=(phred42 const &) noexcept = default;
66  constexpr phred42 & operator=(phred42 &&) noexcept = default;
67  ~phred42() noexcept = default;
68 
69 #ifdef SEQAN3_DEPRECATED_310
75  {
76  assign_phred(p);
77  }
78 #endif // SEQAN3_DEPRECATED_310
79 
80  // Inherit converting constructor
81  using base_t::base_t;
83 
91  static constexpr phred_type offset_phred{0};
92 
97  static constexpr char_type offset_char{'!'};
99 };
100 
101 inline namespace literals
102 {
103 
117 constexpr phred42 operator""_phred42(char const c) noexcept
118 {
119  return phred42{}.assign_char(c);
120 }
121 
133 inline std::vector<phred42> operator""_phred42(char const * s, std::size_t n)
134 {
136  r.resize(n);
137 
138  for (size_t i = 0; i < n; ++i)
139  r[i].assign_char(s[i]);
140 
141  return r;
142 }
144 
145 } // inline namespace literals
146 
147 } // namespace seqan3
A CRTP-base that makes defining a custom alphabet easier.
Definition: alphabet_base.hpp:81
constexpr derived_type & assign_char(char_type const chr) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: alphabet_base.hpp:211
Quality type for traditional Sanger and modern Illumina Phred scores.
Definition: phred42.hpp:47
constexpr phred42() noexcept=default
Defaulted.
static constexpr phred_type offset_phred
The projection offset between Phred and rank score representation.
Definition: phred42.hpp:91
constexpr phred42(phred_type const p)
Allow construction from the Phred score value.
Definition: phred42.hpp:74
static constexpr char_type offset_char
The projection offset between char and rank score representation.
Definition: phred42.hpp:97
A CRTP-base that refines seqan3::alphabet_base and is used by the quality alphabets.
Definition: phred_base.hpp:31
constexpr phred42 & assign_phred(phred_type const p) noexcept
Assign from the numeric Phred score value.
Definition: phred_base.hpp:137
int8_t phred_type
The integer representation of the quality score.
Definition: phred_base.hpp:40
The main SeqAn3 namespace.
Definition: aligned_sequence_concept.hpp:29
Provides seqan3::phred42 quality scores.
#define SEQAN3_DEPRECATED_310
Deprecation message for SeqAn 3.1.0 release.
Definition: platform.hpp:203
T resize(T... args)