-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatasetExplorer.js
executable file
·4154 lines (3779 loc) · 132 KB
/
datasetExplorer.js
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
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
function disableL3(exportButton) {
console.error("Disabling everything now");
Ext.getCmp('filterButton').disable();
Ext.getCmp('chrButton').disable();
if (exportButton) {
Ext.getCmp('excelButton').disable();
Ext.getCmp('mutationButton').disable();
}
}
function enableL3(exportButton) {
console.error("Enabling everything now");
Ext.getCmp('filterButton').enable();
Ext.getCmp('chrButton').enable();
if (exportButton) {
Ext.getCmp('excelButton').enable();
Ext.getCmp('mutationButton').enable();
}
}
String.prototype.trim = function() {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
Ext.layout.BorderLayout.Region.prototype.getCollapsedEl = Ext.layout.BorderLayout.Region.prototype.getCollapsedEl.createSequence(function () {
if ((this.position === 'north' || this.position === 'south') && !this.collapsedEl.titleEl) {
this.collapsedEl.titleEl = this.collapsedEl.createChild({
style: 'color:#15428b;font:11px/15px tahoma,arial,verdana,sans-serif;padding:2px 5px;',
cn: this.panel.title
});
}
});
var runner = new Ext.util.TaskRunner();
var wfsWindow = null;
function dataSelectionCheckboxChanged(ctl) {
if (getSelected(ctl)[0] !== undefined) {
Ext.getCmp("exportStepDataSelectionNextButton").enable();
}
}
function setDataAssociationAvailableFlag(el, success, response, options) {
if (!success) {
var dataAssociationPanel = Ext.getCmp('dataAssociationPanel');
var resultsTabPanel = Ext.getCmp('resultsTabPanel');
resultsTabPanel.remove(dataAssociationPanel);
resultsTabPanel.doLayout();
} else {
Ext.Ajax.request({
url: pageInfo.basePath+"/dataAssociation/loadScripts",
method: 'GET',
timeout: '600000',
params: Ext.urlEncode({}),
success: function (result, request) {
var exp = jQuery.parseJSON(result.responseText);
if (exp.success && exp.files.length > 0) {
loadScripts(exp.files);
}
},
failure: function (result, request) {
alert("Unable to process the export: " + result.responseText);
}
});
}
}
/**
* Load js and css dynamically
* @param scripts
*/
function loadScripts(scripts) {
// loop through script array
for (var i = 0, iLength = scripts.length; i < iLength; i++) {
var file = scripts[i];
if (file.type === 'script') { // if javascript
$j.getScript(file.path);
} else if (file.type === 'css') { // if css
$j('head').append($j('<link rel="stylesheet" type="text/css" />').attr('href', file.path));
} else {
console.error("Unknown file type.");
}
}
}
Ext.Panel.prototype.setBody = function (html) {
var el = this.getEl();
var domel = el.dom.lastChild.firstChild;
domel.innerHTML = html;
};
Ext.Panel.prototype.getBody = function (html) {
var el = this.getEl();
var domel = el.dom.lastChild.firstChild;
return domel.innerHTML;
};
Ext.onReady(function () {
Ext.QuickTips.init();
//set ajax to 600*1000 milliseconds
Ext.Ajax.timeout = 1800000;
// this overrides the above
Ext.Updater.defaults.timeout = 1800000;
// create the main regions of the screen
westPanel = new Ext.Panel({
id: 'westPanel',
region: 'west',
width: 320,
minwidth: 280,
split: true,
border: true,
layout: 'border'
});
var tb = new Ext.Toolbar({
id: 'maintoolbar',
title: 'maintoolbar',
items: [
new Ext.Toolbar.Button({
id: 'changetool',
text: 'Switch to subset view',
iconCls: 'nextbutton',
disabled: false,
handler: function () {
window.location.href = "i2b2client.jsp";
}
})
]
});
expmenu = new Ext.menu.Menu({
id: 'exportMenu',
minWidth: 250,
items: [
{
text: 'Summary Statistics',
handler: function() {
if (typeof(grid) !== undefined && grid !== null) {
exportGrid();
} else {
alert("Nothing to export");
}
}
},
'-',
{
text: 'Gene Expression/RBM Datasets',
handler: function() {
exportDataSets();
}
}
]
});
advmenu = new Ext.menu.Menu({
id: 'advancedMenu',
minWidth: 250,
items: [
{
text: 'Heatmap',
// when checked has a boolean value, it is assumed to be a CheckItem
handler: function () {
GLOBAL.HeatmapType = 'Compare';
validateHeatmap();
advancedWorkflowContextHelpId = "1085";
},
disabled: GLOBAL.GPURL === ""
},
{
text: 'Hierarchical Clustering',
// when checked has a boolean value, it is assumed to be a CheckItem
handler: function () {
GLOBAL.HeatmapType = 'Cluster';
validateHeatmap();
advancedWorkflowContextHelpId = "1085";
},
disabled: GLOBAL.GPURL === ""
},
{
text: 'K-Means Clustering',
// when checked has a boolean value, it is assumed to be a CheckItem
handler: function () {
GLOBAL.HeatmapType = 'KMeans';
validateHeatmap();
advancedWorkflowContextHelpId = "1085";
},
disabled: GLOBAL.GPURL === ""
},
{
text: 'Comparative Marker Selection (Heatmap)',
// when checked has a boolean value, it is assumed to be a CheckItem
handler: function () {
GLOBAL.HeatmapType = 'Select';
validateHeatmap();
advancedWorkflowContextHelpId = "1085";
},
disabled: GLOBAL.GPURL === ""
},
'-',
{
text: 'Principal Component Analysis',
// when checked has a boolean value, it is assumed to be a CheckItem
handler: function () {
GLOBAL.HeatmapType = 'PCA';
validateHeatmap();
advancedWorkflowContextHelpId = "1172";
},
disabled: GLOBAL.GPURL === ""
},
'-',
{
text: 'Survival Analysis',
handler: function () {
if (isSubsetEmpty(1) || isSubsetEmpty(2)) {
alert('Survival Analysis needs time point data from both subsets.');
return;
} else {
showSurvivalAnalysis();
}
},
disabled: GLOBAL.GPURL === ""
},
'-',
{
text: 'Haploview',
handler: function() {
if (isSubsetEmpty(1) && isSubsetEmpty(2)) {
alert('Empty subsets found, need a valid subset to analyze!');
return;
}
if ((GLOBAL.CurrentSubsetIDs[1] === null && !isSubsetEmpty(1)) || (GLOBAL.CurrentSubsetIDs[2] === null && !isSubsetEmpty(2))) {
runAllQueries(function() {
showHaploviewGeneSelection();
});
} else {
showHaploviewGeneSelection();
}
return;
}
},
{
text: 'SNPViewer',
handler: function() {
if (isSubsetEmpty(1) && isSubsetEmpty(2)) {
alert('Both dataset is empty. Please choose a valid dataset.');
return;
}
if ((GLOBAL.CurrentSubsetIDs[1] === null && !isSubsetEmpty(1)) || (GLOBAL.CurrentSubsetIDs[2] === null && !isSubsetEmpty(2))) {
runAllQueries(function() {
showSNPViewerSelection();
});
} else {
showSNPViewerSelection();
}
return;
},
disabled: GLOBAL.GPURL === ""
},
{
text: 'Integrative Genome Viewer',
handler: function() {
if (isSubsetEmpty(1) && isSubsetEmpty(2)) {
alert('Both dataset is empty. Please choose a valid dataset.');
return;
}
if ((GLOBAL.CurrentSubsetIDs[1] === null && !isSubsetEmpty(1)) || (GLOBAL.CurrentSubsetIDs[2] === null && !isSubsetEmpty(2))) {
runAllQueries(function() {
showIgvSelection();
});
} else {
showIgvSelection();
}
return;
},
disabled: GLOBAL.GPURL === ""
},
{
text: 'PLINK',
disabled: true,
handler: function() {
if (isSubsetEmpty(1) && isSubsetEmpty(2)) {
alert('Both dataset is empty. Please choose a valid dataset.');
return;
}
if ((GLOBAL.CurrentSubsetIDs[1] === null && !isSubsetEmpty(1)) || (GLOBAL.CurrentSubsetIDs[2] === null && !isSubsetEmpty(2))) {
runAllQueries(function() {
showPlinkSelection();
});
} else {
showPlinkSelection();
}
return;
}
},
{
text: 'Genome-Wide Association Study',
handler: function() {
if (isSubsetEmpty(1) || isSubsetEmpty(2)) {
alert('Genome-Wide Association Study needs control datasets (normal patients) in subset 1, and case datasets (disease patients) in subset 2.');
return;
}
if ((GLOBAL.CurrentSubsetIDs[1] === null && !isSubsetEmpty(1)) || (GLOBAL.CurrentSubsetIDs[2] === null && !isSubsetEmpty(2))) {
runAllQueries(function() {
showGwasSelection();
});
} else {
showGwasSelection();
}
return;
}
}
]
});
var tb2 = new Ext.Toolbar({
id: 'maintoolbar',
title: 'maintoolbar',
items: [
new Ext.Toolbar.Button({
id: 'dataExplorerHelpButton',
iconCls: 'contextHelpBtn',
qtip: 'Click for Dataset Explorer Help',
disabled: false,
handler: function () {
D2H_ShowHelp("1258",helpURL,"wndExternal",CTXT_DISPLAY_FULLHELP);
}
})
]
});
centerMainPanel = new Ext.Panel({
id: 'centerMainPanel',
region: 'center',
// tbar: tb,
layout: 'border'
});
centerPanel = new Ext.Panel({
id: 'centerPanel',
region: 'center',
width: 500,
minwidth: 150,
split: true,
border: true,
layout: 'fit'
});
// **************
// Comparison tab
// **************
queryPanel = new Ext.Panel({
id: 'queryPanel',
title: 'Comparison',
region: 'north',
height: 340,
autoScroll: true,
split: true,
autoLoad: {
url: pageInfo.basePath+'/datasetExplorer/queryPanelsLayout',
scripts: true,
nocache: true,
discardUrl: true,
method: 'POST'
},
collapsible: true,
titleCollapse: false,
animCollapse: false,
listeners: {
activate: function() {
GLOBAL.Analysis="Advanced";
}
}
});
resultsPanel = new Ext.Panel({
id: 'resultsPanel',
title: 'Results',
region: 'center',
split: true,
height: 90
});
resultsTabPanel = new Ext.TabPanel({
id: 'resultsTabPanel',
title: 'Analysis/Results',
region: 'center',
defaults: {
hideMode: 'display'
},
collapsible: false,
//height: 300,
deferredRender: false,
activeTab: 0,
tools: [
{
id: 'help',
qtip:'Click for Generate Summary Statistics help',
handler: function(event, toolEl, panel) {
D2H_ShowHelp("1074",helpURL,"wndExternal",CTXT_DISPLAY_FULLHELP);
},
hidden:true
}
]
});
// **************
// Grid view tab
// **************
analysisGridPanel = new Ext.Panel({
id: 'analysisGridPanel',
title: 'Grid View',
region: 'center',
split: true,
height: 90,
layout: 'fit',
listeners: {
activate: function (p) {
if (isSubsetQueriesChanged(p.subsetQueries) || !Ext.get('analysisGridPanel')) {
runAllQueries(getSummaryGridData, p);
activateTabResults();
onWindowResize();
} else {
getSummaryGridData();
}
},
deactivate: function() {
resultsTabPanel.tools.help.dom.style.display = "none";
},
'afterLayout': {
fn: function (el) {
onWindowResize();
}
}
}
});
// ******************
// Summary Statistics
// ******************
analysisPanel = new Ext.Panel ({
id: 'analysisPanel',
title: 'Summary Statistics',
region: 'center',
fitToFrame: true,
listeners: {
activate: function (p) {
if (isSubsetQueriesChanged(p.subsetQueries) || !Ext.get('analysis_title')) {
p.body.mask("Loading...", 'x-mask-loading');
runAllQueries(getSummaryStatistics, p);
activateTabResults();
onWindowResize();
}
},
deactivate: function() {
resultsTabPanel.tools.help.dom.style.display = "none";
},
'afterLayout': {
fn: function (el) {
onWindowResize();
}
}
},
autoScroll: true,
html: '<div style="text-align:center;font:12pt arial;width:100%;height:100%;">' +
'<table style="width:100%;height:100%;"><tr><td align="center" valign="center">Drag concepts ' +
'to this panel to view a breakdown of the subset by that concept</td></tr></table></div>',
split: true,
closable: false,
height: 90,
tbar: [
'->', // Fill
{
id: 'printanalysisbutton',
text: 'Print',
iconCls: 'printbutton',
handler: function() {
var text = getAnalysisPanelContent();
printPreview(text);
}
}
]
});
// ************
// Data Exports
// ************
analysisDataExportPanel = new Ext.Panel({
id: 'analysisDataExportPanel',
title: 'Data Export',
region: 'center',
split: true,
height: 90,
layout: 'fit',
listeners: {
activate: function(p) {
if (isSubsetQueriesChanged(p.subsetQueries) || !Ext.get('dataTypesGridPanel')) {
p.body.mask("Loading...", 'x-mask-loading');
runAllQueries(getDatadata, p);
return;
}
else {
this.doLayout()
}
},
'afterLayout': {
fn: function (el) {
onWindowResize();
}
}
},
collapsible: true
});
// ******************
// Advanced Workflow
// ******************
dataAssociationPanel = new Ext.Panel({
id: 'dataAssociationPanel',
title: 'Advanced Workflow',
region: 'center',
split: true,
height: 90,
layout: 'fit',
tbar: new Ext.Toolbar({
id: 'advancedWorkflowToolbar',
title: 'Advanced Workflow actions',
items: []
}),
autoScroll: true,
autoLoad: {
url: pageInfo.basePath+'/dataAssociation/defaultPage',
method: 'POST',
callback: setDataAssociationAvailableFlag,
evalScripts:true
},
listeners: {
activate: function (p) {
/**
* routines when activating advanced workflow tab
* @private
*/
var _activateAdvancedWorkflow = function () {
activateTabResults();
GLOBAL.Analysis="dataAssociation";
renderCohortSummary();
onWindowResize();
};
if (isSubsetQueriesChanged(p.subsetQueries)) {
runAllQueries(_activateAdvancedWorkflow, p);
}
_activateAdvancedWorkflow();
},
'afterLayout': {
fn: function (el) {
onWindowResize();
}
}
},
collapsible: true
});
// ******************
// Export Jobs
// ******************
analysisExportJobsPanel = new Ext.Panel({
id: 'analysisExportJobsPanel',
title: 'Export Jobs',
region: 'center',
split: true,
height: 90,
layout: 'fit',
listeners: {
activate: function(p) {
p.body.mask("Loading...", 'x-mask-loading');
getExportJobs(p);
},
deactivate: function() {
}
},
collapsible: true
});
/**
* panel to display list of jobs belong to a user
* @type {Ext.Panel}
*/
analysisJobsPanel = new Ext.Panel({
id: 'analysisJobsPanel',
title: 'Analysis Jobs',
region: 'center',
split: true,
height: 90,
layout: 'fit',
listeners: {
activate: function(p) {
getJobsData(p);
}
},
collapsible: true
});
workspacePanel = new Ext.Panel({
id: 'workspacePanel',
title: 'Workspace',
region: 'center',
split: true,
height: 90,
layout: 'fit',
autoScroll: false,
listeners: {
activate: function(p) {
renderWorkspace(p);
},
deactivate: function() {
}
},
collapsible: true
});
/*here starts the l3plugin*/
sampleArray = [];
variantArray = [];
exportTable = "l3 bioinformatics";
filterParamsArray = []; //for sample search to store what is dragged, wait for input filter range
tmpTable = ""; //store every time to reuse for displaying table
//sampleJSON = []; //to store json received from sample search
//variantJSON = []; //to store json received from variant search
//studyName = ""; //to store the study name
variantTable = '<head><style>.beta table, .beta th, .beta td {border: 1px solid black;border-collapse: collapse;} .beta th, .beta td {padding: 5px;} .beta th { text-align: left; }</style></head><body><table style="width:100%" class="beta"><tr><th>chr</th><th>pos</th><th>ref</th><th>alt</th><th>homo count</th><th>sample count</th><th>sample covered</th><th>af</th><th>annotation consequence</th><th>annotation aminoAcidChange</th></tr>';
l3tbar = new Ext.Toolbar({
id: 'l3tbar',
title: 'L3Info',
items: [
'Search variant',
{xtype: 'tbspacer', width: 200},
'chr: ',
{
id: 'chrField',
xtype: 'textfield',
name: 'chrField',
emptyText: 'x',
fieldLabel: 'chr'
//allowBlank: false
},
{xtype: 'tbspacer', width: 150},
'from: ',
{
id: 'fromField',
xtype: 'textfield',
name: 'fromField',
emptyText: '123456',
fieldLabel: 'from'
//allowBlank: false
},
{xtype: 'tbspacer', width: 150},
'to: ',
{
id: 'toField',
xtype: 'textfield',
name: 'toField',
emptyText: '123456',
fieldLabel: 'to'
//allowBlank: false
},
{xtype: 'tbspacer', width: 200},
{
id: 'chrButton',
xtype: 'button',
text: 'submit',
handler: function() {
variantArray = [];
var chr = Ext.getCmp('chrField').getValue();
var from = Ext.getCmp('fromField').getValue();
var to = Ext.getCmp('toField').getValue();
//updateL3Panel('<h1>Connecting...</h1>', false);
if (sampleArray.length == 0) {
Ext.MessageBox.alert('Invalid input','Please make sure you have use a valid filter and get the sample results');
} else if(chr.length != 0 && from.length != 0 && to.length != 0) {
updateL3Panel('<h1>Connecting...</h1>', false);
disableL3(true);
Ext.Ajax.request({
url: "http://localhost:40083/variant/search",
method: 'POST',
success: function (result, request) {
if (typeof result === "undefined") {
exportTable = variantTable;
exportTable += '<tr><td colspan="10">Successful connection to variant/search but no result return</td></tr></table></body>';
updateL3Panel(exportTable, false); //l3todo: this was table, but I feels like this should be exportTable??
enableL3(false);
} else {
fromL3Variant(result);
enableL3(true);
};
console.error("this is variant search params");
console.error(JSON.stringify({
"chr": chr.toString(),
"start": from.toString(),
"end": to.toString(),
"alt": "C",
"samples": sampleArray
}));
},
failure: function (result, request) { //the given result from the server is already in html form!
//getSummaryStatisticsComplete(result);
exportTable = 'CGDB API variant/search connection failure';//'<tr><td colspan="10">CGDB API variant/search connection failure</td></tr></table></body>';
updateL3Panel(exportTable, false);
//l3PluginPanel.body.unmask();
enableL3(false);
},
//contentType: "application/json", //headers: {"Content-Type" : "application/json"},//{'X-Requested-With' : 'XMLHttpRequest'},
timeout: '300000',
//dataType: "json",
jsonData: JSON.stringify({
"chr": chr.toString(),
"start": from.toString(),
"end": to.toString(),
"alt": "C",
"samples": sampleArray
}) // or a URL encoded string
});
} //end of if condition
else {Ext.MessageBox.alert('Invalid input', 'Please make sure you have enter chr, from and to fields');}
} //end of handler fuinciton
}
]
});
l3bbar = new Ext.Toolbar({
id: 'l3bbar',
title: 'L3Info',
items: [ /* {
// xtype: 'button', // default for Toolbars, same as 'tbbutton'
text: 'Export To Excel',
listeners: {
click: function () {
//console.error(exportTable);
var a = document.createElement('a');
a.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,'
+ Base64.encode(exportTable);
a.setAttribute('type', 'hidden');
a.download = 'grid_view.xls';
document.body.appendChild(a);
a.click();
jQuery(a).remove();
}
}
},*/
' Fill in the study name: ',
{
id: 'studyNameField',
xtype: 'textfield',
name: 'studyNameField',
emptyText: 'uniqueStudyInOneWord',
allowBlank: true
},
{ id: 'mutationButton',
text: 'Import Variants',
listeners: {
click: function () {
var studyName = Ext.getCmp('studyNameField').getValue();
var chr = Ext.getCmp('chrField').getValue();
var from = Ext.getCmp('fromField').getValue();
var to = Ext.getCmp('toField').getValue();
if (studyName.length == 0) {
console.error("You must enter a dinstinct study name")
Ext.MessageBox.alert('Invalid input', 'You should enter a dinstinct and non empty study name');
} else if (sampleArray.length == 0) {
console.error("No available samples, import procedure stopped");
Ext.MessageBox.alert('Invalid input', 'No available samples, import procedure stopped.');
} else if (variantArray.length == 0) {
console.error("Though samples found, no available variants, import procedure stopped");
Ext.MessageBox.alert('Invalid input', 'No available variants, import procedure stopped');
} else {
disableL3(true);
console.error("This is the params for import gene");
l3PluginPanel.body.mask("Importing variants..", 'x-mask-loading');
console.error("Ouch! you want to import!");
console.error(JSON.stringify({
"study_name" : studyName,
"chr" : chr,
"start" : from,
"end" : to,
"samples" : filterParamsArray
}));
Ext.Ajax.request({
url: "http://localhost:40083/transmart/import", //_gene_mutation",//import", ///pageInfo.basePath+"/chart/basicStatistics",
method: 'POST',
success: function (result, request) {
l3PluginPanel.body.unmask();
console.error("Sample import finish, Variants import starts");
//Ext.MessageBox.alert('success', 'add the track link: http://localhost:58080/hubDirectory/hub.txt to genome browser');
Ext.MessageBox.confirm('Confirm', 'Import success. You can add the track link: http://localhost:58080/hubDirectory/hub.txt to genome browser to view the variants. Click Yes to refresh the page and you will see samples, vcf and mutations on the left, click No to stay in the page.', function(e) {
if (e == 'yes') location.reload()});//importL3Variants (); //l3todo: write this import function
enableL3(true);
},
failure: function (result, request) {
console.error("Cannot import the samples to nevigate, so will stop import variants as well");
l3PluginPanel.body.unmask();
enableL3(true);
},
timeout: '300000',
jsonData: JSON.stringify({
"study_name" : studyName,
"chr" : chr,
"start" : from,
"end" : to,
"samples" : filterParamsArray
})
});
} }
}
} ,
/*
//start of import vcf
{ id: 'vcfButton',
text: 'Import Gene Variants',
listeners: {
click: function () {
var studyName = Ext.getCmp('studyNameField').getValue();
var chr = Ext.getCmp('chrField').getValue();
var from = Ext.getCmp('fromField').getValue();
var to = Ext.getCmp('toField').getValue();
if (studyName.length == 0) {
console.error("You must enter a dinstinct study name")
Ext.MessageBox.alert('Invalid input', 'You should enter a dinstinct and non empty study name');
} else if (sampleArray.length == 0) {
console.error("No available samples, import procedure stopped");
Ext.MessageBox.alert('Invalid input', 'No available samples, import procedure stopped.');
} else if (variantArray.length == 0) {
console.error("Though samples found, no available variants, import procedure stopped");
Ext.MessageBox.alert('Invalid input', 'No available variants, import procedure stopped');
} else {
disableL3(true);
console.error("This is the params for import gene");
l3PluginPanel.body.mask("Importing Samples..", 'x-mask-loading');
console.error("Ouch! you want to import!");
console.error(JSON.stringify({
"study_name" : studyName,
"chr" : chr,
"start" : from,
"end" : to,
"samples" : filterParamsArray
}));
Ext.Ajax.request({
url: "http://localhost:40083/transmart/import_vcf", ///pageInfo.basePath+"/chart/basicStatistics",
method: 'POST',
success: function (result, request) {
//getSummaryStatisticsComplete(result);
l3PluginPanel.body.unmask();
console.error("Sample import finish, Variants import starts");
console.error("This is the passed params");
Ext.MessageBox.confirm('Confirm', 'Click Yes to refresh the page and you will see samples/variants on the left, click Nm to stay in the page.', function(e) {
if (e == 'yes') location.reload()});//importL3Variants (); //l3todo: write this import function
enableL3(true);
},
failure: function (result, request) {
//getSummaryStatisticsComplete(result);
console.error("Cannot import the samples to nevigate, so will stop import variants as well");
var table = sampleTable;
l3PluginPanel.body.unmask();
enableL3(true);
},
timeout: '300000',
jsonData: JSON.stringify({
"study_name" : studyName,
"chr" : chr,
"start" : from,
"end" : to,
"samples" : filterParamsArray
})
});
} }
}
}
//end of import vcf
*/
/*
,
{ id: 'browserButton',
text: 'Import to genome browser',
listeners: {
click: function() {
console.error("import genome button clicked");
var studyName = Ext.getCmp('studyNameField').getValue();
var chr = Ext.getCmp('chrField').getValue();
var from = Ext.getCmp('fromField').getValue();
var to = Ext.getCmp('toField').getValue();
if (studyName.length == 0) {
console.error("You must enter a dinstinct study name")
Ext.MessageBox.alert('Invalid input', 'You should enter a dinstinct and non empty track name');
} else if (variantArray.length == 0) {
console.error("You need to have the vcf file to import");
Ext.MessageBox.alert('Invalid input','You need to have the vcf file to import');
} else {
disableL3(true);
console.error("You want to import to browswer");
console.error(JSON.stringify({
"study_name" : studyName,
"chr" : chr,
"start" : from,
"end" : to,
"samples" : filterParamsArray
}));
Ext.Ajax.request({
url: "http://localhost:40083/transmart/add_track", ///pageInfo.basePath+"/chart/basicStatistics",
method: 'POST',
success: function (result, request) {
//getSummaryStatisticsComplete(result);
l3PluginPanel.body.unmask();
//Ext.MessageBox.alert('success', 'To view the track in genome browser, click genome browser -> \'+\' sign -> Defaults -> \'+\' sign -> paste in \'http://localhost:48080/hubDirectory/hub.txt\'');
Ext.MessageBox.alert('success', 'add the track link: http://localhost:58080/hubDirectory/hub.txt to genome browser');
console.error("Import to genome browser finished");
//location.reload();//importL3Variants (); //l3todo: write this import function
enableL3(true);
},
failure: function (result, request) {
//getSummaryStatisticsComplete(result);
Ext.MessageBox.alert('failure', 'Cannot import vcf to browser');
l3PluginPanel.body.unmask();
enableL3(true);
},
timeout: '300000',
jsonData: JSON.stringify({
"study_name" : studyName,
"chr" : chr,
"start" : from,
"end" : to,
"samples" : filterParamsArray})
});
}
}
}
},*/
{
id: 'excelButton',
// xtype: 'button', // default for Toolbars, same as 'tbbutton'
text: 'Export To Excel',
listeners: {
click: function () {
if (variantArray.length == 0) {
console.error("Though samples found, no available variants, import procedure stopped");
Ext.MessageBox.alert('Invalid input', 'No available variants, import procedure stopped');
} else { disableL3(true);
//console.error(exportTable);
var a = document.createElement('a');
a.href = 'data:application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;base64,'
+ Base64.encode(exportTable);
a.setAttribute('type', 'hidden');
var studyName = Ext.getCmp('studyNameField').getValue();
if (studyName.length == 0) {
a.download = 'Variants.xls';
} else {
a.download = studyName.concat('.xls');
}
document.body.appendChild(a);
a.click();
jQuery(a).remove();
enableL3(true);
}
}
}
}
]
});
l3ttbar = new Ext.Toolbar({
id: 'l3ttbar',
title: 'L3Info',
items: ['Age range: ',
{
id: 'ageLeft',
xtype: 'textfield',
name: 'ageLeft',
//emptyText: '30',
//fieldLabel: 'chr'
//allowBlank: false
},
' <= age < ',
{
id: 'ageRight',
xtype: 'textfield',