-
Notifications
You must be signed in to change notification settings - Fork 16
/
Waterman-Smith-Beyer.html
241 lines (214 loc) · 10.4 KB
/
Waterman-Smith-Beyer.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<!--
University of Freiburg WS 2017/2018
Chair for Bioinformatics
Supervisor: Martin Raden
Authors: Martin Raden, Alexander Mattheis
-->
<div class="waterman_smith_bayer_static_size"> <!-- to avoid that MathJax disrupts the output -->
<div id="algorithm_description">
<div class="description">
The dynamic programming approach by
<a href="https://doi.org/10.1016/0001-8708(76)90202-4">
Michael S. Waterman, Temple F. Smith and William A. Beyer (1976)</a>
computes optimal global alignments for two sequences and
allows an arbitrary scoring of consecutive gaps (insertions/deletions).
Thus, it can incorporate the assumption that a single large insertion/deletion event is
biologically more likely to happen compared to many small insertions/deletions by
using e.g. a logarithmic or affine gap scoring function.
<br />
<br />
To this end, all possible gap lengths are explicitly considered within the recursion,
which increases the time complexity from $O(n^2)$ to $O(n^3)$ when compared to the approach by
<a href="https://doi.org/10.1016/0022-2836(70)90057-4">Needleman and Wunsch (1970)</a>
that applies a linear gap scoring.
Under the assumption that both input sequences $a$ and $b$ stem from the same origin,
a global alignment tries to identify matching parts and the
changes needed to transfer one sequence into the other.
The changes are scored and an optimal set of changes is identified, which defines an alignment.
The dynamic programming approach tabularizes optimal subsolutions in matrix $D$.
An entry $D_{i,j}$ represents the best score for the alignment of the
prefixes $a_{1..i}$ with $b_{1..j}$. The according recursion is shown below.
<br />
<br />
For the given input, the according table $D$ is provided along with a list
of according optimal alignments.
On table cell selection, optimal traceback options are shown.
On alignment selection, an according traceback path is visualized in the table.
</div>
<div class="picture">
<img src="Waterman-Smith-Beyer-120x90.png" />
</div>
</div>
<h1>Input:</h1>
<div id="algorithm_input">
<div class="row">
<div class="colW100"><label>Sequence $a$:</label></div>
<div class="colW400"><input class="sequence" data-bind="value: input.sequence1" id="sequence_1" placeholder="EXAMPLE 'ATC'"
title="Allowed are A-Z and '-'." type="text"></div>
</div>
<div class="row">
<div class="colW100"><label>Sequence $b$:</label></div>
<div class="colW400"><input class="sequence" data-bind="value: input.sequence2" id="sequence_2" placeholder="EXAMPLE 'AGTC'"
title="Allowed are A-Z and '-'." type="text"></div>
</div>
<div class="row">
<div class="colW100"><label>Optimization of:</label></div>
<div class="colW400">
<span class="group">
Distance <input class="optimization_type" data-bind="checked: input.calculation" id="distance"
name="calculation" type="radio" value="distance">
Similarity <input class="optimization_type" data-bind="checked: input.calculation" id="similarity"
name="calculation" type="radio" value="similarity">
</span>
</div>
</div>
<div class="row">
<div class="colW100"><label>Scoring in $s$:</label></div>
<div class="colW400">
<span class="group"> <!-- Microsoft Browsers will fallback on text-fields using following input type -->
Match <input class="fx_parameter" data-bind="value: input.match" id="match" type="number">
Mismatch <input class="fx_parameter" data-bind="value: input.mismatch" id="mismatch" type="number">
</span>
</div>
</div>
<div class="row">
<div class="colW100"><label>Gap function $g$:</label></div>
<div class="colW400">
<span class="group"> <!-- Microsoft Browsers will fallback on text-fields using following input type -->
Affine <input class="gap_function_type" data-bind="checked: input.subadditiveFunction" id="affine"
name="functionGroup" type="radio" value="affine">
Logarithmic <input class="gap_function_type" data-bind="checked: input.subadditiveFunction" id="logarithmic"
name="functionGroup" type="radio" value="logarithmic">
Quadratic <input class="gap_function_type" data-bind="checked: input.subadditiveFunction" id="quadratic"
name="functionGroup" type="radio" value="quadratic">
</span>
<br />
<br />
<span data-bind="text: $root.input.gapFunction"></span>
<br />
<br />
<span class="group"> <!-- Microsoft Browsers will fallback on text-fields using following input type -->
Gap opening $\alpha$ <input class="fx_parameter" data-bind="value: input.baseCosts" id="base_costs" type="number">
Enlargement $\beta$ <input class="fx_parameter" data-bind="value: input.enlargement" id="enlargement" type="number">
</span>
</div>
</div>
<div class="row">
<div class="colW100">
<br />
<label>
<br />
<br />
Recursion:
</label>
</div>
<div class="colW600">
<span data-bind="text: $root.input.formula"></span>
<div class="group_hint">
<b>Hint:</b> <br />
For similarity maximization, <br /> match scores should be positive and all other scores lower. <br />
For distance minimization the reverse applies.
</div>
</div>
</div>
</div>
</div>
<h1>Output:</h1>
<div id="algorithm_output">
<div class="output">
<div class="main_output">
<table class="calculation">
<thead>
<tr>
<th>$D$</th>
<th></th>
<!-- ko foreach: input.sequence2 -->
<th data-bind="drawChar: [$data, $index()+1]"></th>
<!-- /ko -->
</tr>
</thead>
<tbody>
<!-- ko foreach: output.matrix --> <!-- to get i-indexes = $parentContext.$index() -->
<tr>
<!-- ko if: $index() == 0 -->
<th></th>
<!-- /ko -->
<!-- ko if: $index() > 0 -->
<th data-bind="drawChar: [$root.input.sequence1()[$index()-1], $index()]"></th>
<!-- /ko -->
<!-- ko foreach: $root.output.matrix[0] --> <!-- to get j-indexes = $index() -->
<td class="selectable_entry"
data-bind="text: $root.output.matrix()[$parentContext.$index()][$index()]"></td>
<!-- /ko -->
</tr>
<!-- /ko -->
<tr>
<th class="hint" colspan=100%> <!-- HINT: move colspan into "hint"-class when browsers are ready! -->
<small>
<b>Score:</b> <span data-bind="text: $root.output.score"></span>
</small>
</th>
</tr>
</tbody>
</table>
</div>
<div class="download_area">
<a class="table_download" href="#">Download Table</a>
</div>
</div>
<div class="outcome">
<div class ="ancillary_output">
<table class="results_header">
<thead>
<tr>
<th>
Results <br />
<small>
You can select a result to get the related traceback.
</small>
</th>
</tr>
</thead>
</table>
<div class="results_with_scrollbar">
<table class="results">
<tbody>
<!-- ko foreach: $root.output.alignments -->
<!-- ko if: $index() < 10 -->
<!-- ko if: $index() == 0 -->
<tr>
<td class="selectable_entry selectable_entry_start">
<code data-bind="text: $root.output.alignments()[$index()][0]"></code> <br />
<code data-bind="text: $root.output.alignments()[$index()][1]"></code> <br />
<code data-bind="text: $root.output.alignments()[$index()][2]"></code>
</td>
</tr>
<!-- /ko -->
<!-- ko if: $index() != 0 -->
<tr>
<td class="selectable_entry">
<code data-bind="text: $root.output.alignments()[$index()][0]"></code> <br />
<code data-bind="text: $root.output.alignments()[$index()][1]"></code> <br />
<code data-bind="text: $root.output.alignments()[$index()][2]"></code>
</td>
</tr>
<!-- /ko -->
<!-- /ko -->
<!-- /ko -->
</tbody>
</table>
</div>
<table class="results_footer">
<tr>
<th>
<small>
<!-- ko if: $root.output.moreTracebacks -->
<b>Hint:</b> Only the first ten results are computed.
<!-- /ko -->
</small>
</th>
</tr>
</table>
</div>
</div>
</div>