-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate.html
385 lines (349 loc) · 15.7 KB
/
template.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<title>{{ family }}</title>
<style>
.guanine {
background-color: rgb(255, 192, 203);
}
.uracil {
background-color: rgb(255, 247, 61);
}
.adenine {
background-color: rgb(118, 208, 233);
}
.cytosine {
background-color: rgb(131, 236, 149);
}
.mature {
text-decoration: underline overline;
}
.table td {
padding: 0 5px;
}
.table {
font-size: 11px;
}
.bit_score {
cursor: pointer;
}
.ralee_80 {
background-color: #72f9fd;
}
.ralee_60 {
background-color: #96cde8;
}
.ralee_40 {
background-color: #bebebe;
}
</style>
</head>
<body>
<div class="container-fluid" style="margin-bottom: 10px;">
<h1>{{ family }}</h1>
<!-- <button class="btn btn-outline-success btn-sm" onclick="document.getElementById('gathering-cutoff').scrollIntoView({behavior: 'smooth'})">✅ Gathering cutoff</button>
<button class="btn btn-outline-danger btn-sm" onclick="document.getElementById('best-reversed-hit').scrollIntoView({behavior: 'smooth'})">🛑 Best reversed</button> -->
<button class="btn btn-outline-dark btn-sm" id="toggle-columns">🎨 Colour by base identity</button>
<div class="btn-group" role="group" aria-label="Ralee controls">
<button class="btn btn-outline-dark btn-sm" id="ralee-conservation">🍭 Ralee conservation view</button>
<button class="btn btn-outline-dark btn-sm" id="reset-ralee-conservation">Reset</button>
</div>
<p class="text-muted">
By default a nucleotide is <span class="text-success">green</span> if it occurs in the seed or <span class="text-danger">red</span> otherwise.
<span class="mature">Mature sequences</span> are highlighted with under- and overlines.
<br>
In Ralee view, nucleotides are coloured by conservation (<label class="ralee_80">80-100%</label>, <label class="ralee_60">60-80%</label>, and <label class="ralee_40">40-60%</label>).
<br>
Hover over <em>accession</em>, <em>bit score</em> or <em>taxonomic string</em> to see more information
</p>
<div>
<input type="range" id="ga_threshold" name="ga_threshold"
value="25" min="25" max="120" step="1">
<label for="ga_threshold">Gathering threshold</label>
<span id="ga-label">25</span> bits
<div class="btn-group" role="group" aria-label="Threshold controls" style="margin-left: 10px; margin-right: 10px;">
<button class="btn btn-outline-primary btn-sm" id="set-threshold">Set threshold</button>
<button class="btn btn-outline-dark btn-sm" id="reset-threshold">Reset</button>
</div>
<span class="text-muted">Click on bit score to set threshold or drag slider and click Set threshold</span>
</div>
</div>
<table class="table table-striped table-borderless table-hover table-sm table-responsive">
<thead>
<tr>
<td><strong>Seed consensus</strong></td>
<td> </td>
<td> </td>
<td class="text-monospace alignment" style="display: inline-flex; font-weight: bold;">
{% for nt in rf_line %}
{% if nt.upper() == 'A' %}
<span class="adenine-inactive">A</span>
{% elif nt.upper() == 'G' %}
<span class="guanine-inactive">G</span>
{% elif nt.upper() == 'C' %}
<span class="cytosine-inactive">C</span>
{% elif nt.upper() == 'U' %}
<span class="uracil-inactive">U</span>
{% else %}
<span>{{ nt }}</span>
{% endif %}
{% endfor %}
</td>
<td> </td>
</tr>
</thead>
<tbody>
<tr>
<td>Consensus structure</td>
<td></td>
<td> </td>
<td class="text-monospace" style="display: inline-flex;">
{% for ss_symbol in ss_cons_split %}
<span>{{ ss_symbol }}</span>
{% endfor %}
</td>
<td> </td>
</tr>
{% for species_row, outlist_row, big_drop, skip in zip(species, outlist, big_drops, outlist_skip) %}
{% if species_row is string and 'CURRENT GA' in species_row %}
<tr class="table-success" id="gathering-cutoff">
<td colspan="5" class="lead"><strong>✅ {{ species_row }}</strong><td>
</tr>
{% elif species_row is string and 'BEST REVERSED in species_row' %}
<tr class="table-danger" id="best-reversed-hit">
<td colspan="5" class="lead">
<strong>🛑 {{ species_row }}</strong>
{% set num_hidden = outlist_skip | select("equalto", 1) | list | count %}
{% if num_hidden > 0 %}
<strong style="margin-left: 15px;">☠️ {{ num_hidden }}</strong> entries below reversed hidden (showing only the top scoring hit from each species)
{% endif %}
<td>
</tr>
{% elif skip != 1 %}
<tr>
<td style="white-space: nowrap;" class="small" data-toggle="tooltip" data-placement="right" title="{{ outlist_row.description }}">
{% if species_row.name.startswith('URS00') %}
<a href="https://rnacentral.org/rna/{{ outlist_row.urs_taxid }}" target="_blank">{{ species_row.name }}</a> ({{ outlist_row.str }})
{% else %}
<a href="https://www.ncbi.nlm.nih.gov/nuccore/{{ species_row.name }}?report=docsum&log$=seqview" target="_blank">{{ species_row.name }}/{{ outlist_row.start }}-{{ outlist_row.end }}</a> ({{ outlist_row.str }})
{% endif %}
</td>
<td data-toggle="tooltip" data-placement="top" title="{% if big_drop %} ⚠️ Bit score drop > 10 ⚠️ {% endif %} E-value {{ outlist_row.evalue }}" {% if big_drop %} class="table-danger"{% endif %}>
<strong class="bit_score">{{ species_row.bits }}</strong>
</td>
{% if species_row.seqLabel == 'SEED' and outlist_row.str != '-' %}
<td><span class="badge badge-success">{{ species_row.seqLabel }}</span></td>
{% elif species_row.seqLabel == 'SEED' and outlist_row.str == '-' %}
<td data-toggle="tooltip" data-placement="top" title="⚠️ Reversed match ⚠️"><span class="badge badge-danger" >{{ species_row.seqLabel }}</span></td>
{% else %}
<td class="text-muted">{{ species_row.seqLabel }}</td>
{% endif %}
<td class="text-monospace sequence" style="display: inline-flex; {% if species_row.seqLabel == 'SEED' %}font-weight: bold;{% endif %}">
{% if outlist_row.seq_name in align %}
{% for nt in align[outlist_row.seq_name].sequence_split %}
{% if nt == 'A' %}
<span class="adenine-inactive {% if nt in seed_nts[loop.index0] %}text-success{% else %}text-danger{% endif %} {% if outlist_row.urs_taxid in mature_mirnas and mature_mirnas[outlist_row.urs_taxid][loop.index0] == 1 %}mature{% endif %}">A</span>
{% elif nt == 'G' %}
<span class="guanine-inactive {% if nt in seed_nts[loop.index0] %}text-success{% else %}text-danger{% endif %} {% if outlist_row.urs_taxid in mature_mirnas and mature_mirnas[outlist_row.urs_taxid][loop.index0] == 1 %}mature{% endif %}">G</span>
{% elif nt == 'C' %}
<span class="cytosine-inactive {% if nt in seed_nts[loop.index0] %}text-success{% else %}text-danger{% endif %} {% if outlist_row.urs_taxid in mature_mirnas and mature_mirnas[outlist_row.urs_taxid][loop.index0] == 1 %}mature{% endif %}">C</span>
{% elif nt == 'U' %}
<span class="uracil-inactive {% if nt in seed_nts[loop.index0] %}text-success{% else %}text-danger{% endif %} {% if outlist_row.urs_taxid in mature_mirnas and mature_mirnas[outlist_row.urs_taxid][loop.index0] == 1 %}mature{% endif %}">U</span>
{% else %}
<span>{{ nt }}</span>
{% endif %}
{% endfor %}
{% else %}
{% endif %}
</td>
<td style="white-space: nowrap;">
<span data-toggle="tooltip" data-placement="left" title="{{ species_row.species }}">
{{ get_emoji(species_row.taxString) }}
<a class="small" href="https://www.ncbi.nlm.nih.gov/Taxonomy/Browser/wwwtax.cgi?id={{ species_row.ncbiId }}" target="_blank">
{% for taxon in species_row.tax_string_split %}
<span class="{% if taxon in seed_taxa %}text-success{% else %}text-danger{% endif %}">
{{ taxon }}{% if not loop.last %};{% endif %}
</span>
{% endfor %}
</a>
</span>
</td>
</tr>
{% endif %}
{% endfor %}
</tbody>
</table>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<script>
rfmake = function(threshold){
// hide alignment rows below threshold
var show_up_to = null;
$("tr").each(function(row_index) {
$this = $(this);
var td = $this.find(".bit_score");
if (td.length > 0) {
var bit_score = parseFloat($(td).html());
if (bit_score && bit_score < threshold) {
$this.hide();
} else {
$this.show();
show_up_to = row_index;
}
}
});
// hide empty alignment columns
var alignment_length = $($("tr>td.text-monospace")[1]).find('span').length;
for (var i = 1; i <= alignment_length; i++) {
var column = $('tr>td.text-monospace>span:nth-child(' + i + ')');
var all_gaps = 0;
for (var j = 2; j < show_up_to; j++) {
if (column[j].innerHTML.match(/\w/)) {
all_gaps = 0;
break;
}
all_gaps = 1;
}
if (all_gaps) {
column.hide();
} else {
column.show();
}
}
};
ralee_conservation = function(threshold){
reset_ralee_conservation();
// find visible rows
var show_up_to = null;
var table_rows = $("tr>.sequence");
table_rows.each(function(row_index) {
if ($(this).is(':visible')) {
show_up_to = row_index;
} else {
return false;
}
});
// analyse conservation
var alignment_length = $('.sequence').first().find('span').length;
// starting at 1 because nth-child is 1-based
for (var i = 1; i <= alignment_length; i++) {
var column = $('.sequence>span:nth-child(' + i + ')')
if (!$(column[0]).is(':visible')) {
continue;
}
var guanine = 1, adenine = 1, cytosine = 1, uracil = 1, other = 1;
for (var j = 0; j <= show_up_to; j++) {
var nt = column[j].innerHTML;
if (nt === 'G' || nt === 'g') {
guanine += 1;
} else if (nt === 'A' || nt === 'a') {
adenine += 1;
} else if (nt === 'C' || nt === 'c') {
cytosine += 1;
} else if (nt === 'U' || nt === 'u') {
uracil += 1;
} else {
other += 1;
}
}
adenine = adenine / (show_up_to - other);
cytosine = cytosine / (show_up_to - other);
guanine = guanine / (show_up_to - other);
uracil = uracil / (show_up_to - other);
var colours = {
adenine: (adenine >= 0.8) ? 'ralee_80' : (adenine >= 0.6) ? 'ralee_60' : (adenine >= 0.4) ? 'ralee_40' : null,
cytosine: (cytosine >= 0.8) ? 'ralee_80' : (cytosine >= 0.6) ? 'ralee_60' : (cytosine >= 0.4) ? 'ralee_40' : null,
guanine: (guanine >= 0.8) ? 'ralee_80' : (guanine >= 0.6) ? 'ralee_60' : (guanine >= 0.4) ? 'ralee_40' : null,
uracil: (uracil >= 0.8) ? 'ralee_80' : (uracil >= 0.6) ? 'ralee_60' : (uracil >= 0.4) ? 'ralee_40' : null,
}
var to_paint = '';
if (colours.adenine) {
to_paint += 'Aa';
}
if (colours.guanine) {
to_paint += 'Gg';
}
if (colours.cytosine) {
to_paint += 'Cc';
}
if (colours.uracil) {
to_paint = 'Uu';
}
for (var j = 0; j <= show_up_to; j++) {
var nt = column[j].innerHTML;
if (to_paint.indexOf(nt) === -1) {
continue;
}
if (nt === 'G' || nt === 'g') {
column[j].classList.add(colours.guanine);
} else if (nt === 'A' || nt === 'a') {
column[j].classList.add(colours.adenine);
} else if (nt === 'C' || nt === 'c') {
column[j].classList.add(colours.cytosine);
} else if (nt === 'U' || nt === 'u') {
column[j].classList.add(colours.uracil);
}
}
}
};
reset_ralee_conservation = function(){
$('span.ralee_80, span.ralee_60, span.ralee_40').removeClass('ralee_80 ralee_60 ralee_40');
}
$(function () {
$('[data-toggle="tooltip"]').tooltip()
$('#ga_threshold').on('change input', function() {
$('#ga-label').html($('#ga_threshold').val());
});
$('#set-threshold').on('click', function() {
var threshold = parseFloat($('#ga_threshold').val());
reset_ralee_conservation();
rfmake(threshold);
});
$('#reset-threshold').on('click', function() {
var threshold = 25;
reset_ralee_conservation();
rfmake(threshold);
$('#ga-label').html(threshold);
$('#ga_threshold').val(threshold);
});
$('#ralee-conservation').on('click', function() {
var threshold = parseFloat($('#ga_threshold').val());
ralee_conservation(threshold);
});
$('#reset-ralee-conservation').on('click', function() {
reset_ralee_conservation();
});
$('.bit_score').on('click', function(){
var threshold = $(this).html();
reset_ralee_conservation();
rfmake(parseFloat(threshold));
$('#ga-label').html(threshold);
$('#ga_threshold').val(threshold);
});
$('#toggle-columns').on('click', function(e) {
if ($('.uracil').length) {
$('.adenine').toggleClass("adenine adenine-inactive");
$('.guanine').toggleClass("guanine guanine-inactive");
$('.cytosine').toggleClass("cytosine cytosine-inactive");
$('.uracil').toggleClass("uracil uracil-inactive");
} else {
$('.adenine-inactive').toggleClass("adenine-inactive adenine");
$('.guanine-inactive').toggleClass("guanine-inactive guanine");
$('.cytosine-inactive').toggleClass("cytosine-inactive cytosine");
$('.uracil-inactive').toggleClass("uracil-inactive uracil");
}
e.preventDefault();
});
});
</script>
</body>
</html>