source: trunk/yat/utility/Alignment.h @ 1707

Last change on this file since 1707 was 1514, checked in by Peter, 13 years ago

typo

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1#ifndef _theplu_yat_utility_alignment_
2#define _theplu_yat_utility_alignment_
3
4// $Id: Alignment.h 1514 2008-09-19 19:58:49Z peter $
5
6/*
7  Copyright (C) 2004 Jari Häkkinen, Peter Johansson
8  Copyright (C) 2005 Peter Johansson
9  Copyright (C) 2006 Jari Häkkinen
10  Copyright (C) 2007 Jari Häkkinen, Peter Johansson
11  Copyright (C) 2008 Peter Johansson
12
13  This file is part of the yat library, http://dev.thep.lu.se/yat
14
15  The yat library is free software; you can redistribute it and/or
16  modify it under the terms of the GNU General Public License as
17  published by the Free Software Foundation; either version 3 of the
18  License, or (at your option) any later version.
19
20  The yat library is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23  General Public License for more details.
24
25  You should have received a copy of the GNU General Public License
26  along with yat. If not, see <http://www.gnu.org/licenses/>.
27*/
28
29#include <string>
30#include <utility>
31#include <vector>
32
33namespace theplu {
34namespace yat {
35namespace utility {
36
37  class Matrix;
38
39  ///
40  /// Function performing alignment following the Needleman-Wunch
41  /// algorithm. The algorithm starts from the dot-matrix, \a s, where
42  /// \f$ s_{ij} \f$ describes how well element \f$ i \f$ in the first
43  /// sequence match to element \f$ j \f$ in the second sequence. A
44  /// path through this matrix corresponds to an alignment of the two
45  /// sequences, in which a diagonal step over a matrix element
46  /// corresponds to a match between the corresponding sequnce
47  /// elements and a vertical or a horizontal step corresponds to
48  /// inserting a gap in one of the sequnces. The function maximizes
49  /// \f$ \sum s_{ij}-n \f$ \a gap, where the first sum goes over all
50  /// matches and the second term is a penalty term for inserting \f$
51  /// n \f$ gaps. Default is to have the \a gap cost set to zero. The
52  /// vector \a path contains information about which elements that
53  /// were matched. If the first element in the first sequence was
54  /// matched to the first element in the second sequence, the last
55  /// element in \a path is pair(0,0).
56  ///
57  /// @return the global maximum alignment score.
58  ///
59  double NeedlemanWunsch(const utility::Matrix& s,
60                         std::vector<std::pair<size_t, size_t> >& path,
61                         const double gap);
62
63  /**
64     \brief Local alignment following the Smith-Waterman
65     algorithm.
66
67     The original paper can be found here:
68     http://gel.ym.edu.tw/~chc/AB_papers/03.pdf
69
70     Instead of looking at each sequence in its entirety the S-W algorithm
71     compares segment of all possible lengths (LOCAL alignment) and chooses
72     whichever maximises the similarity measure.
73
74     \param s score matrix in which element \f$(i,j)\f$ is the score between
75     element \f$i\f$ in first sequence vs element \f$j\f$ in second sequence.
76     \param gap cost for having a gap (insertion or deletion)
77     \param open_gap cost for open up a gap in sequence, in other words, for a
78     gap of length \f$l\f$ the total cost is \f$open_gap + l*gap\f$.
79   */
80  double SmithWaterman(const utility::Matrix& s,
81                       double gap, double open_gap);
82
83  /**
84     SSearch does a rigorous Smith-Waterman search for similarity between
85     sequnces. For long sequences this may be very expensive (both in time and
86     space) and BLAST or FASTA is preferable.
87
88     @return score
89   */
90  double ssearch(std::string first, std::string second, double gap, 
91                 double open_gap);
92
93}}} // of namespace utility, yat, and theplu
94
95#endif
Note: See TracBrowser for help on using the repository browser.