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

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

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

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

Public Types

Member types
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).
 

Public Member Functions

Constructors, destructor and assignment
constexpr aminoacid_scoring_scheme () noexcept=default
 The default constructor (delegates to set_hamming_distance()). More...
 
template<arithmetic score_arg_t>
constexpr aminoacid_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 aminoacid_scoring_scheme (matrix_type const &matrix) noexcept
 Constructor for a custom scheme (delegates to set_custom_matrix()). More...
 
constexpr aminoacid_scoring_scheme (aminoacid_similarity_matrix const matrix_id)
 Construct for seqan3::aminoacid_similarity_matrix. More...
 
Scheme selection
constexpr void set_similarity_matrix (aminoacid_similarity_matrix const matrix_id)
 Set the similarity matrix scheme (e.g. BLOSUM62). 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== (aminoacid_scoring_scheme< int8_t > const &rhs) const noexcept
 Checks whether *this is equal to rhs.
 
constexpr bool operator!= (aminoacid_scoring_scheme< int8_t > 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
 aminoacid_scoring_scheme () -> aminoacid_scoring_scheme< int8_t >
 Default constructed objects deduce to int8_t.
 
template<arithmetic score_arg_type>
 aminoacid_scoring_scheme (match_score< score_arg_type >, mismatch_score< score_arg_type >) -> aminoacid_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>
 aminoacid_scoring_scheme (std::array< std::array< score_arg_type, 27 >, 27 >) -> aminoacid_scoring_scheme< score_arg_type >
 Deduce the score type from the provided matrix.
 
 aminoacid_scoring_scheme (aminoacid_similarity_matrix) -> aminoacid_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.
 

Detailed Description

template<arithmetic score_type = int8_t>
class seqan3::aminoacid_scoring_scheme< score_type >

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

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

Example

#include <range/v3/view/zip.hpp>
int main()
{
using seqan3::operator""_aa27;
using seqan3::operator""_aa20;
seqan3::aminoacid_scoring_scheme scheme{seqan3::aminoacid_similarity_matrix::BLOSUM62};
// How to score two letters:
seqan3::debug_stream << "BLOSUM62 score for T and S: " << (int) scheme.score('T'_aa27, 'S'_aa27) << "\n"; // == 1
scheme.set_similarity_matrix(seqan3::aminoacid_similarity_matrix::BLOSUM80);
// You can also score aa20 against aa27:
seqan3::debug_stream << "BLOSUM80 score for 'T'_aa27 and 'S'_aa20: " << (int) scheme.score('T'_aa27, 'S'_aa20) << "\n"; // == 2
scheme.set_hamming_distance();
seqan3::debug_stream << "Hamming distance between T and S: " << (int) scheme.score('T'_aa27, 'S'_aa20) << "\n"; // == -1
seqan3::debug_stream << "Hamming distance between T and T: " << (int) scheme.score('T'_aa27, 'T'_aa20) << "\n"; // == 0
// You can "edit" a given matrix directly:
seqan3::debug_stream << "BLOSUM80 score between T and S: " << (int) scheme2.score('T'_aa27, 'S'_aa27) << "\n"; // == 2
auto & cell = scheme2.score('T'_aa27, 'S'_aa27);
cell = 3;
seqan3::debug_stream << "New score after editing entry: " << (int) scheme2.score('T'_aa27, 'S'_aa27) << "\n"; // == 3
std::vector<seqan3::aa27> one = "ALIGATOR"_aa27;
std::vector<seqan3::aa27> two = "ANIMATOR"_aa27;
seqan3::aminoacid_scoring_scheme scheme3{seqan3::aminoacid_similarity_matrix::BLOSUM62};
// You can also score two sequences:
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"; // 4 + -3 + 4 + -3 + 4 + 5 + -1 + 5 = 15
}

Constructor & Destructor Documentation

◆ aminoacid_scoring_scheme() [1/4]

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

The default constructor (delegates to set_hamming_distance()).

◆ aminoacid_scoring_scheme() [2/4]

template<arithmetic score_type = int8_t>
template<arithmetic score_arg_t>
constexpr seqan3::aminoacid_scoring_scheme< score_type >::aminoacid_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.

◆ aminoacid_scoring_scheme() [3/4]

template<arithmetic score_type = int8_t>
constexpr seqan3::aminoacid_scoring_scheme< score_type >::aminoacid_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.

◆ aminoacid_scoring_scheme() [4/4]

template<arithmetic score_type = int8_t>
constexpr seqan3::aminoacid_scoring_scheme< score_type >::aminoacid_scoring_scheme ( aminoacid_similarity_matrix const  matrix_id)
inlineconstexpr

Construct for seqan3::aminoacid_similarity_matrix.

Parameters
[in]matrix_idThe enum ID of the matrix, see seqan3::aminoacid_similarity_matrix.
Exceptions
std::invalid_argumentIf there is no matrix data for the given ID (usually a BUG).

Member Function Documentation

◆ score() [1/2]

constexpr score_t seqan3::scoring_scheme_base< aminoacid_scoring_scheme< int8_t > , alphabet_t, score_t >::score ( alph1_t const  alph1,
alph2_t const  alph2 
) const
inlineconstexprnoexceptinherited

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< aminoacid_scoring_scheme< int8_t > , alphabet_t, score_t >::score ( alph1_t const  alph1,
alph2_t const  alph2 
)
inlineconstexprnoexceptinherited

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.

◆ set_custom_matrix()

constexpr void seqan3::scoring_scheme_base< aminoacid_scoring_scheme< int8_t > , alphabet_t, score_t >::set_custom_matrix ( matrix_type const &  matrix)
inlineconstexprnoexceptinherited

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

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

◆ set_similarity_matrix()

template<arithmetic score_type = int8_t>
constexpr void seqan3::aminoacid_scoring_scheme< score_type >::set_similarity_matrix ( aminoacid_similarity_matrix const  matrix_id)
inlineconstexpr

Set the similarity matrix scheme (e.g. BLOSUM62).

Parameters
[in]matrix_idThe enum ID of the matrix, see seqan3::aminoacid_similarity_matrix.
Exceptions
std::invalid_argumentIf there is no matrix data for the given ID (usually a BUG).

◆ set_simple_scheme()

constexpr void seqan3::scoring_scheme_base< aminoacid_scoring_scheme< int8_t > , alphabet_t, score_t >::set_simple_scheme ( match_score< score_arg_t > const  ms,
mismatch_score< score_arg_t > const  mms 
)
inlineconstexprinherited

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.

The documentation for this class was generated from the following file:
debug_stream.hpp
Provides seqan3::debug_stream and related types.
zip.hpp
Provides seqan3::views::zip.
std::vector
seqan3::aminoacid_similarity_matrix::BLOSUM30
@ BLOSUM30
The BLOSUM30 matrix for very distantly related proteins.
seqan3::scoring_scheme_base< aminoacid_scoring_scheme< int8_t >, aa27, int8_t >::score
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
aminoacid_scoring_scheme.hpp
Provides seqan3::aminoacid_scoring_scheme.
aa27.hpp
Provides seqan3::aa27, container aliases and string literals.
seqan3::aminoacid_scoring_scheme
A data structure for managing and computing the score of two amino acids.
Definition: aminoacid_scoring_scheme.hpp:75
all.hpp
Meta-header for the aminoacid submodule; includes all headers from alphabet/aminoacid/.
seqan3::debug_stream
debug_stream_type debug_stream
A global instance of seqan3::debug_stream_type.
Definition: debug_stream.hpp:42