yat  0.18pre
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>


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 Matrix &d)
double smith_waterman (const Matrix &d)
void operator() (const Matrix &dot, Matrix &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.

New in yat 0.9

Member Enumeration Documentation

Enum used to describe alignment.

See also

Constructor & Destructor Documentation

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


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

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


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

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.

const Cigar theplu::yat::utility::Aligner::cigar ( size_t  i,
size_t  j 
) const
new in yat 0.12
double theplu::yat::utility::Aligner::needleman_wunsch ( const Matrix 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().

most lower right element of score matrix
void theplu::yat::utility::Aligner::operator() ( const Matrix dot,
Matrix 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.

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

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

max element in score matrix.
See also

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

Generated on Sun Sep 27 2020 02:26:14 for yat by  doxygen 1.8.11