SeqAn3  3.0.0
The Modern C++ library for sequence analysis.
seqan3::nucleotide_scoring_scheme< score_type > Class Template Reference

A data structure for managing and computing the score of two nucleotides. More...

#include <seqan3/alignment/scoring/nucleotide_scoring_scheme.hpp>

+ Inheritance diagram for seqan3::nucleotide_scoring_scheme< score_type >:

Public Types

Member types
using score_type = score_t
 Type of the score values.
 
using matrix_size_type = std::remove_const_t< decltype(alphabet_size< alphabet_t >)>
 Size type that can hold the dimension of the matrix (i.e. size of the alphabet).
 
using matrix_type = std::array< std::array< score_type, matrix_size >, matrix_size >
 Type of the internal matrix (a two-dimensional array).
 

Public Member Functions

Constructors, destructor and assignment
constexpr nucleotide_scoring_scheme () noexcept
 The default constructor (delegates to set_hamming_distance()). More...
 
template<Arithmetic score_arg_t>
constexpr nucleotide_scoring_scheme (match_score< score_arg_t > const ms, mismatch_score< score_arg_t > const mms)
 Constructor for the simple scheme (delegates to set_simple_scheme()). More...
 
constexpr nucleotide_scoring_scheme (matrix_type const &_matrix) noexcept
 Constructor for a custom scheme (delegates to set_custom_matrix()). More...
 
Scheme selection
constexpr void set_hamming_distance () noexcept
 Set the hamming scheme, a variant of the simple scheme where match is scored 0 and mismatch -1.
 
constexpr void set_simple_scheme (match_score< score_arg_t > const ms, mismatch_score< score_arg_t > const mms)
 Set the simple scheme (everything is either match or mismatch). More...
 
constexpr void set_custom_matrix (matrix_type const &_matrix) noexcept
 Set a custom scheme by passing a full matrix with arbitrary content. More...
 
Accessors
constexpr score_t & score (alph1_t const alph1, alph2_t const alph2) noexcept
 Score two letters (either two nucleotids or two amino acids). More...
 
constexpr score_t score (alph1_t const alph1, alph2_t const alph2) const noexcept
 Score two letters (either two nucleotids or two amino acids). More...
 
Comparison operators
constexpr bool operator== (nucleotide_scoring_scheme< score_type > const &rhs) const noexcept
 Checks whether *this is equal to rhs.
 
constexpr bool operator!= (nucleotide_scoring_scheme< score_type > const &rhs) const noexcept
 Checks whether *this is not equal to rhs.
 

Static Public Attributes

static constexpr matrix_size_type matrix_size
 Size of the matrix dimensions (i.e. size of the alphabet).
 

Related Functions

(Note that these are not member functions.)

Type deduction guides
 nucleotide_scoring_scheme () -> nucleotide_scoring_scheme< int8_t >
 Default constructed objects deduce to int8_t.
 
template<Arithmetic score_arg_type>
 nucleotide_scoring_scheme (match_score< score_arg_type >, mismatch_score< score_arg_type >) -> nucleotide_scoring_scheme< int8_t >
 Attention: This guide does not actually deduce from the underlying type, but always defaults to int8_t. To use a larger type, specify the template argument manually.
 
template<Arithmetic score_arg_type>
 nucleotide_scoring_scheme (std::array< std::array< score_arg_type, 15 >, 15 >) -> nucleotide_scoring_scheme< score_arg_type >
 Deduce the score type from the provided matrix.
 
Requirements for seqan3::ScoringScheme

You can expect these members on all types that implement seqan3::ScoringScheme.

typedef IMPLEMENTATION_DEFINED score_type
 The type returned by seqan3::ScoringScheme::score(), usually a seqan3::Arithmetic. More...
 
score_type score (alph1_t const alph1, alph2_t const alph2)
 Compute the score of two letters. More...
 

Detailed Description

template<Arithmetic score_type = int8_t>
class seqan3::nucleotide_scoring_scheme< score_type >

A data structure for managing and computing the score of two nucleotides.

Template Parameters
score_typeThe underlying type.

You can use an instance of this class to score two nucleotides, the nucleotides need not be of the same type. Different scoring behaviour can be set via the member functions.

Example

Score two letters:

nucleotide_scoring_scheme scheme; // hamming is default
debug_stream << "Score between DNA5 A and G: " << (int) scheme.score('A'_dna5, 'G'_dna5) << "\n"; // == -1
debug_stream << "Score between DNA5 A and A: " << (int) scheme.score('A'_dna5, 'A'_dna5) << "\n"; // == 0
scheme.set_simple_scheme(match_score{3}, mismatch_score{-2});
debug_stream << "Score between DNA5 A and RNA15 G: " << (int) scheme.score('A'_dna5, 'G'_rna15) << "\n"; // == -2
debug_stream << "Score between DNA5 A and RNA15 A: " << (int) scheme.score('A'_dna5, 'A'_rna15) << "\n"; // == 3
// you can score differenct nucleotides ^

You can "edit" a given matrix directly:

nucleotide_scoring_scheme scheme; // hamming distance is default
debug_stream << "Score between DNA A and G before edit: "
<< (int) scheme.score('A'_dna15, 'G'_dna15) << "\n"; // == -1
scheme.score('A'_dna15, 'G'_dna15) = 3;
debug_stream << "Score after editing: " << (int) scheme.score('A'_dna15, 'G'_dna15) << "\n"; // == 3

Score two sequences:

std::vector<dna15> one = "AGAATA"_dna15;
std::vector<dna15> two = "ATACTA"_dna15;
nucleotide_scoring_scheme scheme; // hamming distance is default
int score = 0;
for (auto pair : std::view::zip(one, two))
score += scheme.score(std::get<0>(pair), std::get<1>(pair));
debug_stream << "Score: " << score << "\n"; // == 0 - 1 + 0 - 1 + 0 + 0 = -2

Constructor & Destructor Documentation

◆ nucleotide_scoring_scheme() [1/3]

template<Arithmetic score_type = int8_t>
constexpr seqan3::nucleotide_scoring_scheme< score_type >::nucleotide_scoring_scheme ( )
inlinenoexcept

The default constructor (delegates to set_hamming_distance()).

◆ nucleotide_scoring_scheme() [2/3]

template<Arithmetic score_type = int8_t>
template<Arithmetic score_arg_t>
constexpr seqan3::nucleotide_scoring_scheme< score_type >::nucleotide_scoring_scheme ( match_score< score_arg_t > const  ms,
mismatch_score< score_arg_t > const  mms 
)
inline

Constructor for the simple scheme (delegates to set_simple_scheme()).

Template Parameters
score_arg_tThe underlying type of the arguments.
Parameters
[in]msMatches shall be given this value (of type seqan3::match_score).
[in]mmsMismatches shall be given this value (of type seqan3::mismatch_score).
Exceptions
std::invalid_argumentThrown if you pass a value that is to large/low to be represented by score_t.

◆ nucleotide_scoring_scheme() [3/3]

template<Arithmetic score_type = int8_t>
constexpr seqan3::nucleotide_scoring_scheme< score_type >::nucleotide_scoring_scheme ( matrix_type const &  _matrix)
inlinenoexcept

Constructor for a custom scheme (delegates to set_custom_matrix()).

Parameters
[in]_matrixA full matrix that is copied into the scheme.

Member Function Documentation

◆ score() [1/2]

constexpr score_t& seqan3::scoring_scheme_base< nucleotide_scoring_scheme< score_type > , alphabet_t, score_t >::score ( alph1_t const  alph1,
alph2_t const  alph2 
)
inlinenoexceptinherited

Score two letters (either two nucleotids or two amino acids).

Template Parameters
alph1_tType of the first letter.
alph2_tType of the second letter (needn't be the same as alph1_t).
Parameters
[in]alph1The first letter to score.
[in]alph2The second letter to score.
Returns
The score of the two letters in the current scheme.

◆ score() [2/2]

constexpr score_t seqan3::scoring_scheme_base< nucleotide_scoring_scheme< score_type > , alphabet_t, score_t >::score ( alph1_t const  alph1,
alph2_t const  alph2 
) const
inlinenoexceptinherited

Compute the score of two letters.

Parameters
alph1First letter.
alph2Second letter.
Attention
This is a concept requirement, not an actual function (however types satisfying this concept will provide an implementation).

◆ set_custom_matrix()

constexpr void seqan3::scoring_scheme_base< nucleotide_scoring_scheme< score_type > , alphabet_t, score_t >::set_custom_matrix ( matrix_type const &  _matrix)
inlinenoexceptinherited

Set a custom scheme by passing a full matrix with arbitrary content.

Parameters
[in]_matrixA full matrix that is copied into the scheme.

◆ set_simple_scheme()

constexpr void seqan3::scoring_scheme_base< nucleotide_scoring_scheme< score_type > , alphabet_t, score_t >::set_simple_scheme ( match_score< score_arg_t > const  ms,
mismatch_score< score_arg_t > const  mms 
)
inlineinherited

Set the simple scheme (everything is either match or mismatch).

Template Parameters
score_arg_tThe underlying type of the arguments.
Parameters
[in]msMatches shall be given this value (of type seqan3::match_score).
[in]mmsMismatches shall be given this value (of type seqan3::mismatch_score).
Exceptions
std::invalid_argumentThrown if you pass a value that is to large/low to be represented by score_t.

Friends And Related Function Documentation

◆ score()

score_type score ( alph1_t const  alph1,
alph2_t const  alph2 
)
related

Compute the score of two letters.

Parameters
alph1First letter.
alph2Second letter.
Attention
This is a concept requirement, not an actual function (however types satisfying this concept will provide an implementation).

◆ score_type()

typedef IMPLEMENTATION_DEFINED score_type
related

The type returned by seqan3::ScoringScheme::score(), usually a seqan3::Arithmetic.

Attention
This is a concept requirement, not an actual typedef (however types satisfying this concept will provide an implementation).

The documentation for this class was generated from the following file: