forked from ewels/sra-explorer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
773 lines (703 loc) · 48 KB
/
index.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
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
<!DOCTYPE html>
<html lang="en" ng-app="sraExplorerApp">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="An experimental interface for exploring the Sequence Read Archive">
<meta name="author" content="Phil Ewels">
<title>SRA Explorer</title>
<!-- Framework CSS -->
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
<!-- SRA-explorer styles -->
<style type="text/css">
/* Core structural setup */
body {
padding-top: 50px;
}
/* Styles for little clear button on search fields */
.form-control-clear, .form-control-clear:hover, .form-control-clear:focus, .form-control-clear:active {
pointer-events: auto;
text-decoration: none;
cursor: pointer;
color: #999;
z-index: 4;
}
.form-control-clear:hover, .form-control-clear:focus, .form-control-clear:active {
color: #666;
}
/* Make button links have proper styling */
a[ng-click]{
cursor: pointer;
}
/* Page Header */
.jumbotron {
margin-top: 30px;
}
.jumbotron h1 {
margin-top: 0;
}
.jumbotron h1 a {
color: #333;
text-decoration: none;
}
/* Saved datasets */
#savedDatasets pre {
overflow-x: auto;
}
#savedDatasets pre code {
font-size: 10px;
white-space: pre;
}
</style>
<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body ng-controller="searchCtrl">
<div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<a class="navbar-brand" href="#" ng-click="returnToHomeButton()">SRA-Explorer</a>
<a href="#" class="btn navbar-btn" style="float:right;" ng-class="savedResults.length == 0 ? 'disabled btn-default' : 'btn-primary'" ng-click="checkoutButton()"><span class="glyphicon glyphicon-shopping-cart"></span> <span ng-bind="savedResults.length"></span> saved datasets</a>
</div>
</div>
<div class="container">
<div class="jumbotron">
<h1><a href="#" ng-click="returnToHomeButton()">SRA Explorer</a></h1>
<p>This tool aims to make datasets within the Sequence Read Archive more accessible.</p>
<form class="form-horizontal" role="search">
<div class="form-group form-group-lg">
<label class="col-sm-2 control-label" for="searchText">Search for:</label>
<div class="col-sm-10">
<div class="input-group">
<div class="has-feedback has-clear">
<input ng-model="searchText" id="searchText" type="text" class="form-control" placeholder="Enter accession number" required>
<a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" ng-click="searchText = ''" ng-show="searchText.length"></a>
</div>
<div class="input-group-btn">
<button ng_click="search()" class="btn btn-default btn-lg" type="submit"><span class="glyphicon glyphicon-search"></span></button>
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label" for="maxResults">Max Results</label>
<div class="col-sm-2">
<input type="number" max="500" class="form-control" id="maxResults" ng-model="maxResults" value="100" required>
</div>
<label class="col-sm-2 control-label" for="retstart">Start At Record</label>
<div class="col-sm-2">
<input type="number" class="form-control" id="retstart" ng-model="retstart" value="0" required>
</div>
</div>
<span id="helpBlock" class="help-block">
Need inspiration? Try
<code ng-click="searchText='GSE30567'; search()" style="cursor:pointer;">GSE30567</code>,
<code ng-click="searchText='SRP043510'; search()" style="cursor:pointer;">SRP043510</code>,
<code ng-click="searchText='PRJEB8073'; search()" style="cursor:pointer;">PRJEB8073</code>,
<code ng-click="searchText='ERP009109'; search()" style="cursor:pointer;">ERP009109</code> or
<code ng-click="searchText='human liver miRNA'; search()" style="cursor:pointer;">human liver miRNA</code>.
</span>
</form>
</div>
<div class="alert alert-info" ng-show="savedResults.length > 0 && results.length == 0 && !showSaved">
You have {{ savedResults.length }} datasets in your collection.
<a href="#" ng-click="checkoutButton()">View saved datasets</a>.
</div>
<p ng-show="loadingSpinner" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading..</p>
<div ng-show="results.length > 0">
<hr>
<div class="alert alert-info">
Select relevant datasets and click <em>add to collection</em>.
When you're finished, view all saved datasets with the button in the top right of the
page, where you can copy the SRA URLs.
</div>
<p>Showing <span ng-bind="filteredResults.length" class="badge"></span> results.</p>
<button class="pull-right btn btn-primary" ng-class="{disabled: selectedItems == 0}" ng-click="saveDatasets()">Add <span ng-bind="selectedItems">0</span> to collection</button>
<form class="form-inline" role="search">
<div class="form-group">
<label for="filterText">Filter results:</label>
<div class="input-group">
<div class="form-group has-feedback has-clear">
<input ng-model="filterText" id="filterText" type="text" class="form-control" placeholder="Enter search term">
<a class="glyphicon glyphicon-remove-sign form-control-feedback form-control-clear" ng-click="filterText = ''" ng-show="filterText.length"></a>
</div>
<div class="input-group-btn">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">All Fields <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li class="active"><a href="#">All Fields</a></li>
<li><a href="#">Title</a></li>
<li><a href="#">Accession</a></li>
<li><a href="#">Instrument</a></li>
</ul>
</div>
</div>
</div>
</form>
<hr>
<div class="table-responsive"><table class="table table-striped table-hover">
<thead>
<tr>
<th><input type="checkbox" ng-model="selectAll" ng-click="checkAll()"></th>
<th><a ng-click="sortType = 'title'; sortReverse = !sortReverse">
Title
<span ng-show="sortType == 'title' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'title' && sortReverse" class="fa fa-caret-up"></span>
</a></th>
<th><a ng-click="sortType = 'accession'; sortReverse = !sortReverse">
Accession
<span ng-show="sortType == 'accession' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'accession' && sortReverse" class="fa fa-caret-up"></span>
</a></th>
<th><a ng-click="sortType = 'platform'; sortReverse = !sortReverse">
Instrument
<span ng-show="sortType == 'platform' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'platform' && sortReverse" class="fa fa-caret-up"></span>
</a></th>
<th><a ng-click="sortType = 'total_bases'; sortReverse = !sortReverse">
Total Bases (Mb)
<span ng-show="sortType == 'total_bases' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'total_bases' && sortReverse" class="fa fa-caret-up"></span>
</a></th>
<th><a ng-click="sortType = 'createdate'; sortReverse = !sortReverse">
Date Created
<span ng-show="sortType == 'createdate' && !sortReverse" class="fa fa-caret-down"></span>
<span ng-show="sortType == 'createdate' && sortReverse" class="fa fa-caret-up"></span>
</a></th>
</tr>
</thead>
<tbody>
<tr ng-repeat="x in results | orderBy:sortType:sortReverse | filter:filterText as filteredResults" ng-click="rowClicked(x)" ng-class="{ success: x.selected }">
<td><input type="checkbox" ng-checked="x.selected" ng-click="toggleRow($event, x)"></td>
<td>{{ x.title }}</td>
<td><a href="https://www.ncbi.nlm.nih.gov/sra/?term={{ x.accession }}" target="_blank">{{ x.accession }}</a></td>
<td>{{ x.platform }}</td>
<td>{{ x.total_bases }}</td>
<td>{{ x.createdate | date:'dd MMM yyyy' }}</td>
</tr>
</tbody>
</table></div>
</div>
<!-- Saved datasets -->
<div id="savedDatasets" ng-show="showSaved" class="animate-show">
<h2>
<span ng-bind="savedResults.length"></span> Saved Datasets
<button ng-show="savedResults.length > 0" ng-click="returnSaved()" class="btn btn-default" style="float:right;">Remove all from collection and send to search results</button>
</h2>
<div>
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li class="active"><a href="#fastq_tabcontent" aria-controls="fastq_tabcontent" role="tab" data-toggle="tab">FastQ Downloads</a></li>
<li><a href="#sra_tabcontent" aria-controls="sra_tabcontent" role="tab" data-toggle="tab">SRA Downloads</a></li>
<li><a href="#full_metadata_tabcontent" aria-controls="full_metadata_tabcontent" role="tab" data-toggle="tab">Full Metadata</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane fade in active" id="fastq_tabcontent">
<div ng-show="savedResults.length > 0" class="panel-group" id="fastqAccordion" role="tablist" aria-multiselectable="true">
<p><br>To download FastQ files directly, sra-explorer queries the <a href="https://www.ebi.ac.uk/ena" target="_blank" rel="nofollow">ENA</a> for each SRA run accession number.</p>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fastqAccordion" href="#fastqURLs">Raw FastQ Download URLs</a>
</h4>
</div>
<div id="fastqURLs" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>The following is a list of links to download the selected SRA runs as FastQ from the ENA.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fastqURLs_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fastqURLs_content', 'sra_explorer_fastq_urls.txt')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fastqURLs_content"><code ng-repeat="x in savedResultsENAfastq">{{ x.fastq_url }}{{ nlChr }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fastqAccordion" href="#fastqURLs_bashCURL">Bash script for downloading FastQ files</a>
</h4>
</div>
<div id="fastqURLs_bashCURL" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>This list of bash <code>curl</code> commands to download each SRA run FastQ file from the ENA, and save with a nicer filename, with the cleaned dataset title appended.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fastqURLs_bashCURL_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fastqURLs_bashCURL_content', 'sra_explorer_fastq_download.sh')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fastqURLs_bashCURL_content"><code>#!/usr/bin/env bash</code><code ng-repeat="x in savedResultsENAfastq">{{ nlChr }}curl -L {{ x.fastq_url }} -o {{ x.fastq_niceFilename }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fastqAccordion" href="#fastqURLs_aspera">Aspera commands for downloading FastQ files</a>
</h4>
</div>
<div id="fastqURLs_aspera" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>This list of bash <code>ascp</code> commands to download each FastQ file from the ENA using the <a href="https://downloads.asperasoft.com/en/downloads/8?list" target="_blank" rel="nofollow">Aspera download tool</a>.</p>
<form class="form-horizontal">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">ascp openssh key path</label>
<div class="col-sm-10">
<div class="input-group">
<input type="text" class="form-control" id="ascp_openssh_location" ng-model="ascp_openssh_location">
<span class="input-group-btn">
<button class="btn btn-default" type="button" ng-click="set_ascp_openssh_location('linux')"><i class="fa fa-linux" aria-hidden="true"></i> Linux</button>
<button class="btn btn-default" type="button" ng-click="set_ascp_openssh_location('osx')"><i class="fa fa-apple" aria-hidden="true"></i> OSX</button>
</span>
</div>
</div>
</div>
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Rename files?</label>
<div class="col-sm-10">
<label class="radio-inline">
<input type="radio" ng-model="ascp_append_mv" ng-value="true"> Append <code>mv</code> command to rename downloaded files
</label>
<label class="radio-inline">
<input type="radio" ng-model="ascp_append_mv" ng-value="false"> Don't rename files
</label>
</div>
</div>
</form>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fastqURLs_aspera_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fastqURLs_aspera_content', 'sra_explorer_fastq_aspera_download.sh')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fastqURLs_aspera_content"><code>#!/usr/bin/env bash</code><code ng-repeat="x in savedResultsENAfastq">{{ nlChr }}ascp -QT -l 300m -P33001 -i {{ ascp_openssh_location }} {{ x.fastq_asperaurl }} .<span ng-show="ascp_append_mv"> && mv {{ x.fastq_filename }} {{ x.fastq_niceFilename }}</span></code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fastqAccordion" href="#fastqURLs_niceNames">Cluster Flow FastQ download file (nice filenames)</a>
</h4>
</div>
<div id="fastqURLs_niceNames" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>This list of URLs is followed by a nicer filename, with the cleaned dataset title appended. This is suitable for use with the <a href="http://clusterflow.io" target="_blank">Cluster Flow</a> <code>--file_list</code> download option.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fastqURLs_niceNames_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fastqURLs_niceNames_content', 'sra_explorer_fastq_nicenames.txt')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fastqURLs_niceNames_content"><code ng-repeat="x in savedResultsENAfastq">{{ x.fastq_url }}{{ tabChr }}{{ x.fastq_niceFilename }}{{ nlChr }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fastqAccordion" href="#fastqURLs_bcbio">bcbio project file for FastQ downloads (nice filenames)</a>
</h4>
</div>
<div id="fastqURLs_bcbio" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>This list of URLs is followed by a nicer filename. This is suitable for use with <a href="https://bcbio-nextgen.readthedocs.io/en/latest/" target="_blank">bcbio-nextgen</a> analysis pipelines.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fastqURLs_bcbio_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fastqURLs_bcbio_content', 'sra_explorer_bcbio.txt')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fastqURLs_bcbio_content"><code>samplename,description</code><code ng-repeat="x in savedResultsENAfastq">{{ nlChr }}{{ x.fastq_url }},{{ x.fastq_niceFilename }}</code></pre>
</div>
</div>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="sra_tabcontent">
<div ng-show="savedResults.length > 0" class="panel-group" id="sraAccordion" role="tablist" aria-multiselectable="true">
<p><br>These download links are automatically generated based on the URL schema of the NCBI SRA.</p>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#sraAccordion" href="#ftpURLs">Raw SRA Download URLs</a>
</h4>
</div>
<div id="ftpURLs" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>The following is a list of links to download the selected SRA files.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#ftpURLs_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#ftpURLs_content', 'sra_explorer_sra_urls.txt')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<pre id="ftpURLs_content"><code ng-repeat="x in savedResults">{{ x.sra_url }}{{ nlChr }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#sraAccordion" href="#ftpURLs_bashCURL">
Bash script for downloading SRA files (nice filenames)
</a>
</h4>
</div>
<div id="ftpURLs_bashCURL" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>This list of bash <code>curl</code> commands to download each SRA file and save with a nicer filename, with the cleaned dataset title appended.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#ftpURLs_bashCURL_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#ftpURLs_bashCURL_content', 'sra_explorer_sra_download.sh')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<pre id="ftpURLs_bashCURL_content"><code>#!/usr/bin/env bash</code><code ng-repeat="x in savedResults">{{ nlChr }}curl -L {{ x.sra_url }} -o {{ x.sra_niceFilename }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#sraAccordion" href="#ftpURLs_niceNames">
Cluster Flow SRA download file (nice filename)
</a>
</h4>
</div>
<div id="ftpURLs_niceNames" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>This list of URLs is followed by a nicer filename, with the cleaned dataset title appended. This is suitable for use with the <a href="http://clusterflow.io" target="_blank">Cluster Flow</a> <code>--file_list</code> download option.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#ftpURLs_niceNames_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#ftpURLs_niceNames_content', 'sra_explorer_sra_nicenames.txt')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<pre id="ftpURLs_niceNames_content"><code ng-repeat="x in savedResults">{{ x.sra_url }}{{ tabChr }}{{ x.sra_niceFilename }}{{ nlChr }}</code></pre>
</div>
</div>
</div>
</div>
</div>
<div role="tabpanel" class="tab-pane fade" id="full_metadata_tabcontent">
<div ng-show="savedResults.length > 0" class="panel-group" id="fullMetaAccordion" role="tablist" aria-multiselectable="true">
<p><br>These files contain the metadata used by SRA-Explorer for downstream use. Note that each SRA record is repeated for every ENA FastQ entry.</p>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fullMetaAccordion" href="#fullTSV">TSV</a>
</h4>
</div>
<div id="fullTSV" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>The following is a TSV (tab separated values) file with all metadata fields for the selected samples.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fullTSV_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fullTSV_content', 'sra_explorer_metadata.tsv')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fullTSV_content"><code>Accession{{ tabChr }}Title{{ tabChr }}Platform{{ tabChr }}Total bases{{ tabChr }}Create date{{ tabChr }}SRA URL{{ tabChr }}SRA filename{{ tabChr }}SRA nice filename{{ tabChr }}FastQ URL{{ tabChr }}FastQ Aspera URL{{ tabChr }}FastQ filename{{ tabChr }}FastQ nice filename</code><code ng-repeat="x in savedResultsENAfastq">{{ nlChr }}{{ x.accession }}{{ tabChr }}{{ x.title }}{{ tabChr }}{{ x.platform }}{{ tabChr }}{{ x.total_bases }}{{ tabChr }}{{ x.createdate }}{{ tabChr }}{{ x.sra_url }}{{ tabChr }}{{ x.accession }}.sra{{ tabChr }}{{ x.sra_niceFilename }}{{ tabChr }}{{ x.fastq_url }}{{ tabChr }}{{ x.fastq_asperaurl }}{{ tabChr }}{{ x.fastq_filename }}{{ tabChr }}{{ x.fastq_niceFilename }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fullMetaAccordion" href="#fullJSON">JSON</a>
</h4>
</div>
<div id="fullJSON" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>The following is a JSON file with all metadata fields for the selected samples.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fullJSON_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fullJSON_content', 'sra_explorer_metadata.json')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fullJSON_content"><code>{{ savedResultsENAfastq | json }}</code></pre>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading" role="tab">
<h4 class="panel-title">
<a role="button" data-toggle="collapse" data-parent="#fullMetaAccordion" href="#fullYAML">YAML</a>
</h4>
</div>
<div id="fullYAML" class="panel-collapse collapse" role="tabpanel">
<div class="panel-body">
<p>The following is a YAML file with all metadata fields for the selected samples.</p>
<p>
<button class="btn btn-sm btn-default btn-copy" data-clipboard-target="#fullYAML_content"><span class="glyphicon glyphicon-copy"></span> Copy</button>
<button class="btn btn-sm btn-default btn-download" ng-click="download_contents('#fullYAML_content', 'sra_explorer_metadata.yaml')"><span class="glyphicon glyphicon-download-alt"></span> Download</button>
</p>
<p ng-show="savedResultsENAaccessions.length < savedResults.length" class="text-center"><span class="glyphicon glyphicon-refresh fa-spin"></span> Loading <span class="badge"><span ng-bind="savedResultsENAaccessions.length"></span> / <span ng-bind="savedResults.length"></span></span>..</p>
<pre ng-show="savedResultsENAfastq.length > 0" id="fullYAML_content"><code>{{ savedResultsENAfastqYAML }}</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<p ng-show="summaryURL">Query URL = <code ng-bind="summaryURL"></code></p>
</div><!-- /.container -->
<hr>
<div class="container footer text-muted">
<p>SRA-Explorer was written by <a href="http://phil.ewels.co.uk">Phil Ewels</a>. Source code is available under a GNU GPLv3 licence at <a href="https://github.com/ewels/sra-explorer">https://github.com/ewels/sra-explorer</a>.</p>
</div>
<hr>
<!-- Core JavaScript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.9/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.10/clipboard.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/js-yaml/3.12.2/js-yaml.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/1.3.8/FileSaver.js"></script>
<!-- SRA-Explorer Code -->
<script type="text/javascript">
var app = angular.module("sraExplorerApp", []);
app.controller("searchCtrl", function($scope, $http) {
$scope.searchText = "";
$scope.maxResults = 100;
$scope.retstart = 0;
$scope.summaryURL = 0;
$scope.loadingSpinner = 0;
$scope.sortType = '';
$scope.results = [];
$scope.savedResults = [];
$scope.savedResultsENAaccessions = [];
$scope.savedResultsENAfastq = [];
$scope.savedResultsENAfastqYAML = '';
$scope.showSaved = false;
$scope.tabChr = "\t";
$scope.nlChr = "\n";
$scope.ascp_openssh_location = '$HOME/.aspera/connect/etc/asperaweb_id_dsa.openssh';
$scope.ascp_append_mv = true;
$scope.search = function() { searchSRA($scope.searchText); };
/* Search Function */
function searchSRA (string) {
$scope.showSaved = false;
$scope.loadingSpinner = 1;
$scope.results = [];
var searchURL = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi?db=sra&usehistory=y&retmode=json&term='+string;
$http.get(searchURL).success(function(s_response) {
if(s_response.esearchresult.querytranslation){
$scope.searchText = s_response.esearchresult.querytranslation;
}
var webenv = s_response.esearchresult.webenv;
var querykey = s_response.esearchresult.querykey;
var retmax = $scope.maxResults;
var retstart = $scope.retstart;
var resultsURL = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi?db=sra&retmode=json&query_key='+querykey+'&WebEnv='+webenv+'&retstart='+retstart+'&retmax='+retmax;
$scope.summaryURL = resultsURL;
$http.get(resultsURL).success(function(response) {
$scope.loadingSpinner = 0;
// Parse the stupid embedded XML
angular.forEach(response.result, function(value, key) {
// Exp XML
expXMLraw = '<document>'+value.expxml+'</document>';
parser = new DOMParser();
expXML = parser.parseFromString(expXMLraw,"text/xml");
expJSON = xmlToJson(expXML);
if(expJSON.document.Summary){
exp = expJSON.document.Summary;
value.expxml = exp;
}
// Runs
runsXMLraw = '<document>'+value.runs+'</document>';
parser = new DOMParser();
runsXML = parser.parseFromString(runsXMLraw,"text/xml");
runsJSON = xmlToJson(runsXML);
if(runsJSON.document.Run){
value.runs = runsJSON.document.Run;
// If only one SRR, make it an array
if(!Array.isArray(value.runs)){
value.runs = [value.runs];
}
// Loop through each run result
for(var i = 0; i < value.runs.length; i++){
// Add results to scope
try {
var sra_cleanTitle = value.expxml.Title.text.replace(/[^a-z0-9\._\-]/gi, '_').replace(/_+/g, '_');
$scope.results.push({
'title': value.expxml.Title.text,
'accession': value.runs[i].attributes.acc,
'platform': value.expxml.Platform.attributes.instrument_model,
'total_bases': Math.round(value.runs[i].attributes.total_bases / 100000),
'createdate': Date.parse(value.createdate),
'cleanTitle': sra_cleanTitle,
'sra_url': "ftp://ftp-trace.ncbi.nlm.nih.gov/sra/sra-instant/reads/ByRun/sra/"+value.runs[i].attributes.acc.substring(0,3)+"/"+value.runs[i].attributes.acc.substring(0,6)+"/"+value.runs[i].attributes.acc+"/"+value.runs[i].attributes.acc+".sra",
'sra_niceFilename': value.runs[i].attributes.acc+'_'+sra_cleanTitle+'.sra'
});
} catch(e){
console.log(e);
console.log({key: value});
}
};
}
});
// console.log(response.result);
});
});
}
// Toggle row selection checkboxes
$scope.toggleRow = function($event, obj) {
$event.stopPropagation();
obj.selected = !obj.selected;
}
$scope.rowClicked = function(obj) {
obj.selected = !obj.selected;
};
$scope.checkAll = function () {
angular.forEach($scope.filteredResults, function (item) {
item.selected = $scope.selectAll;
});
};
$scope.$watch('filteredResults', function(items){
var selectedItems = 0;
angular.forEach(items, function(item){
selectedItems += item.selected ? 1 : 0;
});
$scope.selectedItems = selectedItems;
}, true);
// Save datasets
$scope.saveDatasets = function() {
angular.forEach($scope.filteredResults, function(item){
if(item.selected){
var alreadyAdded = false;
for (i=0; i<$scope.savedResults.length; i++){
if (item['accession'] == $scope.savedResults[i]['accession']){
alreadyAdded = true;
}
}
if(!alreadyAdded){
$scope.savedResults.push( angular.copy(item) );
}
}
});
};
// Show saved datasets
$scope.checkoutButton = function(){
// Clear search results and show saved
$scope.results = [];
$scope.summaryURL = 0;
$scope.loadingSpinner = 0;
$scope.showSaved = true;
$scope.fetchFastqENA();
}
// Show saved datasets
$scope.returnToHomeButton = function(){
// Clear search results and hide results again
$scope.showSaved = false;
$scope.results = [];
$scope.searchText = '';
}
// Send saved datasets back to table
$scope.returnSaved = function() {
// Clear search results and show saved
$scope.results = angular.copy( $scope.savedResults );
$scope.savedResults = [];
$scope.showSaved = false;
}
// Send saved datasets back to table
$scope.fetchFastqENA = function() {
if($scope.savedResultsENAaccessions.length < $scope.savedResults.length){
angular.forEach($scope.savedResults, function(value, key) {
if($scope.savedResultsENAaccessions.indexOf(value['accession']) === -1){
var ENAsearchURL = 'https://www.ebi.ac.uk/ena/portal/api/filereport?result=read_run&fields=fastq_ftp&format=JSON&accession='+value['accession'];
$http.get(ENAsearchURL).success(function(s_response) {
for (var i = 0; i < s_response.length; i++) {
var ftpFastQ = s_response[i]["fastq_ftp"];
if (ftpFastQ != undefined) {
// Paired-end FastQ files are given as a single result, need to split by ; character
var ftpFastQ_urls = ftpFastQ.split(';');
for(var j = 0; j < ftpFastQ_urls.length; j++){
// Save the accession now that we have some download filenames, so we know that this worked
if($scope.savedResultsENAaccessions.indexOf(value['accession']) === -1){
$scope.savedResultsENAaccessions.push(value['accession']);
}
var fname = ftpFastQ_urls[j].substring(ftpFastQ_urls[j].lastIndexOf('/')+1);
$scope.savedResultsENAfastq.push({
// Original SRA data
'title': value['title'],
'accession': value['accession'],
'cleanTitle': value['cleanTitle'],
'platform': value['platform'],
'total_bases': value['total_bases'],
'createdate': value['createdate'],
'sra_url': value['sra_url'],
'sra_niceFilename': value['sra_niceFilename'],
// New FastQ fields
'fastq_url': 'ftp://'+ftpFastQ_urls[j],
'fastq_asperaurl': ftpFastQ_urls[j].replace('ftp.sra.ebi.ac.uk/', '[email protected]:'),
'fastq_filename': fname,
'fastq_niceFilename': value['accession']+'_'+value['cleanTitle']+fname.replace(value['accession'], '')
});
$scope.savedResultsENAfastqYAML = jsyaml.safeDump($scope.savedResultsENAfastq);
}
}
}
});
}
});
}
}
// Customise the ascp openssh location with buttons
$scope.set_ascp_openssh_location = function(loc){
if(loc == 'linux'){
$scope.ascp_openssh_location = '$HOME/.aspera/connect/etc/asperaweb_id_dsa.openssh';
}
if(loc == 'osx'){
$scope.ascp_openssh_location = '$HOME/Applications/Aspera\\ Connect.app/Contents/Resources/asperaweb_id_dsa.openssh';
}
}
// Download contents as a file
$scope.download_contents = function(target, filename){
var content = $(target).text();
var blob = new Blob([content], { type: "text/plain;charset=utf-8" });
saveAs(blob, filename);
}
});
// Stolen frmo http://davidwalsh.name/convert-xml-json
// Changes XML to JSON
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
if (xml.attributes.length > 0) {
obj["attributes"] = {};
for (var j = 0; j < xml.attributes.length; j++) {
var attribute = xml.attributes.item(j);
obj["attributes"][attribute.nodeName] = attribute.value;
}
}
} else if (xml.nodeType == 3) { // text
obj = xml.nodeValue;
}
// do children
if (xml.hasChildNodes()) {
for(var i = 0; i < xml.childNodes.length; i++) {
var item = xml.childNodes.item(i);
var nodeName = item.nodeName.replace('#','');
if (typeof(obj[nodeName]) == "undefined") {
obj[nodeName] = xmlToJson(item);
} else {
if (typeof(obj[nodeName].push) == "undefined") {
var old = obj[nodeName];
obj[nodeName] = [];
obj[nodeName].push(old);
}
obj[nodeName].push(xmlToJson(item));
}
}
}
return obj;
};
// Activate the copy buttons
new Clipboard('.btn-copy');
</script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-51481908-2', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>