-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathNeedleman-Wunsch.html
203 lines (184 loc) · 7.87 KB
/
Needleman-Wunsch.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
<!--
University of Freiburg WS 2017/2018
Chair for Bioinformatics
Supervisor: Martin Raden
Authors: Martin Raden, Alexander Mattheis
-->
<div id="algorithm_description">
<div class="description">
<a href="https://doi.org/10.1016/0022-2836(70)90057-4">
Saul B. Needleman and Christian D. Wunsch</a> introduced 1970 an approach to
compute the optimal global alignment of two sequences.
A minimizing variant was introduced 1974 by
<a href="https://doi.org/10.1137/0126070">Peter H. Sellers</a>.
<br />
<br />
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$,
where an entry $D_{i,j}$ represents the best score for aligning the
prefixes $a_{1..i}$ with $b_{1..j}$. The according recursions are shown below.
Note, consecutive gap (insertion/deletion) scoring is done linearly.
<br />
<br />
For the given input, the final 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="Needleman-Wunsch-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">
Gap <input class="fx_parameter" data-bind="value: input.gap" id="gap" type="number">
</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 class="row">
<div class="colW100">
<label>
<br />
<br />
Recursion:
</label>
</div>
<div class="colW600">
<span data-bind="text: $root.input.formula"></span>
</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>