BioC++ core-0.7.0
The Modern C++ libraries for Bioinformatics.
 
Loading...
Searching...
No Matches
phred42.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
14#pragma once
15
17
18// ------------------------------------------------------------------
19// phred42
20// ------------------------------------------------------------------
21
22namespace bio::alphabet
23{
24
44class phred42 : public quality_base<phred42, 42>
45{
46private:
49
51 friend base_t;
53 friend base_t::base_t;
55
56public:
60 constexpr phred42() noexcept = default;
61 constexpr phred42(phred42 const &) noexcept = default;
62 constexpr phred42(phred42 &&) noexcept = default;
63 constexpr phred42 & operator=(phred42 const &) noexcept = default;
64 constexpr phred42 & operator=(phred42 &&) noexcept = default;
65 ~phred42() noexcept = default;
66
68 constexpr phred42(phred_type const p) : base_t{p} {}
69
70 // Inherit converting constructor
71 using base_t::base_t;
73
78 static constexpr phred_type offset_phred{0};
79
81 static constexpr char_type offset_char{'!'};
83};
84
85} // namespace bio::alphabet
86
87// ------------------------------------------------------------------
88// literals
89// ------------------------------------------------------------------
90
91namespace bio::alphabet
92{
93
94inline namespace literals
95{
96
105consteval phred42 operator""_phred42(char const c)
106{
107 if (!char_is_valid_for<phred42>(c))
108 throw std::invalid_argument{"Illegal character in character literal."};
109
110 return phred42{}.assign_char(c);
111}
112
122template <meta::detail::literal_buffer_string str>
123constexpr std::vector<phred42> operator""_phred42()
124{
125 return detail::string_literal<str, phred42>();
126}
128
129} // namespace literals
130
131} // namespace bio::alphabet
constexpr derived_type & assign_char(char_type const c) noexcept
Assign from a character, implicitly converts invalid characters.
Definition: base.hpp:145
Quality type for traditional Sanger and modern Illumina Phred scores (typical range)....
Definition: phred42.hpp:45
static constexpr char_type offset_char
The projection offset between char and rank score representation.
Definition: phred42.hpp:81
constexpr phred42() noexcept=default
Defaulted.
static constexpr phred_type offset_phred
The projection offset between phred and rank score representation.
Definition: phred42.hpp:78
A CRTP-base that refines bio::alphabet::base and is used by the quality alphabets.
Definition: quality_base.hpp:30
int8_t phred_type
The integer representation of a quality score assignable with =operator.
Definition: quality_base.hpp:36
The alphabet module's namespace.
Definition: aa10li.hpp:23
Provides bio::alphabet::phred42 quality scores.