SeqAn3  3.0.3
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 Member Functions

Constructors, destructor and assignment
constexpr nucleotide_scoring_scheme () noexcept=default
 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...
 
- Public Member Functions inherited from seqan3::scoring_scheme_base< nucleotide_scoring_scheme< int8_t >, dna15, int8_t >
constexpr scoring_scheme_base (scoring_scheme_base const &) noexcept=default
 Defaulted.
 
constexpr scoring_scheme_base (scoring_scheme_base &&) noexcept=default
 Defaulted.
 
constexpr scoring_scheme_base () noexcept
 The default constructor (delegates to set_hamming_distance()).
 
constexpr scoring_scheme_base (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 scoring_scheme_base (matrix_type const &matrix) noexcept
 Constructor for a custom scheme (delegates to set_custom_matrix()). More...
 
constexpr scoring_scheme_baseoperator= (scoring_scheme_base const &) noexcept=default
 Defaulted.
 
constexpr scoring_scheme_baseoperator= (scoring_scheme_base &&) noexcept=default
 Defaulted.
 
 ~scoring_scheme_base () noexcept=default
 Defaulted.
 
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...
 
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...
 
constexpr bool operator== (nucleotide_scoring_scheme< int8_t > const &rhs) const noexcept
 Checks whether *this is equal to rhs.
 
constexpr bool operator!= (nucleotide_scoring_scheme< int8_t > const &rhs) const noexcept
 Checks whether *this is not equal to rhs.
 

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.
 

Additional Inherited Members

- Public Types inherited from seqan3::scoring_scheme_base< nucleotide_scoring_scheme< int8_t >, dna15, int8_t >
using score_type = score_t
 Type of the score values.
 
using alphabet_type = alphabet_t
 Type of the underlying alphabet.
 
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).
 
- Static Public Attributes inherited from seqan3::scoring_scheme_base< nucleotide_scoring_scheme< int8_t >, dna15, int8_t >
static constexpr matrix_size_type matrix_size
 Size of the matrix dimensions (i.e. size of the alphabet).
 

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

int main()
{
using namespace seqan3::literals;
// You can score two letters:
seqan3::nucleotide_scoring_scheme scheme; // hamming is default
seqan3::debug_stream << "Score between DNA5 A and G: " << (int) scheme.score('A'_dna5, 'G'_dna5) << "\n"; // == -1
seqan3::debug_stream << "Score between DNA5 A and A: " << (int) scheme.score('A'_dna5, 'A'_dna5) << "\n"; // == 0
// You can also score differenct nucleotides:
seqan3::debug_stream << "Score between DNA5 A and RNA15 G: " << (int) scheme.score('A'_dna5, 'G'_rna15) << "\n"; // == -2
seqan3::debug_stream << "Score between DNA5 A and RNA15 A: " << (int) scheme.score('A'_dna5, 'A'_rna15) << "\n"; // == 3
// You can "edit" a given matrix directly:
seqan3::nucleotide_scoring_scheme scheme2; // hamming distance is default
seqan3::debug_stream << "Score between DNA A and G before edit: "
<< (int) scheme2.score('A'_dna15, 'G'_dna15) << "\n"; // == -1
scheme2.score('A'_dna15, 'G'_dna15) = 3;
seqan3::debug_stream << "Score after editing: " << (int) scheme2.score('A'_dna15, 'G'_dna15) << "\n"; // == 3
// You can score two sequences:
std::vector<seqan3::dna15> one = "AGAATA"_dna15;
std::vector<seqan3::dna15> two = "ATACTA"_dna15;
seqan3::nucleotide_scoring_scheme scheme3; // hamming distance is default
int score = 0;
for (auto pair : seqan3::views::zip(one, two))
score += scheme3.score(std::get<0>(pair), std::get<1>(pair));
seqan3::debug_stream << "Score: " << score << "\n"; // == 0 - 1 + 0 - 1 + 0 + 0 = -2
}
A data structure for managing and computing the score of two nucleotides.
Definition: nucleotide_scoring_scheme.hpp:38
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).
Definition: scoring_scheme_base.hpp:178
constexpr score_t & score(alph1_t const alph1, alph2_t const alph2) noexcept
Score two letters (either two nucleotids or two amino acids).
Definition: scoring_scheme_base.hpp:219
Provides seqan3::debug_stream and related types.
Provides seqan3::dna5, container aliases and string literals.
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42
constexpr auto zip
A zip view.
Definition: zip.hpp:29
The SeqAn namespace for literals.
Provides seqan3::nucleotide_scoring_scheme.
Provides seqan3::rna15, container aliases and string literals.
A strong type of underlying type score_type that represents the score of two matching characters.
Definition: scoring_scheme_base.hpp:41
A strong type of underlying type score_type that represents the score two different characters.
Definition: scoring_scheme_base.hpp:66
Provides seqan3::views::zip.

Constructor & Destructor Documentation

◆ nucleotide_scoring_scheme() [1/3]

template<arithmetic score_type = int8_t>
constexpr seqan3::nucleotide_scoring_scheme< score_type >::nucleotide_scoring_scheme ( )
constexprdefaultnoexcept

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 
)
inlineconstexpr

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)
inlineconstexprnoexcept

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

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

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