|
ADS
Algorithms and Data Structures
|
The alignments of two strings \( P \) and \( T \) of exercises 13.7 to 13.9 of the book: spaces are inserted in \( P \) or \( T \), never one in front of the other, and each column scores \( +1 \) if the characters are equal, \( -1 \) if they differ and \( -2 \) if one is a space. More...
#include <algorithm>#include "ADS/Contract.h"#include <cstddef>#include <string>#include <utility>#include <vector>#include "ADS/string/impl/Alignment.tpp"Go to the source code of this file.
Namespaces | |
| namespace | ADS |
Enumerations | |
| enum class | ADS::Alignment { ADS::Alignment::GLOBAL , ADS::Alignment::SEMIGLOBAL , ADS::Alignment::LOCAL } |
| the kind of alignment More... | |
Functions | |
| template<class S> | |
| int | ADS::alignmentScore (const S &P, const S &T, Alignment kind) |
| the best score of an alignment of \( P \) and \( T \) | |
| template<class S> | |
| std::pair< S, S > | ADS::globalAlignment (const S &P, const S &T, typename S::value_type gap=' ') |
| a best global alignment, the two strings with the spaces as gap | |
The alignments of two strings \( P \) and \( T \) of exercises 13.7 to 13.9 of the book: spaces are inserted in \( P \) or \( T \), never one in front of the other, and each column scores \( +1 \) if the characters are equal, \( -1 \) if they differ and \( -2 \) if one is a space.
The best score \( \mathit{DP}[ i ][ j ] \) of the prefixes \( P( i ) \) and \( T( j ) \) is
\[ \max\{ \mathit{DP}[ i ][ j - 1 ] - 2 , \mathit{DP}[ i - 1 ][ j ] - 2 , \mathit{DP}[ i - 1 ][ j - 1 ] + \delta_{ij} \} \]
with \( \delta_{ij} = \pm 1 \), \( \Theta( m n ) \) time:
The contracts [see Contract.h]: the two strings of a global alignment have the same length, at least that of the longer string. The operations are defined in Alignment.tpp.