OpenMS  2.7.0
Public Types | Public Member Functions | Static Public Attributes | Private Attributes | List of all members
NeedlemanWunsch Class Reference

This class serves for the calculation of the global alignment score of two amino acid sequences by using the Needleman-Wunsch-Algorithm. For match and mismatch it uses a similarity scoring matrix. More...

#include <OpenMS/ANALYSIS/SEQUENCE/NeedlemanWunsch.h>

Collaboration diagram for NeedlemanWunsch:
[legend]

Public Types

enum class  ScoringMatrix { identity , PAM30MS , SIZE_OF_SCORINGMATRIX }
 contains the valid matrices and the number of them More...
 

Public Member Functions

 NeedlemanWunsch (ScoringMatrix matrix, int penalty)
 Constructor that sets the scoring matrix and the gap penalty. More...
 
 NeedlemanWunsch ()=default
 Default constructor (scoring matrix PAM30MS and penalty 5) More...
 
 ~NeedlemanWunsch ()=default
 Default destructor. More...
 
int align (const String &seq1, const String &seq2)
 Calculates the similarity score of the global alignment of two amino acid sequences using Needleman-Wunsch- Algorithm. More...
 
void setMatrix (const ScoringMatrix &matrix)
 sets the scoring matrix. Takes either a string or the enum ScoringMatrix. More...
 
void setMatrix (const std::string &matrix)
 
void setPenalty (const int penalty)
 sets the cost of gaps More...
 
ScoringMatrix getMatrix () const
 returns the scoring matrix More...
 
int getPenalty () const
 returns the gap penalty More...
 

Static Public Attributes

static const std::vector< std::string > NamesOfScoringMatrices
 Names of valid matrices. More...
 

Private Attributes

int gap_penalty_ = 5
 penalty for alignment score calculation More...
 
ScoringMatrix my_matrix_ = ScoringMatrix::PAM30MS
 scoring matrix for the alignment score calculation More...
 
std::vector< int > first_row_ {}
 alignment score calculation with two rows More...
 
std::vector< int > second_row_ {}
 

Detailed Description

This class serves for the calculation of the global alignment score of two amino acid sequences by using the Needleman-Wunsch-Algorithm. For match and mismatch it uses a similarity scoring matrix.

Member Enumeration Documentation

◆ ScoringMatrix

enum ScoringMatrix
strong

contains the valid matrices and the number of them

Enumerator
identity 
PAM30MS 
SIZE_OF_SCORINGMATRIX 

Constructor & Destructor Documentation

◆ NeedlemanWunsch() [1/2]

NeedlemanWunsch ( ScoringMatrix  matrix,
int  penalty 
)

Constructor that sets the scoring matrix and the gap penalty.

◆ NeedlemanWunsch() [2/2]

NeedlemanWunsch ( )
default

Default constructor (scoring matrix PAM30MS and penalty 5)

◆ ~NeedlemanWunsch()

~NeedlemanWunsch ( )
default

Default destructor.

Member Function Documentation

◆ align()

int align ( const String seq1,
const String seq2 
)

Calculates the similarity score of the global alignment of two amino acid sequences using Needleman-Wunsch- Algorithm.

◆ getMatrix()

ScoringMatrix getMatrix ( ) const

returns the scoring matrix

◆ getPenalty()

int getPenalty ( ) const

returns the gap penalty

◆ setMatrix() [1/2]

void setMatrix ( const ScoringMatrix matrix)

sets the scoring matrix. Takes either a string or the enum ScoringMatrix.

Exceptions
Exceptionillegal argument is thrown if the input is not a member of the valid matrices.

◆ setMatrix() [2/2]

void setMatrix ( const std::string &  matrix)

◆ setPenalty()

void setPenalty ( const int  penalty)

sets the cost of gaps

Member Data Documentation

◆ first_row_

std::vector<int> first_row_ {}
private

alignment score calculation with two rows

◆ gap_penalty_

int gap_penalty_ = 5
private

penalty for alignment score calculation

◆ my_matrix_

ScoringMatrix my_matrix_ = ScoringMatrix::PAM30MS
private

scoring matrix for the alignment score calculation

◆ NamesOfScoringMatrices

const std::vector<std::string> NamesOfScoringMatrices
static

Names of valid matrices.

◆ second_row_

std::vector<int> second_row_ {}
private