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

Last change on this file since 1797 was 1797, checked in by Peter, 12 years ago

updating copyright statements

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