-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
968 lines (773 loc) · 34.4 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
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>WebQC, quality check of raw data files in genomics, transcriptomics, proteomics and metabolomics</title>
<script src="falco.js"></script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<link href="css/bootstrap.min.css" rel="stylesheet">
<script src="js/bootstrap.bundle.min.js"></script>
<style>
.area {
border-left: 1px solid #dee2e6;
# position: absolute;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
text-align: center;
}
.uploadarea {
border: 4px dashed rgb(45, 62, 80);
filter: alpha(opacity=50);
-khtml-opacity: 0.5;
-moz-opacity: 0.5;
opacity: 0.5;
height: 20vh;
background-image: url("./images/download.png");
background-position: center;
background-repeat: no-repeat;
background-size: 64px 64px;
}
.uploadarea:hover,
.uploadarea.dragging,
.uploadarea.uploading {
filter: alpha(opacity=100);
-khtml-opacity: 1;
-moz-opacity: 1;
opacity: 1;
}
.uploadarea input {
margin: auto;
width: 100%;
height: 100%;
# margin-left: -300%;
border: none;
cursor: pointer;
opacity: 0;
}
.uploadarea input:focus {
outline: none;
}
div.summary ul {
padding-left: 0;
list-style-type: none;
}
div.summary ul li img {
margin-bottom: -0.5em;
margin-top: 0.5em;
}
dl, ol, ul {
margin-top: 0.8em;
/* margin-bottom: 1rem; */
}
div.main {
background-color: white;
}
div.module {
padding-bottom: 1em;
padding-top: 1em;
border-bottom: 1px solid rgb(45, 62, 80)
}
div.footer {
background-color: #EEE;
border: 0;
margin: 0;
padding: 0.5em;
font-size: 100%;
width: 100%;
}
h2 {
font: 1em monospace;
color: #2a5e8c;
padding-bottom: 0;
margin-bottom: 0;
clear: left;
}
table {
margin: auto;
text-align: center;
}
th {
text-align: center;
background-color: #000080;
color: #FFF;
padding: 0.4em;
}
td {
font-family: monospace;
text-align: left;
background-color: #EEE;
color: #000;
padding: 0.4em;
}
img {
padding-top: 0;
margin-top: 0;
border-top: 0;
}
.nav-link{
color:white;
}
.nav .nav-link:hover {
color:black;
background-color: white;
}
p {
padding-top: 0;
margin-top: 0;
}
.pass {
color: #009900;
}
.warn {
color: #999900;
}
.fail {
color: #990000;
}
</style>
</head>
<body>
<div class="" style="height: 100vh; width:100vw; overflow-x: hidden; overflow-y: hidden;">
<div class="navbar navbar-expand-lg " style="background: rgb(45, 62, 80); height:3.25rem">
<div class="container-fluid" style="height:100%">
<a class="navbar-brand" href="https://nfdi4plants.org/">
<img src="images/logo.png" alt="Logo" width="32" height="32" style=" ">
</a>
<ul class="nav nav-tabs justify-content-center" id="TabMenu" role="tablist" style=" height:100%">
<li class="nav-item " role="presentation" >
<button class="nav-link px-3 active " id="WebQC" data-bs-toggle="tab" data-bs-target="#home" type="button"
role="tab" aria-controls="home" aria-selected="true">Comparison</button>
</li>
</ul>
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">github</a>
</li>
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="#">Home</a>
</li>
</ul>
</div>
</div>
<div class="row tab-content" id="TabContent" style="height:calc(100vh - 3.5rem )">
<div class="tab-pane fade active show" id="home" role="tabpanel" aria-labelledby="home_tab">
<div class="row" style="height:calc(100vh - 3.5rem )">
<div class="col-sm-2 " style="padding : 1rem;">
</div>
<div class="col-sm-8" id="multiQC" style="padding: 0px ;height:calc(100vh - 3.5rem ); overflow-y: scroll;">
<div>
<br>
<h1>
🧬 Quality control on raw data</h1> <br>
<h3>Load your files or <a href="./test_data/SRR10124060.fastq"
>use prepared samples</a> to start,
<br> nothing leaves your browser and local computer.</h3>
</div>
<div class=" area uploadarea " id="importArea"
ondragenter="this.className='area uploadarea dragging'"
ondrop=";DragAndDrop(event)" style="margin:auto; height:20%">
<input type="file" onchange="onFiles(this.files)" id="import" multiple>
</div>
<div class="text-start btn-group" id="sum" style="margin:auto; ">
<div class="dropdown">
<a class="btn btn-secondary dropdown-toggle" href="#" role="button" id="fileDropDown" data-bs-toggle="dropdown" aria-expanded="false">
File(s)
</a>
<ul class="dropdown-menu" id="fileList" aria-labelledby="fileDropDown">
</ul>
</div>
<br>
<div class="dropdown">
<a class="btn btn-primary dropdown-toggle" href="#" role="button" id="genomicsDropDown" data-bs-toggle="dropdown" aria-expanded="false">
ENA Data File
</a>
<ul class="dropdown-menu" id="genomicsList" aria-labelledby="genomicsDropDown">
</ul>
</div>
<br>
<div class="dropdown">
<a class="btn btn-success dropdown-toggle" href="#" role="button" id="transcriptomicsDropDown" data-bs-toggle="dropdown" aria-expanded="false">
GEO Data File
</a>
<ul class="dropdown-menu" id="transcriptomicsList" aria-labelledby="transcriptomicsDropDown">
</ul>
</div>
<br>
<div class="dropdown">
<a class="btn btn-warning dropdown-toggle" href="#" role="button" id="metabolomicsDropDown" data-bs-toggle="dropdown" aria-expanded="false">
Metabolight Data Files
</a>
<ul class="dropdown-menu" id="metabolomicsList" aria-labelledby="metabolomicsDropDown">
</ul>
</div>
<br>
<div class="dropdown">
<a class="btn btn-info dropdown-toggle" href="#" role="button" id="proteomicsDropDown" data-bs-toggle="dropdown" aria-expanded="false">
PRIDE Data Files
</a>
<ul class="dropdown-menu" id="proteomicsList" aria-labelledby="proteomicsDropDown">
</ul>
</div>
</div>
<div class="text-start" id="download" style="margin:auto; ">
</div>
<div class="module">
<h2 class="" id="spider"> Summary Radar
</h2>
<div id="spiderf"></div>
</div>
<div class="module">
<h2 class="" id="p1m"> Phred Score Average
</h2>
<div id="p1f"></div>
</div>
<div class="module">
<h2 class="" id="p2m"> Per Sequence Quality
</h2>
<div id="p2f"></div>
</div>
<div class="module">
<h2 class="" id="p3m"> GC Content
</h2>
<div id="p3f"></div>
</div>
<div class="module">
<h2 class="" id="p4m"> Per Base N Content
</h2>
<div id="p4f"></div>
</div>
<div class="module">
<h2 class="" id="p5m"> Per Base Sequence Content
</h2>
<div id="p5f"></div>
</div>
<div class="module">
<h2 class="" id="p6m"> Sequence Length Distribution
</h2>
<div id="p6f"></div>
</div>
<div class="module">
<h2 class="" id="p7m">
</h2>
<div id="p7f"></div>
</div>
<div>
<pre class="console" id="console"
style="position: fixed; background-color: #fff; opacity: 70%; font-size: 9px;
bottom: 0; height:10%; width: 67%; border: #2a5e8c ; border-width: 1px;
text-align: left; "> Console output
</pre>
</div>
</div>
<div class="col-sm-2 align-self-center" style="margin-left: 0px; padding :0px;">
</div>
</div>
</div>
</div>
<!-- Button trigger modal -->
<button type="button" id="modalButton" class="btn btn-primary d-none" data-bs-toggle="modal" data-bs-target="#runningModal">
Launch static backdrop modal
</button>
<!-- Modal -->
<div class="modal" id="runningModal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="staticBackdropLabel">Quality Control is Running</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<div class="spinner-border" role="status">
<span class="visually-hidden">Loading...</span>
</div>
<span id="fileInfo"></span>
</div>
<div class="modal-footer">
</div>
</div>
</div>
</div>
</div>
<script>
var total_qc = 0;
var figure_1 = [];
var figure_2 = [];
var figure_3 = [];
var figure_4 = [];
var figure_5 = [];
var figure_6 = [];
var figure_7 = [];
var all_figures = [figure_1, figure_2,figure_3, figure_4,figure_5, figure_6, figure_7];
var dbg;
var raw_data_json;
var folders = {files: [], folders: []};
var gFiles = [];
const D3Colors = [
'#1f77b4',
'#ff7f0e',
'#2ca02c',
'#d62728',
'#9467bd',
'#8c564b',
'#e377c2',
'#7f7f7f',
'#bcbd22',
'#17becf'
];
const repoList = {
"genomics": "ENA",
"transcriptomics": "GEO",
"metabolomics": "Metabolight",
"proteomics": "PRIDE",
};
var rawExt;
var omicsList;
fetch("./js/name_list.json")
.then(res => res.json())
.then(data => {raw_data_json = JSON.parse(JSON.stringify(data));
rawExt = raw_data_json["extension_ident"]; omicsList = raw_data_json["omics"]})
var runningModal = new bootstrap.Modal(document.getElementById('runningModal'));
function err(text) {
document.getElementById("console").innerHTML += text + "<br>";
}
var handleException = (e) => {
if (e instanceof ExitStatus || e == "unwind") {
return EXITSTATUS;
};
alert("An error has occured, please refresh the webpage, check your files and try again");
document.getElementById("fileInfo").outerHTML = "<button class='btn btn-danger' onclick='location.reload()'> ERROR, please refresh </button>";
quit_(1, e);
};
//console.log(txt);
function tsvJSON(txt){
var lines=txt.split("\n");
var result = {};
var headers=lines[0].split("\t");
for(var k=0;k<headers.length;k++){
result[headers[k]]= [];
}
for(var i=1;i<lines.length;i++){
var currentline=lines[i].split("\t");
for(var j=0;j<headers.length;j++){
result[headers[j]].push( currentline[j]);
}
}
//return result; //JavaScript object
return JSON.stringify(result); //JSON
}
function mqc(txt, fileName, textStart, textEnd, plotName, x, y, xLabel, yLabel, figType, nFig=0, d1="G", d2="A", d3="T", d4="C"){
const pass_txt = txt.match(textStart+"\t(....)\n#")[1];
const p1_txt = txt.match(textStart+"\t....\n#((.|\n)*?)"+ textEnd);
const dict_color = {
"pass" : "green",
"warn" : "orange",
"fail" : "red"
}
const text_color = dict_color[pass_txt];
if (p1_txt !=null){
let p1_data = JSON.parse(tsvJSON(p1_txt[1]));
const color_i = (total_qc % 10)+1;
const color_name = D3Colors[color_i];
let p1_fig = {x : p1_data[x],
y : p1_data[y],
type : figType,
name : '<span style="color:'+text_color+'">'+fileName+'</span>',
line : { color :color_name},
textfont: {
family: 'sans serif',
size: 18,
color: text_color
},
};
all_figures[nFig].push(p1_fig);
//console.log(all_figure);
return [plotName,
all_figures[nFig],
{
margin: { t: 0 },
showlegend: true,
xaxis : {title : xLabel},
yaxis : {title : yLabel},
},
p1_data[d1],
p1_data[d2],
p1_data[d3],
p1_data[d4]
,
];
}else{
console.log(p1_txt )
}
}
function runFalco(file, fileN, fileindex) {
//fetch(file)
//.then((res) => res.text())
//.then((text) => {
let reader = new FileReader();
reader.onload = function () {
var data = new Uint8Array(reader.result);
const fileName = file.name.replace(" ", "-");
FS.writeFile(fileName, data);
const fileName1 = fileName.split(".")[0];
callMain([fileName]);
// ;
const summary = FS.readFile("summary.txt");
const textData = FS.readFile("fastqc_data.txt");
let txt = new TextDecoder().decode(textData);
const totalSeq= txt.match("\nTotal Sequences\t((.|)*?)\n" )[1];
console.log(total_qc);
const f1 = mqc(txt, fileName1, ">>Per base sequence quality",
"\n>>END_MODULE",
"p1f",
"Base",
"Mean",
"Base position" ,
"Phread quality" ,
"line",
0,
"Lower Quartile",
"Median"
);
const f2 = mqc(txt, fileName1, ">>Per sequence quality scores",
"\n>>END_MODULE",
"p2f",
"Quality",
"Count",
"Quality" ,
"Count" ,
"line",
1
);
const f3 = mqc(txt, fileName1, ">>Per sequence GC content",
"\n>>END_MODULE",
"p3f",
"GC Content",
"Count",
"GC Content" ,
"Count" ,
"line",
2
);
const f4 = mqc(txt, fileName1, ">>Per base N content",
"\n>>END_MODULE",
"p4f",
"Base",
"N-Count",
"Base" ,
"N-Count" ,
"line",
3
);
let f5 = mqc(txt, fileName1, ">>Per base sequence content",
"\n>>END_MODULE\n",
"p5f",
"Base",
"G",
"Base" ,
"Max A-T and G-T difference" ,
"line",
4,
"A",
"T",
"G",
"C"
);
const f6 = mqc(txt, fileName1, ">>Sequence Length Distribution",
"\n>>END_MODULE\n",
"p6f",
"Length",
"Count",
"Sequence length" ,
"Number of sequences" ,
"line",
5,
);
const color_i = (total_qc % 10)+1 ;
const color_name = D3Colors[color_i];
const perbase = [].map.call(f5[3], (el, i)=> { return Math.max(Math.abs(parseFloat(f5[3][i]) -parseFloat(f5[5][i])) , Math.abs( parseFloat(f5[4][i])- parseFloat(f5[6][i]))) }) ;
const abs1 = [].map.call(perbase, (ele, index)=>{return Math.abs(ele) });
const max = Math.max.apply(null, abs1);
f5[1][total_qc]["y"] = perbase;
const phred = f1[1][total_qc]["y"];
const calSum = list => list.reduce((a,b)=> parseFloat(a)+parseFloat(b),0);
const phredMean = calSum(phred)/phred.length/40*100
function calScore(arr, fail, warn ){
const list =[].map.call(arr, (el, index)=>{
if (fail(el)){
return 0 ;
}else if (warn(el)){
return 0.5;
}else {
return 1;
}
} );
return list;
}
const lower = f1[3];
const median = f1[4];
const lowerScore = calScore(lower, (x)=>{return x<5}, (x)=>{return x<10});
const medianScore = calScore(median, (x)=>{return x<20}, (x)=>{return x<25});
const final = [].map.call(lowerScore, (el, index)=> {return Math.min(el, medianScore[index]); } );
const final1 = calSum(final)/final.length*100;
const perSeqQx = f2[1][total_qc]["x"];
const perSeqQScore = calScore(perSeqQx, (x)=>{return x<20}, (x)=>{return x<27});
const perSeqQy = f2[1][total_qc]["y"];
const weightedPerSeqQ = [].map.call(perSeqQScore,(el, index)=> {return el*perSeqQy[index] } )
const final2 = calSum(weightedPerSeqQ)/totalSeq*100;
const perBaseSeqCon = calScore(perbase, (x)=>{return x>20}, (x)=>{return x>10});
const final3 = calSum(perBaseSeqCon)/perBaseSeqCon.length*100;
const perBaseGC = calScore(f3[1][total_qc]["y"], (x)=>{return x>10}, (x)=>{return x>5});
const final4 = calSum(perBaseGC)/perBaseGC.length*100;
const perBaseN = calScore(f4[1][total_qc]["y"], (x)=>{return x>20}, (x)=>{return x>5});
const final5 = calSum(perBaseN)/perBaseN.length*100;
const seqLength = Math.max.apply(null, f6[1][total_qc]["y"]);
const final6 = seqLength/totalSeq*100;
const c1 = f1[1][total_qc]["textfont"]["color"];
const c2 = f2[1][total_qc]["textfont"]["color"];
const c3 = f3[1][total_qc]["textfont"]["color"];
const c4 = f4[1][total_qc]["textfont"]["color"];
const c5 = f5[1][total_qc]["textfont"]["color"];
const c6 = f6[1][total_qc]["textfont"]["color"];
figure_7.push({
type: 'scatterpolar',
r: [ final1, final2 , final3, final4, final5, final6,],
theta: ['Per Base Sequence quality','Per Sequence Quality','Per Base Sequence Content', 'Per Base GC Content', 'Per Base N Content', 'Sequence Length'],
mode:"lines",
marker: {color: color_name,
line:{color: [c1,c2,c3,c4,c5,c6], width :3}},
mode: "lines+markers",
fill: "toself",
}) ;
const layout = {
polar: {
radialaxis: {
visible: true,
range: [0, 100]
}
},
showlegend: false
}
Plotly.newPlot( f1[0] , f1[1],f1[2],f1[3]
).then(() => {Plotly.react( f1[0],f1[1]
).then(() => {Plotly.react( f2[0],f2[1],f2[2],f2[3]
).then(() => {Plotly.react( f3[0],f3[1],f3[2],f3[3]
).then(()=> {Plotly.react( f4[0],f4[1],f4[2],f4[3]
).then(()=>{ Plotly.react( f5[0],f5[1],f5[2],f5[3]
).then(()=>{ Plotly.react( f6[0],f6[1],f6[2],f6[3]
).then(()=>{ Plotly.react( "spiderf", figure_7 ,layout )
});
});
});
});
});
});
});
//const con = new TextDecoder().decode(summary);
//document.getElementById("log").innerText = con;
const htmlRep = FS.readFile("fastqc_report.html");
const htmlDecode = new TextDecoder().decode(htmlRep);
var htmlEle = document.createElement('html');
htmlEle.innerHTML = htmlDecode;
//const styles = htmlEle.querySelectorAll("head")[0].querySelectorAll("style") ;
//[].map.call(styles, function(el) {return document.head.appendChild(el);});
//const links = htmlEle.querySelectorAll("head")[0].querySelectorAll("link");
//[].map.call(links, function (el) { return document.head.appendChild(el); });
const n = 10;//(imported.files.length + 3).toString();
let TabMenu = document.getElementById("TabMenu");
const tabMenuHTML = '<li class="nav-item " role="presentation" style=" width:calc(80vw /'+ n +')"><button class="nav-link " id="' + fileName1 +
'_tab" data-bs-toggle="tab" data-bs-target="#' + fileName1 +
'"type="button" role="tab" aria-controls="profile" aria-selected="false">' + fileName1 + '</button></li>';
TabMenu.innerHTML += tabMenuHTML;
let TabChildren = TabMenu.children;
[].map.call(TabChildren, (ele, index)=> {ele.setAttribute("style", "width:calc(80vw /"+ Math.max(8,TabChildren.length)+")" ) } )
const tabContentHTML = '<div class="tab-pane fade" id="' + fileName1 + '" role="tabpanel" aria-labelledby="' + fileName1 +
`_tab" > <div class=" col-sm-12 ">
<div class="row tab-content" style="height:calc(100vh - 3.5rem )">
<div class="col-sm-3 " style="padding : 2em;">
<div class="text-start" id="`+fileName1+
`_sum" style="margin:auto; ">
</div>
<div class="text-start" id="`+fileName1+
`_download" style="margin:auto; ">
</div>
</div>
<div class="col-sm-9 " id="`+fileName1+
`_content" style="height:calc(100vh - 3.5rem ); padding-left : 2em; padding-right : 0em">
</div>
</div>
</div>
</div > `;
document.getElementById("TabContent").innerHTML += tabContentHTML;
const sums = htmlEle.querySelectorAll("div.summary");
sums[0].style = "position: static; width: auto; top: 0em; margin: auto"
let sum = document.getElementById(fileName1 +"_sum");
sum.innerHTML = sums[0].innerHTML;
let htmlVis = document.getElementById(fileName1+"_content");
let main = htmlEle.querySelector("div.main");
main.style = "position: static; height : calc(100vh - 3.5rem); width : 100%; overflow-x: hidden;"
htmlVis.innerHTML = main.outerHTML;
const eleList = [[["basicstatistics"], ["null_string"]],
[["perbasesequencequality"], ["seqbasequalityboxplot"]],
[["pertilesequencequality"], ["tilequalityheatmap"]],
[["persequencequalityscores"], ["seqqualitylineplot"]],
[["perbasesequencecontent"], ["basesequencecontentlineplot"]],
[["persequencegccontent"], ["sequencegccontentlineplot"]],
[["perbasencontent"], ["basencontentlineplot"]],
[["sequencelengthdistribution"], ["sequencelengthdistributionlineplot"]],
[["sequenceduplicationlevels"], ["seqduplevelslineplot"]],
[["overrepresentedsequences"], ["null_string"]],
[["adaptercontent"], ["adapterlineplot"]]
];
[].map.call(eleList, function (el) {
let find_ele = document.querySelector('#' + el[0]);
if (find_ele != null) {
find_ele.setAttribute("id", fileName1 + "_" + el[0]);
let find_ele1 = document.querySelector('#' + el[1]);
try { find_ele1.setAttribute("id", fileName1 + "_" + el[1]); }
catch (err) { console.log(err) };
const a = document.querySelector("a[href='#" + el[0] + "']");
//console.log(a);
a.href = "#" + fileName1 + "_" + el[0];
}
});
//const headScripts = htmlEle.querySelectorAll("head")[0].querySelectorAll("script") ;
//[].map.call(headScripts, function(el) {return document.head.appendChild(el)});
const scripts = htmlEle.querySelectorAll("body")[0].querySelectorAll("script");
[].map.call(scripts, function (el) {
let a = el.innerHTML.replaceAll("document.getElementById('", "document.getElementById('" + fileName1 + "_");
let b = a.replaceAll("Plotly.newPlot('", "Plotly.newPlot('" + fileName1 + "_");
//console.log(b);
eval(b);
});
let dl_ele = document.getElementById(fileName1 +"_download");
dl_ele.innerHTML = "";
let d1 = document.createElement("a");
d1.className = "btn btn-xs";
d1.innerText = file.name + " Summary";
d1.download = file.name + "_summary.txt";
d1.href = URL.createObjectURL(new Blob([summary], { type: "application/octet-stream" }));
d1.id = "summaryButton";
dl_ele.append(d1);
let d2 = document.createElement("a");
d2.className = "btn btn-xs";
d2.innerText = file.name + " text Data";
d2.download = file.name + "factqc_data.txt";
d2.href = URL.createObjectURL(new Blob([textData], { type: "application/octet-stream" }));
d2.id = "dataButton";
dl_ele.append(d2);
let d3 = document.createElement("a");
d3.className = "btn btn-xs";
d3.innerText = file.name + " HTML report";
d3.download = file.name + "_report.html";
d3.href = URL.createObjectURL(new Blob([htmlRep], { type: "application/octet-stream" }));
d3.id = "htmlButton";
dl_ele.append(d3);
total_qc = total_qc +1;
//console.log(fileN+ " the file is " + fileindex)
const TabN = document.getElementById("TabMenu");
const ENAN = document.getElementById("genomicsList");
if ( TabN.childElementCount == ENAN.childElementCount+1 ){
runningModal.hide();
}else{}
};
reader.readAsArrayBuffer(file);
//})
}
function DragAndDrop(e) {
e.preventDefault();
var items = e.dataTransfer.items;
for (var i=0; i<items.length; i++) {
let firstI = i;
var item = items[i].webkitGetAsEntry(); //Might be renamed to GetAsEntry() in 2020
if (item) {
GetFileTree(item, folders);
}else {
}
};
}
function GetFileTree(item, SubFolder, path) {
path = path || "";
if (item.isFile) {
if (SubFolder["files"]===undefined) {
SubFolder["files"]=[];
SubFolder["files"][item.name] = {"size": "unknow", "path":item.fullPath }
} else{
SubFolder["files"][item.name] = {"size": "unknow", "path":item.fullpath };
}
item.file(function(file) {
onFile(file, 1, 0, SubFolder["files"], path);
//console.log(file);
});
} else if (item.isDirectory) {
if (SubFolder["folders"]===undefined) {
SubFolder["folders"]=[];
SubFolder["folders"][item.name] = {"size": "unknow" , "path":item.fullPath}
} else{
SubFolder["folders"][item.name] = {"size": "unknow" , "path":item.fullPath};
}
//console.log(item.name); //console.log(item.name)
// Get folder contents
var dirReader = item.createReader();
dirReader.readEntries(function(entries) {
for (var i=0; i<entries.length; i++) {
GetFileTree(entries[i], SubFolder["folders"][item.name], path + item.name + "/");
}
});
};
}
function onFile(file, fileN, fileindex, info, path) {
runningModal.show();
console.log("running modal showed");
info = info || folders["files"];
path = path || "/";
const extension = file.name.split(".").slice(-1)[0].toString();
const allExt = file.name.split(/[\s,\-_:.]+/);
gFiles.push({ name:file.name, lastExt:extension, allExt:allExt, size : file.size, "path":path });
info[file.name] = {size : file.size, "path":path};
name = file.name.replace(/.[^/.]+$/, '');
document.getElementById("importArea").setAttribute("style", "margin:auto; height:20%" );
document.getElementById("fileList").innerHTML += '<li><a class="dropdown-item" href="#">'+file.name+'</a></li>';
document.getElementById("fileDropDown").innerText = gFiles.length +" files are scanned";
//console.log('upload code goes here', file, name);
let rawExtList = [];
for (var key in rawExt){ rawExtList.push(rawExt[key]) ;
}
let omics = [];
console.log(rawExtList );
[].map.call(allExt, (ele, index)=> { let listIndex = rawExtList.map((e, i) => e === "."+ele ? i : '').filter( String ) ;
//console.log("." +ele );
//console.log(listIndex );
listIndex.length ==0 ? {} : [].map.call(listIndex, (ele, index) => { omics.push(omicsList[ele]) }) ;
})
//console.log("." +ele );
console.log(omics );
[].map.call(omics, (ele, index) => { const menuList = document.getElementById(ele +"List");
menuList.innerHTML += '<li><a class="dropdown-item" href="#">'+file.name+'</a></li>';
document.getElementById(ele +"DropDown").innerText = menuList.childElementCount + " potential " +repoList[ele]+ " Data File(s) " ;
});
if (extension === 'fastq' || extension === 'fasta' || extension === 'bam' || extension === 'gz') {
if (file.size < (39800000 * 1024)) {
//imported.parentNode.className = 'area uploading';
runFalco(file, fileN, fileindex);
} else {
window.alert('File size is too large, please ensure you are importing a file of less than 3.98GB');
}
} else {
err('file extension' + extension + ' is not supported, please fastq, bam, or gz files');
}
};
function onFiles(files) {
let fileN = files.length;
[].map.call(files, function (file, fileindex) {
onFile(file, fileN, fileindex);
//
} )
}
</script>
</body>
</html>