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

Last change on this file since 1486 was 1486, checked in by Jari Häkkinen, 13 years ago

Addresses #436.

  • 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 1486 2008-09-09 21:17:19Z jari $
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 this program; if not, write to the Free Software
27  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28  02111-1307, USA.
29*/
30
31#include <string>
32#include <utility>
33#include <vector>
34
35namespace theplu {
36namespace yat {
37namespace utility {
38
39  class Matrix;
40
41  ///
42  /// Function performing alignment following the Needleman-Wunch
43  /// algorithm. The algorithm starts from the dot-matrix, \a s, where
44  /// \f$ s_{ij} \f$ describes how well element \f$ i \f$ in the first
45  /// sequence match to element \f$ j \f$ in the second sequence. A
46  /// path through this matrix corresponds to an alignment of the two
47  /// sequences, in which a diagonal step over a matrix element
48  /// corresponds to a match between the corresponding sequnce
49  /// elements and a vertical or a horizontal step corresponds to
50  /// inserting a gap in one of the sequnces. The function maximizes
51  /// \f$ \sum s_{ij}-n \f$ \a gap, where the first sum goes over all
52  /// matches and the second term is a penalty term for inserting \f$
53  /// n \f$ gaps. Default is to have the \a gap cost set to zero. The
54  /// vector \a path contains information about which elements that
55  /// were matched. If the first element in the first sequence was
56  /// matched to the first element in the second sequence, the last
57  /// element in \a path is pair(0,0).
58  ///
59  /// @return the global maximum alignment score.
60  ///
61  double NeedlemanWunsch(const utility::Matrix& s,
62                         std::vector<std::pair<size_t, size_t> >& path,
63                         const double gap);
64
65  /**
66     \brief Local alignment following the Smith-Waterman
67     algorithm.
68
69     The original paper can be found here:
70     http://gel.ym.edu.tw/~chc/AB_papers/03.pdf
71
72     Instead of looking at each sequence in its entirety the S-W algorithm
73     compares segemnt of all possible lengths (LOCAL alignment) and chooses
74     whichever maximises the similarity measure.
75
76     \param s score matrix in which element \f$(i,j)\f$ is the score between
77     element \f$i\f$ in first sequence vs element \f$j\f$ in second sequence.
78     \param gap cost for having a gap (insertion or deletion)
79     \param open_gap cost for open up a gap in sequence, in other words, for a
80     gap of length \f$l\f$ the total cost is \f$open_gap + l*gap\f$.
81   */
82  double SmithWaterman(const utility::Matrix& s,
83                       double gap, double open_gap);
84
85  /**
86     SSearch does a rigorous Smith-Waterman search for similarity between
87     sequnces. For long sequences this may be very expensive (both in time and
88     space) and BLAST or FASTA is preferable.
89
90     @return score
91   */
92  double ssearch(std::string first, std::string second, double gap, 
93                 double open_gap);
94
95}}} // of namespace utility, yat, and theplu
96
97#endif
Note: See TracBrowser for help on using the repository browser.