-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2290 from Irallia/feature/alphabet/add_phred94
[FEATURE] Alphabet: Add the quality alphabet seqan3::phred94
- Loading branch information
Showing
17 changed files
with
331 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
// ----------------------------------------------------------------------------------------------------- | ||
// Copyright (c) 2006-2020, Knut Reinert & Freie Universität Berlin | ||
// Copyright (c) 2016-2020, Knut Reinert & MPI für molekulare Genetik | ||
// This file may be used, modified and/or redistributed under the terms of the 3-clause BSD-License | ||
// shipped with this file and also available at: https://github.com/seqan/seqan3/blob/master/LICENSE.md | ||
// ----------------------------------------------------------------------------------------------------- | ||
|
||
/*!\file | ||
* \author Lydia Buntrock <lydia.buntrock AT fu-berlin.de> | ||
* \brief Provides seqan3::phred94 quality scores. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <seqan3/alphabet/quality/quality_base.hpp> | ||
|
||
namespace seqan3 | ||
{ | ||
|
||
/*!\brief Quality type for PacBio Phred scores of HiFi reads. | ||
* \implements seqan3::writable_quality_alphabet | ||
* \if DEV \implements seqan3::detail::writable_constexpr_alphabet \endif | ||
* \implements seqan3::trivially_copyable | ||
* \implements seqan3::standard_layout | ||
* \implements std::regular | ||
* | ||
* \ingroup quality | ||
* | ||
* \details | ||
* | ||
* The phred94 quality alphabet represents the zero-based phred score range [0..93] mapped to the ASCII range | ||
* ['!' .. '~'] (Sanger, Illumina 1.8+ format). It is typically used for HiFi reads produced by PacBio. For Sanger and | ||
* Illumina phred scores of raw reads the range is typically (0 to 41), represented as seqan3::phred42. If you expect | ||
* only slightly larger score types you can use seqan3::phred63 (0 to 62) which still has memory advantages when used | ||
* with seqan3::qualified. | ||
* | ||
* \include test/snippet/alphabet/quality/phred94.cpp | ||
* | ||
* You can find more information about the Phred scores in our \ref quality submodule \see quality submodule. | ||
*/ | ||
class phred94 : public quality_base<phred94, 94> | ||
{ | ||
private: | ||
//!\brief The base class. | ||
using base_t = quality_base<phred94, 94>; | ||
|
||
//!\brief Befriend seqan3::quality_base. | ||
friend base_t; | ||
//!\cond \brief Befriend seqan3::alphabet_base. | ||
friend base_t::base_t; | ||
//!\endcond | ||
|
||
public: | ||
/*!\name Constructors, destructor and assignment | ||
* \{ | ||
*/ | ||
constexpr phred94() noexcept = default; //!< Defaulted. | ||
constexpr phred94(phred94 const &) noexcept = default; //!< Defaulted. | ||
constexpr phred94(phred94 &&) noexcept = default; //!< Defaulted. | ||
constexpr phred94 & operator=(phred94 const &) noexcept = default; //!< Defaulted. | ||
constexpr phred94 & operator=(phred94 &&) noexcept = default; //!< Defaulted. | ||
~phred94() noexcept = default; //!< Defaulted. | ||
|
||
//!\brief Construct from phred value. | ||
constexpr phred94(phred_type const p) : base_t{p} {} | ||
|
||
// Inherit converting constructor | ||
using base_t::base_t; | ||
//!\} | ||
|
||
/*!\name Member variables. | ||
* \{ | ||
*/ | ||
//!\brief The projection offset between phred and rank score representation. | ||
static constexpr phred_type offset_phred{0}; | ||
|
||
//!\brief The projection offset between char and rank score representation. | ||
static constexpr char_type offset_char{'!'}; | ||
//!\} | ||
}; | ||
|
||
/*!\name Literals | ||
* \{ | ||
*/ | ||
/*!\brief The seqan3::phred94 char literal. | ||
* \relates seqan3::phred94 | ||
* \returns seqan3::phred94 | ||
*/ | ||
constexpr phred94 operator""_phred94(char const c) noexcept | ||
{ | ||
return phred94{}.assign_char(c); | ||
} | ||
|
||
/*!\brief The seqan3::phred94 string literal. | ||
* \param[in] s A pointer to the character sequence to assign from. | ||
* \param[in] n The length of the character sequence to assign from. | ||
* \relates seqan3::phred94 | ||
* \returns seqan3::std::vector<seqan3::phred94> | ||
* | ||
* You can use this string literal to easily assign to std::vector<seqan3::phred94>: | ||
* | ||
* \include test/snippet/alphabet/quality/phred94_literal.cpp | ||
*/ | ||
inline std::vector<phred94> operator""_phred94(char const * s, std::size_t n) | ||
{ | ||
std::vector<phred94> r; | ||
r.resize(n); | ||
|
||
for (size_t i = 0; i < n; ++i) | ||
r[i].assign_char(s[i]); | ||
|
||
return r; | ||
} | ||
//!\} | ||
|
||
} // namespace seqan3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <seqan3/alphabet/quality/phred94.hpp> | ||
#include <seqan3/core/debug_stream.hpp> | ||
|
||
int main() | ||
{ | ||
seqan3::phred94 phred; | ||
phred.assign_rank(2); // wrapper for assign_phred(2) | ||
seqan3::debug_stream << phred.to_phred() << "\n"; // 2 | ||
seqan3::debug_stream << phred.to_char() << "\n"; // '#' | ||
seqan3::debug_stream << phred.to_rank() << "\n"; // 2 | ||
|
||
seqan3::phred94 another_phred{75}; | ||
seqan3::debug_stream << another_phred.to_phred() << "\n"; // 75 | ||
|
||
seqan3::phred94 a_third_phred; | ||
another_phred.assign_phred(105); // converted down to 93 | ||
seqan3::debug_stream << another_phred.to_phred() << "\n"; // 93 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <seqan3/std/algorithm> | ||
|
||
#include <seqan3/alphabet/quality/phred94.hpp> | ||
#include <seqan3/core/debug_stream.hpp> | ||
|
||
int main() | ||
{ | ||
using seqan3::operator""_phred94; | ||
|
||
// directly assign to a std::vector<phred94> using a string literal | ||
std::vector<seqan3::phred94> qual_vec = "###!"_phred94; | ||
|
||
// This is the same as a sequence of char literals: | ||
std::vector<seqan3::phred94> qual_vec2 = {'#'_phred94, '#'_phred94, '#'_phred94, '!'_phred94}; | ||
|
||
seqan3::debug_stream << std::ranges::equal(qual_vec, qual_vec2) << '\n'; // prints 1 (true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.