yat  0.20.3pre
Classes | Public Types | Public Member Functions | List of all members
theplu::yat::utility::Aligner Class Reference

Aligning two sequences. More...

#include <yat/utility/Aligner.h>

Classes

class  Cigar
 Compact Idiosyncratic Gapped Alignment Report. More...
 

Public Types

enum  direction { none, right, down, diagonal }
 

Public Member Functions

 Aligner (double gap=0, double open_gap=0)
 Constructor. More...
 
 Aligner (double vertical_gap, double open_vertical_gap, double horizon_gap, double open_horizon_gap)
 constructor More...
 
double needleman_wunsch (const MatrixBase &d)
 
double smith_waterman (const MatrixBase &d)
 
void operator() (const MatrixBase &dot, MatrixMutable &score)
 calculate score matrix based on the dot matrix More...
 
const directionalignment (size_t i, size_t j) const
 
const Cigar cigar (size_t i, size_t j) const
 

Detailed Description

Aligning two sequences.

General class aligning two sequences described in a dot-matrix, D, in which $ D(i,j) $ describes how similar element i in the first sequence is with element j in the second sequence. A path through this matrix corresponds to an alignment of the two sequences, in which a diagonal step correspoinds to a match between corresponding sequence elements, and a vertical or horizontal step correspond correspond to inserting a gap into one of the sequences.

Since
New in yat 0.9

Member Enumeration Documentation

◆ direction

Enum used to describe alignment.

See also
alignment

Constructor & Destructor Documentation

◆ Aligner() [1/2]

theplu::yat::utility::Aligner::Aligner ( double  gap = 0,
double  open_gap = 0 
)
explicit

Constructor.

Same as Aligner(gap, open_gap, gap, open_gap)

◆ Aligner() [2/2]

theplu::yat::utility::Aligner::Aligner ( double  vertical_gap,
double  open_vertical_gap,
double  horizon_gap,
double  open_horizon_gap 
)

constructor

Parameters
vertical_gapPenalty for extending a vertical gap. A vertical gap means alignment consumes an element in second element and not, in the first element, i.e., an element has been inserted to the second element or equivalently an element has been deleted in first sequence.
open_vertical_gapPenalty for open a vertical gap. Total cost for a vertical gap is open_vertical_gap + N * vertical_gap.
horizon_gapPenalty for extending a horizontal gap
open_horizon_gapPenalty for open a horizontal gap. Total penalty for a horizontal gap is open_horizon_gap + N horizon_gap.

Member Function Documentation

◆ alignment()

const direction& theplu::yat::utility::Aligner::alignment ( size_t  i,
size_t  j 
) const

If, for example, alignment(i,j) returns Aligner::diagonal, implies that score(i,j) was maximized as score(i-1,j-1) + dot(i-1, j-1), in other words, element i-1 in first sequence was aligned with element j-1 in second sequence.

◆ cigar()

const Cigar theplu::yat::utility::Aligner::cigar ( size_t  i,
size_t  j 
) const
Since
new in yat 0.12

◆ needleman_wunsch()

double theplu::yat::utility::Aligner::needleman_wunsch ( const MatrixBase d)

Initialize a score matrix with $ S_{k,0} = - \textrm{open\_vertical\_gap} - k * \textrm{vertical\_gap} $ and $ S_{0,k} = - \textrm{open\_horizon\_gap} - k * \textrm{horizon\_gap} $ and align using operator().

Returns
most lower right element of score matrix

◆ operator()()

void theplu::yat::utility::Aligner::operator() ( const MatrixBase dot,
MatrixMutable score 
)

calculate score matrix based on the dot matrix

The algorithm calculates a maximum score matrix as

$ S_{i,j} = \textrm{max} \{ S_{ij}; S_{i,j-1} - F(\textrm{gap}_V); S_{i-1,j-1} + D_{i-1,j-1}; S_{i-1,j} - F(\textrm{gap}_H) \} $

where $ F(\textrm{gap}) $ is gap if there was already a gap, and gap + open_gap otherwise.

To get the CIGAR to behave as expected, the each row in dot corresponds to an element in reference sequence and each row in dot corresponds to an element in query reference. If that is transposed, insertions and deletions are swapped in CIGAR.

The score matrix must have one column more than the dot matrix and one more row than the dot matrix.

◆ smith_waterman()

double theplu::yat::utility::Aligner::smith_waterman ( const MatrixBase d)

Initialize a score matrix with all elements equal to zero, align using operator().

Returns
max element in score matrix.
See also
SmithWaterman

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

Generated on Sat Feb 18 2023 03:31:45 for yat by  doxygen 1.8.14