-
Notifications
You must be signed in to change notification settings - Fork 18
/
genome-maps.js
1561 lines (1473 loc) · 52.4 KB
/
genome-maps.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
/*
* Copyright (c) 2012 Francisco Salavert (ICM-CIPF)
* Copyright (c) 2012 Ruben Sanchez (ICM-CIPF)
* Copyright (c) 2012 Ignacio Medina (ICM-CIPF)
*
* This file is part of Genome Maps.
*
* Genome Maps is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* Genome Maps is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Genome Maps. If not, see <http://www.gnu.org/licenses/>.
*/
function GenomeMaps(targetId, args) {
var _this = this;
this.id = "GenomeMaps" + Math.round(Math.random() * 10000);
this.suiteId = 9;
this.title = "Genome Maps";
this.description = "Genomic data visualization";
this.wum = true;
this.version = "3.0.4";
this.trackIdCounter = 1;
this.args = args;
this.width = $(window).width();
this.height = $(window).height();
this.targetId = document.body;
if (targetId != null) {
this.targetId = targetId;
}
if (args != null) {
if (args.width != null) {
this.width = args.width;
}
if (args.height != null) {
this.height = args.height;
}
if (args.wum != null) {
this.wum = args.wum;
}
}
if(typeof args != 'undefined'){
this.width = args.width || this.width;
this.height = args.height || this.height;
this.wum = args.wum || this.wum;
}
this.accountData = null;
var region = new Region();
var url = $.url();//Check url paramaters
var url_cbhost = url.param('CELLBASE_HOST');
if(url_cbhost != null) {
CELLBASE_HOST = url_cbhost;
}
speciesObj = DEFAULT_SPECIES;
var urlSpecies = url.param('species');
if(urlSpecies != null || urlSpecies != ""){
//TODO change to object AVAILABLE SPECIES
for(var i = 0; i < AVAILABLE_SPECIES.length; i++){
if(AVAILABLE_SPECIES[i].species==urlSpecies){
speciesObj=AVAILABLE_SPECIES[i];
break;
}
}
}
this.species = speciesObj.species;
region.load(speciesObj.region);
//console.log(speciesObj);
var regionStr = url.param('region');
if(regionStr != null) {
region.parse(regionStr);
}
var urlZoom = parseInt(url.param('zoom'));
if(isNaN(urlZoom) || urlZoom > 100 || urlZoom < 0 ){
urlZoom = null;
}
var urlGene = url.param('gene');
if(urlGene != null && urlGene != ""){
region.load(this.getRegionByFeature(urlGene,"gene"));
}
var urlSnp = url.param('snp');
if(urlSnp != null && urlSnp != ""){
region.load(this.getRegionByFeature(urlSnp,"snp"));
}
this.headerWidget = new HeaderWidget({
appname: this.title,
description: this.description,
version:this.version,
suiteId : this.suiteId,
accountData:this.accountData
});
//CHECK genomeviewer checks if the param is provided by url to apply zoom param or region param
region.url = url.param('region');
//visualiaztion URL paramaters
var confPanelCollapsed = false;
if( url.param('confpanel') === 'false'){
confPanelCollapsed = true;
}
var regionPanelHidden = true;
if( url.param('regionpanel') === 'false'){
regionPanelHidden = false;
}
this.genomeViewer = new GenomeViewer(this.id+"gvDiv", speciesObj,{
region:region,
version:this.version,
zoom:urlZoom,
confPanelCollapsed:confPanelCollapsed,
regionPanelHidden:regionPanelHidden,
availableSpecies: AVAILABLE_SPECIES,
height:this.height-this.headerWidget.height,
width:this.width
});
/**Atach events i listen**/
this.headerWidget.onLogin.addEventListener (function (sender) {
Ext.example.msg('Welcome', 'You logged in');
_this.sessionInitiated();
});
this.headerWidget.onLogout.addEventListener (function (sender) {
Ext.example.msg('Good bye', 'You logged out');
_this.sessionFinished();
});
this.headerWidget.onGetAccountInfo.addEventListener(function (evt, response){
_this.setAccountData(response);
});
this._updateLocalOpencgaTracks();
//SPECIE EVENT
this.genomeViewer.onSpeciesChange.addEventListener(function(sender,data){
// _this._setTracks();
// _this.setTracksMenu();
_this.headerWidget.setDescription(_this.genomeViewer.speciesName);
_this.species=_this.genomeViewer.species;
});
//RESIZE EVENT
$(window).smartresize(function(a){
_this.setSize($(window).width(),$(window).height());
});
//SAVE CONFIG IN COOKIE
$(window).unload(function(){
var value = {
species:{
name:_this.genomeViewer.speciesName,
species:_this.genomeViewer.species,
chromosome:_this.genomeViewer.chromosome,
position:_this.genomeViewer.position}
};
$.cookie("gm_settings", JSON.stringify(value), {expires: 365});
});
}
GenomeMaps.prototype.sessionInitiated = function(){
this.availableSt.getRootNode().findChild('id','opencga').set('text','Browse remote data');
};
GenomeMaps.prototype.sessionFinished = function(){
this.availableSt.getRootNode().findChild('id','opencga').set('text','Browse remote data <span class="tip">(login required)</span>');
this._unloadOpencgaTracks();
this.accountData = null;
};
GenomeMaps.prototype.setAccountData = function(response) {
this.accountData = response;
this._updateOpencgaTracks(JSON.parse(JSON.stringify(response)));
};
GenomeMaps.prototype.draw = function(){
var _this = this;
if(this._panel == null){
var gvContainer = Ext.create('Ext.container.Container', {
id:this.id+"gvContainer",
region:"center",
html : '<div id="'+this.id+'gvDiv"></div>'
});
this._panel = Ext.create('Ext.panel.Panel', {
id:this.id+"_panel",
renderTo:this.targetId,
layout:'border',
border:false,
width:this.width,
height:this.height,
items:[this.headerWidget.getPanel(),gvContainer]
});
this.headerWidget.setDescription(this.genomeViewer.speciesName);
this.genomeViewer.afterRender.addEventListener(function(sender,event){
Ext.getCmp(_this.genomeViewer.id+"versionLabel").setText('<span class="info">Genome Maps v'+_this.version+'</span>');
_this._setOverviewTracks();
_this.genomeViewer.addSidePanelItems(_this.getSidePanelItems());
_this.genomeViewer.onSvgRemoveTrack.addEventListener(function(sender,trackId){
Ext.getCmp(_this.id+trackId+"menu").setChecked(false);
});
});
this.genomeViewer.draw();
}
//check login
if($.cookie('bioinfo_sid') != null){
this.sessionInitiated();
}else{
this.sessionFinished();
}
};
GenomeMaps.prototype.setSize = function(width,height){
this.width=width;
this.height=height;
this._panel.setSize(width,height);
this.genomeViewer.setSize(width,height-this.headerWidget.height);
this.headerWidget.setWidth(width);
};
GenomeMaps.prototype.getRegionByFeature = function(name, feature){
var url = CELLBASE_HOST+"/latest/"+this.species+"/feature/"+feature+"/"+name+"/info?of=json";
var f;
$.ajax({
url:url,
async:false,
success:function(data){
f = JSON.parse(data)[0][0];
}
});
if(f != null){
return {chromosome:f.chromosome, start:f.start, end:f.end}
}
return {};
};
//deprecated
//GenomeMaps.prototype.setLocationByFeature = function(name, feature){
// var loc = this.getRegionByFeature(name, feature);
// if (loc.chromosome != null && loc.position != null){
// this.genomeViewer.setLoc(loc);
// }
//};
GenomeMaps.prototype._setOverviewTracks= function(){
var geneTrack = new TrackData("gene",{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "gene",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:50000
}
})
});
this.genomeViewer.trackSvgLayoutOverview.addTrack(geneTrack,{
id:"gene1",
type:"gene",
title:"Gene",
featuresRender:"MultiFeatureRender",
histogramZoom:10,
labelZoom:20,
height:150,
visibleRange:{start:0,end:100},
titleVisibility:'hidden',
featureTypes:FEATURE_TYPES
});
};
GenomeMaps.prototype.genTrackId = function() {
var id = this.trackIdCounter;
this.trackIdCounter++;
return id;
};
GenomeMaps.prototype.removeTrack = function(trackId) {
return this.genomeViewer.removeTrack(trackId);
};
GenomeMaps.prototype.restoreTrack = function(trackSvg, index) {
return this.genomeViewer.restoreTrack(trackSvg, index);
};
GenomeMaps.prototype.scrollToTrack = function(trackId) {
this.genomeViewer.scrollToTrack(trackId);
};
GenomeMaps.prototype.setTrackIndex = function(trackId, newIndex) {
this.genomeViewer.setTrackIndex(trackId, newIndex);
};
GenomeMaps.prototype.getTrackSvgById = function(trackId) {
return this.genomeViewer.getTrackSvgById(trackId);
};
GenomeMaps.prototype.addTrack = function(trackType, trackTitle, objectid, host) {
var id = this.genTrackId();
//console.log(trackId);
switch (trackType) {
case "Gene/Transcript":
var geneTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "gene",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:50000
},
// filters:{},
// options:{},
featureConfig:FEATURE_CONFIG.gene
})
});
this.genomeViewer.addTrack(geneTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"GeneTranscriptRender",
histogramZoom:20,
transcriptZoom:50,
height:24,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "Cytoband":
break;
case "Sequence":
var seqtrack = new TrackData(id,{
adapter: new SequenceAdapter({
category: "genomic",
subCategory: "region",
resource: "sequence",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:1000
}
})
});
this.genomeViewer.addTrack(seqtrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"SequenceRender",
height:30,
visibleRange:{start:100,end:100}
});
break;
case "CpG islands":
var cpgTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "cpg_island",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:50000
}
})
});
this.genomeViewer.addTrack(cpgTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:10,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "SNP":
var snpTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "snp",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:10000
},
featureConfig:FEATURE_CONFIG.snp
})
});
this.genomeViewer.addTrack(snpTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:70,
labelZoom:80,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "Mutation":
var mutationTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "mutation",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:10000
}
})
});
this.genomeViewer.addTrack(mutationTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:50,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "Structural variation (<20Kb)":
var structuralTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "structural_variation",
species: this.genomeViewer.species,
params : {min_length:1,max_length:20000},
featureCache:{
gzip: true,
chunkSize:50000
}
})
});
this.genomeViewer.addTrack(structuralTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:40,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "Structural variation (>20Kb)":
var structuralTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "structural_variation",
species: this.genomeViewer.species,
params : {min_length:20000,max_length:300000000},
featureCache:{
gzip: true,
chunkSize:5000000
}
})
});
this.genomeViewer.addTrack(structuralTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:40,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "miRNA targets":
var miRNATrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "mirna_target",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:10000
}
})
});
this.genomeViewer.addTrack(miRNATrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:50,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "TFBS":
var tfbsTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "tfbs",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:10000
}
})
});
this.genomeViewer.addTrack(tfbsTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:50,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
// case "Histone":
//
// break;
// case "Polymerase":
//
// break;
// case "Open Chromatin":
//
// break;
case "Conserved regions":
var conservedTrack = new TrackData(id,{
adapter: new CellBaseAdapter({
category: "genomic",
subCategory: "region",
resource: "conserved_region",
species: this.genomeViewer.species,
featureCache:{
gzip: true,
chunkSize:10000
}
})
});
this.genomeViewer.addTrack(conservedTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:50,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "bam":
var bamTrack = new TrackData(id,{
adapter: new BamAdapter({
category: "bam",
host:host,
//resource: trackTitle.substr(0,trackTitle.length-4),
resource: objectid,
species: this.genomeViewer.species,
featureCache:{
gzip: false,
chunkSize:5000
},
filters:{},
options:{},
featureConfig:FEATURE_CONFIG.bam
})
});
this.genomeViewer.addTrack(bamTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"BamRender",
histogramZoom:20,
height:24,
visibleRange:{start:90,end:100},
featureTypes:FEATURE_TYPES
});
break;
case "vcf":
var vcfTrack = new TrackData(id,{
adapter: new OpencgaAdapter({
category: "vcf",
//resource: trackTitle.substr(0,trackTitle.length-4),
resource: objectid,
species: this.genomeViewer.species,
featureCache:{
gzip: false,
chunkSize:5000
},
filters:{},
options:{},
featureConfig:FEATURE_CONFIG.vcf
})
});
this.genomeViewer.addTrack(vcfTrack,{
id:id,
type:trackType,
title:trackTitle,
featuresRender:"MultiFeatureRender",
histogramZoom:50,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
break;
default:
return null;
}
return id;
};
GenomeMaps.prototype.addFileTrack = function(text, updateActiveTracksPanel) {
var _this = this;
var fileWidget = null;
switch(text){
case "GFF2": fileWidget = new GFFFileWidget({version:2,viewer:_this.genomeViewer}); break;
case "GFF3": fileWidget = new GFFFileWidget({version:3,viewer:_this.genomeViewer}); break;
case "GTF": fileWidget = new GTFFileWidget({viewer:_this.genomeViewer});break;
case "BED": fileWidget = new BEDFileWidget({viewer:_this.genomeViewer});break;
case "VCF": fileWidget = new VCFFileWidget({viewer:_this.genomeViewer}); break;
}
if(fileWidget != null){
fileWidget.draw();
if (_this.wum){
_this.headerWidget.onLogin.addEventListener(function (sender){
fileWidget.sessionInitiated();
});
_this.headerWidget.onLogout.addEventListener(function (sender){
fileWidget.sessionFinished();
});
}
fileWidget.onOk.addEventListener(function(sender, event) {
var fileTrack = new TrackData(event.fileName,{
adapter: event.adapter
});
var id = _this.genTrackId();
var type = text;
_this.genomeViewer.addTrack(fileTrack,{
id:id,
title:event.fileName,
type:type,
featuresRender:"MultiFeatureRender",
// histogramZoom:80,
height:150,
visibleRange:{start:0,end:100},
featureTypes:FEATURE_TYPES
});
var title = event.fileName+'-'+id;
updateActiveTracksPanel(type, title, id, true);
});
}
};
GenomeMaps.prototype.addDASTrack = function(sourceName, sourceUrl) {
var id = this.genTrackId();
var dasTrack = new TrackData("das",{
adapter: new DasAdapter({
url: sourceUrl,
species: this.genomeViewer.species,
featureCache:{
gzip: false,
chunkSize:10000
}
})
});
this.genomeViewer.addTrack(dasTrack,{
id:id,
title:sourceName,
type:"das",
featuresRender:"MultiFeatureRender",
height:150,
visibleRange:{start:50,end:100},
settings:{
height:10
}
});
return id;
};
GenomeMaps.prototype._loadInitialTracksConfig= function(){
//Load initial TRACKS config
var categories = TRACKS[SPECIES_TRACKS_GROUP[this.species]];
var activeTracks = [];
var cellbaseTracks = [];
for (var i=0, leni=categories.length; i<leni; i++) {
var subChilds = [];
cellbaseTracks.push({text: categories[i].category, iconCls:"icon-box", expanded:true, children:subChilds});
for ( var j = 0, lenj=categories[i].tracks.length; j<lenj; j++){
var trackType = categories[i].tracks[j].id;
var checked = categories[i].tracks[j].checked;
var disabled = categories[i].tracks[j].disabled;
subChilds.push({text: trackType, iconCls:"icon-blue-box", leaf:true});
if(checked){
var trackId = this.addTrack(trackType, trackType);
if(trackId != null){
activeTracks.push({text: trackType, trackId:trackId, trackType:trackType ,checked:true, iconCls:"icon-blue-box", leaf:true});
}else{
console.log('track type not exists in the addTrack function');
}
}
}
}
return {cellbaseTracks:cellbaseTracks,activeTracks:activeTracks};
};
GenomeMaps.prototype._loadInitialDasTrackConfig= function(){
//Load initial DAS_TRACKS config
var das_tracks = DAS_TRACKS;
var dasChilds = [];
for (var i = 0, leni = das_tracks.length; i < leni; i++) {
if(das_tracks[i].species == this.species){
for ( var j = 0, lenj = das_tracks[i].categories.length; j < lenj; j++){
var sourceName, sourceUrl, checked;
var subChilds = [];
dasChilds.push({text: das_tracks[i].categories[j].name, iconCls:"icon-box", expanded:true, children:subChilds});
for ( var k = 0, lenk = das_tracks[i].categories[j].sources.length; k < lenk; k++){
sourceName = das_tracks[i].categories[j].sources[k].name;
sourceUrl = das_tracks[i].categories[j].sources[k].url;
checked = das_tracks[i].categories[j].sources[k].checked;
subChilds.push({text:sourceName, url:sourceUrl, iconCls:"icon-blue-box", leaf:true});
//if(checked){
//this.addDASTrack(sourceName, sourceUrl);
//}
}
}
break;
}
}
return dasChilds;
};
GenomeMaps.prototype._loadInitialPluginTrackConfig= function(){
var plugins_cat = GENOME_MAPS_AVAILABLE_PLUGINS;
var pluginChilds = [];
for (var i = 0, leni = plugins_cat.length; i < leni; i++) {
var subChilds = [];
pluginChilds.push({text: plugins_cat[i].category, iconCls:"icon-box", expanded:true, children:subChilds});
for (var j = 0, lenj = plugins_cat[i].plugins.length; j < lenj; j++){
subChilds.push({text:plugins_cat[i].plugins[j].name, plugin:plugins_cat[i].plugins[j], iconCls:"icon-blue-box", leaf:true});
}
}
return pluginChilds;
};
GenomeMaps.prototype.getSidePanelItems = function() {
var _this = this;
var tracks = this._loadInitialTracksConfig();
var pluginTracks = this._loadInitialPluginTrackConfig();
var activeSt = Ext.create('Ext.data.TreeStore',{
fields:['text', 'trackId', 'trackType'],
root:{
expanded: true,
children: tracks.activeTracks
}
});
this.activeSt = activeSt;
var pluginSt = Ext.create('Ext.data.TreeStore',{
fields:['text', 'plugin'],
root:{
expanded: true,
children: pluginTracks
}
});
/**example to add a children**/
//availableSt.getRootNode().findChild("text","Cellbase").appendChild({text: "prueba", expanded: true, iconCls:"icon-blue-box"});
var activeTracksPanel = {
title:'<span class="">Active tracks</span>',
id:this.id+"activeTracksPanel",
border:0,
layout:{type:'vbox', align:'stretch'},
items:[{
xtype:"treepanel",
id:this.id+"activeTracksTree",
store: activeSt,
bodyPadding:"5 0 0 0",
margin:"-1 0 0 0",
border:false,
autoScroll:true,
flex:1,
useArrows:true,
rootVisible: false,
selType: 'cellmodel',
plugins: [Ext.create('Ext.grid.plugin.CellEditing', {clicksToEdit: 2,listeners:{
edit:function(editor, e, eOpts){
var id = e.record.data.trackId;
var trackSvg = _this.getTrackSvgById(id);
trackSvg.setTitle(e.record.data.text);
}
}})],
hideHeaders:true,
columns: [{
xtype: 'treecolumn',
dataIndex: 'text',
flex:1,
editor: {xtype: 'textfield',allowBlank: false}
},
//{
//xtype: 'actioncolumn',
//menuDisabled: true,
//align: 'center',
//tooltip: 'Edit',
//width:20,
//icon: Compbio.images.edit,
//handler: function(grid, rowIndex, colIndex, actionItem, event, record, row) {
//event.stopEvent();
//if(record.isLeaf()){
//var id = record.data.trackId;
//var track = _this.getTrackSvgById(id);
//if(track != null){
//var trackSettingsWidget = new TrackSettingsWidget({
//trackSvg:track,
//treeRecord:record
//});
//}
//}
//}
//},
{
xtype: 'actioncolumn',
menuDisabled: true,
align: 'center',
tooltip: 'Remove',
width:30,
icon: Utils.images.del,
handler: function(grid, rowIndex, colIndex, actionItem, event, record, row) {
//this also fires itemclick event from tree panel
if(record.isLeaf()){
var id = record.data.trackId;
var checked = record.data.checked;
record.destroy();
if(checked){
_this.removeTrack(id);
}
}
}
}],
viewConfig: {
markDirty:false,
plugins: {
ptype: 'treeviewdragdrop'
},
listeners : {
drop : function (node, data, overModel, dropPosition, eOpts){
var record = data.records[0];
//check if is leaf and if the record has a new index
if(record.isLeaf() && record.data.index != record.removedFrom && record.data.checked){
var id = record.data.trackId;
_this.setTrackIndex(id, record.data.index);
}
}
}
},
listeners : {
itemclick : function (este, record, item, index, e, eOpts){
if(record.isLeaf()){
if(record.data.checked){//track can be disabled, so if not checked does not exist in trackSvgLayout
//this also fires remove button click event from tree panel action column
var id = record.data.trackId;
_this.scrollToTrack(id);
var trackSvg = _this.getTrackSvgById(id);
if(trackSvg!=null){
_this._loadTrackConfig(trackSvg,record);
}
}
}
},
checkchange : function (node, checked){
var type = node.data.trackType;
var id = node.data.trackId;
if(checked){
var track = node.raw.track;
_this.restoreTrack(track, node.data.index);
}else{
var track = _this.removeTrack(id);
//save trackSvg pointer
node.raw.track = track;
}
},
itemmouseenter : function (este,record){
var track = _this.getTrackSvgById(record.data.trackId);
if(track != null){
track.fnTitleMouseEnter();
}
},
itemmouseleave : function (este,record){
var track = _this.getTrackSvgById(record.data.trackId);
if(track != null){
track.fnTitleMouseLeave();
}
}
}
},{
xtype:"tabpanel",
id:this.id+"activeTracksSettings",
plain: true,
border:false,
margin :"5 0 0 0",
autoScroll:true,
flex:2,
items:[
{
id:this.id+"trackOptions",
itemId:this.id+"trackOptions",
title:"Options",
bodyPadding:10,
border:false
},{
id:this.id+"trackFiltering",
itemId:this.id+"trackFiltering",
title:"Filtering",
layout:{type:'vbox', align:'stretch'},
border:false
}
]
}]
};
var pluginsTree = {
xtype:"treepanel",
id:this.id+"pluginsTree",
title:'<span class="">Analysis</span>',
bodyPadding:"10 0 0 0",
useArrows:true,
rootVisible: false,
store: pluginSt,
hideHeaders:true,
listeners : {
itemclick : function (este, record, item, index, e, eOpts){
if(record.isLeaf()){
var plugin = record.get("plugin");
GENOME_MAPS_REGISTERED_PLUGINS[plugin.name].setViewer(_this.genomeViewer);
GENOME_MAPS_REGISTERED_PLUGINS[plugin.name].draw();
}
}
}
};
var searchSidePanel = {
title:'<span class="">Search</span>',
id:this.id+"searchSidePanel",
layout:{type:'vbox', align:'stretch'},
bodyPadding:"5",
items:[{
xtype:'tbtext',text:'<p class="">Search by any external reference:</p>'
},{
id:this.id+ "searchTextArea",
xtype: 'textarea',
flex:1,
enableKeyEvents:true,
cls: 'dis',
style:'normal 6px Ubuntu Mono, arial, verdana, sans-serif',
value: '',
listeners: {
change: function(este){
if (este.getValue()!="") {
Ext.getCmp(_this.id+'searchPanelButton').enable();