SeqAn3  3.0.1
The Modern C++ library for sequence analysis.
Quality

Provides the various quality score types. More...

+ Collaboration diagram for Quality:

Classes

class  seqan3::phred42
 Quality type for traditional Sanger and modern Illumina Phred scores (typical range). More...
 
class  seqan3::phred63
 Quality type for traditional Sanger and modern Illumina Phred scores (full range). More...
 
class  seqan3::phred68legacy
 Quality type for Solexa and deprecated Illumina formats. More...
 
class  seqan3::qualified< sequence_alphabet_t, quality_alphabet_t >
 Joins an arbitrary alphabet with a quality alphabet. More...
 
interface  quality_alphabet
 A concept that indicates whether an alphabet represents quality scores. More...
 
class  seqan3::quality_base< derived_type, size >
 A CRTP-base that refines seqan3::alphabet_base and is used by the quality alphabets. More...
 
interface  writable_quality_alphabet
 A concept that indicates whether a writable alphabet represents quality scores. More...
 

Typedefs

template<typename alphabet_type >
using seqan3::alphabet_phred_t = decltype(seqan3::to_phred(std::declval< alphabet_type >()))
 The phred_type of the alphabet; defined as the return type of seqan3::to_phred.
 

Function objects (Quality)

constexpr auto seqan3::to_phred = detail::adl_only::to_phred_fn{}
 The public getter function for the phred representation of a quality score. More...
 
constexpr auto seqan3::assign_phred_to = detail::adl_only::assign_phred_to_fn{}
 Assign a phred score to a quality alphabet object. More...
 

Detailed Description

Provides the various quality score types.

Introduction

Quality score sequences are usually output together with the DNA (or RNA) sequence by sequencing machines like the Illumina Genome Analyzer. The quality score of a nucleotide is also known as Phred score and is an integer score being inversely proportional to the propability $p$ that a base call is incorrect. Which roughly means that the higher a Phred score is, the higher is the probabality that the corresponding nucleotide is correct for that position. There exists two common variants of its computation:

Encoding Schemes

Format Quality Type Phred Score Range Rank Range ASCII Range Assert
Sanger, Illumina 1.8+ short seqan3::phred42 [0 .. 41] [0 .. 41] ['!' .. 'J'] Phred score in [0 .. 61]
Sanger, Illumina 1.8+ long seqan3::phred63 [0 .. 62] [0 .. 62] ['!' .. '_'] Phred score in [0 .. 62]
Solexa, Illumina [1.0; 1.8[ seqan3::phred68legacy [-5 .. 62] [0 .. 67] [';' .. '~'] Phred score in [-5 .. 62]

The most distributed format is the Sanger or Illumina 1.8+ format. Despite typical Phred scores for Illumina machines range from 0 to maximal 41, it is possible that processed reads reach higher scores. If you don't intend to handle Phred scores larger than 41, we recommend to use seqan3::phred42 due to its more space efficient implementation. For other formats, like Solexa and Illumina 1.0 to 1.7 the type seqan3::phred68legacy is provided. To cover also the Solexa format, the Phred score is stored as a signed integer starting at -5. An overview of all the score formats and their encodings can be found here: https://en.wikipedia.org/wiki/FASTQ_format#Encoding.

Concept

The quality submodule defines the seqan3::writable_quality_alphabet which encompasses all the alphabets, defined in the submodule, and refines the seqan3::writable_alphabet by providing Phred score assignment and conversion operations. Additionally, this submodule defines the seqan3::quality_alphabet, which only requires readablity and not assignability.

Assignment and Conversion

Quality alphabets can be converted to their char and rank representation via seqan3::to_char and seqan3::to_rank respectively (like all other alphabets). Additionally they can be converted to their Phred representation via seqan3::to_phred.

Likewise, assignment happens via seqan3::assign_char_to, seqan3::assign_rank_to and seqan3::assign_phred_to. Phred values outside the representable range, but inside the legal range, are converted to the closest Phred score, e.g. assigning 60 to a seqan3::phred42 will result in a Phred score of 41. Assigning Phred values outside the legal range results in undefined behaviour.

All quality alphabets are explicitly convertible to each other via their Phred representation. Values not present in one alphabet are mapped to the closest value in the target alphabet (e.g. a seqan3::phred63 letter with value 60 will convert to a seqan3::phred42 letter of score 41).

Variable Documentation

◆ assign_phred_to

constexpr auto seqan3::assign_phred_to = detail::adl_only::assign_phred_to_fn{}
inlineconstexpr

Assign a phred score to a quality alphabet object.

Template Parameters
your_typeThe type of the target object. Must model the seqan3::quality_alphabet.
Parameters
chrThe phred score being assigned; must be of the seqan3::alphabet_phred_t of the target object.
Returns
Reference to alph if alph was given as lvalue, otherwise a copy.

This is a function object. Invoke it with the parameter(s) specified above.

It acts as a wrapper and looks for three possible implementations (in this order):

  1. A static member function assign_phred_to(phred_type const chr, your_type & a) of the class seqan3::custom::alphabet<your_type>.
  2. A free function assign_phred_to(phred_type const chr, your_type & a) in the namespace of your type (or as friend).
  3. A member function called assign_phred(phred_type const chr) (not assign_phred_to).

Functions are only considered for one of the above cases if they are marked noexcept (constexpr is not required, but recommended) and if the returned type is your_type &.

Every writable quality alphabet type must provide one of the above. Note that temporaries of your_type are handled by this function object and do not require an additional overload.

Customisation point

This is a customisation point (see Customisation). To specify the behaviour for your own alphabet type, simply provide one of the three functions specified above.

◆ to_phred

constexpr auto seqan3::to_phred = detail::adl_only::to_phred_fn{}
inlineconstexpr

The public getter function for the phred representation of a quality score.

Template Parameters
your_typeThe type of alphabet. Must model the seqan3::quality_alphabet.
Parameters
chrThe quality value to convert into the phred score.
Returns
the phred representation of a quality score.

This is a function object. Invoke it with the parameter(s) specified above.

It acts as a wrapper and looks for three possible implementations (in this order):

  1. A static member function to_phred(your_type const a) of the class seqan3::custom::alphabet<your_type>.
  2. A free function to_phred(your_type const a) in the namespace of your type (or as friend).
  3. A member function called to_phred().

Functions are only considered for one of the above cases if they are marked noexcept (constexpr is not required, but recommended) and if the returned type is convertible to size_t.

Every quality alphabet type must provide one of the above.

Customisation point

This is a customisation point (see Customisation). To specify the behaviour for your own alphabet type, simply provide one of the three functions specified above.