![]() |
OpenMS
|
Global-alignment similarity score for two amino-acid sequences using the Needleman-Wunsch algorithm. More...
#include <OpenMS/ANALYSIS/SEQUENCE/NeedlemanWunsch.h>
Public Types | |
| enum class | ScoringMatrix { identity , PAM30MS , SIZE_OF_SCORINGMATRIX } |
| Substitution matrices bundled with this class. More... | |
Public Member Functions | |
| NeedlemanWunsch (ScoringMatrix matrix, int penalty) | |
| Construct with a chosen scoring matrix and gap penalty. | |
| NeedlemanWunsch ()=default | |
| Default constructor. | |
| ~NeedlemanWunsch ()=default | |
| Destructor. | |
| int | align (const std::string &seq1, const std::string &seq2) |
Compute the Needleman-Wunsch similarity score of seq1 vs. seq2. | |
| void | setMatrix (const ScoringMatrix &matrix) |
| Select the scoring matrix used by align. | |
| void | setMatrix (const std::string &matrix) |
| Select the scoring matrix by name; the accepted names are listed in NamesOfScoringMatrices. | |
| void | setPenalty (const int penalty) |
| Set the linear gap penalty subtracted per gap step. | |
| ScoringMatrix | getMatrix () const |
| Currently selected scoring matrix. | |
| int | getPenalty () const |
| Currently configured gap penalty. | |
Static Public Attributes | |
| static const std::vector< std::string > | NamesOfScoringMatrices |
Lookup table for setMatrix(const std::string&); current entries: "identity", "PAM30MS". | |
Private Attributes | |
| int | gap_penalty_ = 5 |
| Linear gap penalty. | |
| ScoringMatrix | my_matrix_ = ScoringMatrix::PAM30MS |
| Currently selected scoring matrix. | |
| std::vector< int > | first_row_ {} |
| First row of the two-row rolling buffer used by align. | |
| std::vector< int > | second_row_ {} |
| Second row of the two-row rolling buffer used by align. | |
Global-alignment similarity score for two amino-acid sequences using the Needleman-Wunsch algorithm.
Computes the score (not the alignment itself) of the best global alignment of two amino-acid sequences against a substitution matrix plus a linear gap penalty. The implementation uses a two-row rolling buffer.
c - 'A', so the input strings must contain only uppercase ASCII letters in [A-Z]. Characters J, O, and U have INT16_MAX rows/columns in both bundled matrices and effectively forbid any alignment involving them. Lowercase or non-ASCII characters lead to out-of-bounds reads.
|
strong |
| NeedlemanWunsch | ( | ScoringMatrix | matrix, |
| int | penalty | ||
| ) |
Construct with a chosen scoring matrix and gap penalty.
| [in] | matrix | Scoring matrix to use. |
| [in] | penalty | Linear gap penalty (subtracted per gap step). |
|
default |
Default constructor.
Uses ScoringMatrix::PAM30MS and a gap penalty of 5.
|
default |
Destructor.
| int align | ( | const std::string & | seq1, |
| const std::string & | seq2 | ||
| ) |
Compute the Needleman-Wunsch similarity score of seq1 vs. seq2.
Uses the currently selected scoring matrix and gap penalty. The sequences must contain only uppercase [A-Z] characters; see the class brief for the constraints.
| [in] | seq1 | First amino-acid sequence. |
| [in] | seq2 | Second amino-acid sequence. |
| ScoringMatrix getMatrix | ( | ) | const |
| int getPenalty | ( | ) | const |
Currently configured gap penalty.
5 if setPenalty has not been called). | void setMatrix | ( | const ScoringMatrix & | matrix | ) |
Select the scoring matrix used by align.
| [in] | matrix | Scoring matrix to use. |
| void setMatrix | ( | const std::string & | matrix | ) |
Select the scoring matrix by name; the accepted names are listed in NamesOfScoringMatrices.
| [in] | matrix | Matrix name (currently "identity" or "PAM30MS"). |
| Exception::IllegalArgument | when matrix is not one of the names in NamesOfScoringMatrices. The error message lists the valid names. |
| void setPenalty | ( | const int | penalty | ) |
Set the linear gap penalty subtracted per gap step.
| [in] | penalty | Gap penalty (typically positive); the algorithm subtracts penalty from the score for each gap step. |
|
private |
First row of the two-row rolling buffer used by align.
|
private |
Linear gap penalty.
|
private |
Currently selected scoring matrix.
|
static |
Lookup table for setMatrix(const std::string&); current entries: "identity", "PAM30MS".
|
private |
Second row of the two-row rolling buffer used by align.