1 | #ifndef _theplu_yat_utility_alignment_ |
---|
2 | #define _theplu_yat_utility_alignment_ |
---|
3 | |
---|
4 | // $Id: Alignment.h 873 2007-09-18 01:14:38Z 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 | |
---|
11 | This file is part of the yat library, http://trac.thep.lu.se/trac/yat |
---|
12 | |
---|
13 | The yat library is free software; you can redistribute it and/or |
---|
14 | modify it under the terms of the GNU General Public License as |
---|
15 | published by the Free Software Foundation; either version 2 of the |
---|
16 | License, or (at your option) any later version. |
---|
17 | |
---|
18 | The yat library is distributed in the hope that it will be useful, |
---|
19 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
21 | General Public License for more details. |
---|
22 | |
---|
23 | You should have received a copy of the GNU General Public License |
---|
24 | along with this program; if not, write to the Free Software |
---|
25 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
---|
26 | 02111-1307, USA. |
---|
27 | */ |
---|
28 | |
---|
29 | #include <string> |
---|
30 | #include <utility> |
---|
31 | #include <vector> |
---|
32 | |
---|
33 | namespace theplu { |
---|
34 | namespace yat { |
---|
35 | namespace 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 segemnt 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 |
---|