-
Notifications
You must be signed in to change notification settings - Fork 2
/
epiviz-navigation.html
1885 lines (1626 loc) · 61.2 KB
/
epiviz-navigation.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
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
<!-- Polymer dependency -->
<link rel="import" href="bower_components/polymer/polymer-element.html" />
<!-- Epiviz imports dependency -->
<!-- <link rel="import" href="bower_components/epiviz-imports/epiviz-common-js.html"> -->
<!-- Epiviz behaviors dependency -->
<link rel="import" href="chart-behavior.html" />
<link rel="import" href="chart-settings.html" />
<link rel="import" href="chart-colors.html" />
<!-- Epiviz data behaviors dependency -->
<link rel="import" href="chart-data-behavior.html" />
<!-- <link rel="import" href="chart-add-behavior.html" /> -->
<link rel="import" href="chart-workspace-behavior.html" />
<link rel="import" href="chart-grid-behavior.html" />
<link rel="import" href="chart-draggable-behavior.html" />
<!-- Chart elements dependency -->
<link rel="import" href="epiviz-genes-track.html" />
<link rel="import" href="epiviz-ideogram-track.html" />
<link rel="import" href="bower_components/epiviz-mbrowser/epiviz-mbrowser.html" />
<!-- Polymer Behavior dependency -->
<link rel="import" href="bower_components/iron-fit-behavior/iron-fit-behavior.html" />
<!-- External Polymer Styles/elements dependency -->
<link rel="import" href="bower_components/iron-flex-layout/iron-flex-layout.html" />
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html" />
<link rel="import" href="bower_components/paper-input/paper-input.html" />
<link rel="import" href="bower_components/paper-dropdown/paper-dropdown.html">
<link rel="import" href="bower_components/paper-icon-button/paper-icon-button.html" />
<link rel="import" href="bower_components/paper-menu-button/paper-menu-button.html" />
<link rel="import" href="bower_components/paper-listbox/paper-listbox.html" />
<link rel="import" href="bower_components/paper-item/paper-item.html" />
<link rel="import" href="bower_components/iron-label/iron-label.html" />
<!--
<h2> App Component </h2>
epiviz-chart components are pure user interface (UI) elements. They cannot make data requests
or can directly interact with other epiviz elements on the page. Chart elements emit hover events
that propagate up the DOM hierarchy. To build interactive web applications or to coordinate
events, interactions and data requests across different chart elements, we encapsulate charts inside
app components.
Another essential part of the epiviz design is that data and plots are separated: you can visualize
multiple charts from the same data object without having to replicate the data. This way, data
queries are made by the data object, not per chart, which leads to a more responsive design of the
system.
epiviz-app components are abstract components that 1) manage layouts, 2) coordinate interactions
across charts by genomic position and 3) handle and cache data across charts.
<h2> `epiviz-navigation` </h2>
`epiviz-navigation` is an iapp component with genomic context linked to it.
Navigation elements provide UI functionality to search for a gene/probe and update the location
to a genomic region. In addition, `<epiviz-navigation>` has a collapse and expand feature.
When collapsed, it hides its children and provides a smaller compact ideogram-view of the current
genomic location of the element. When expanded, features such are navigating along the chromosome,
or navigating to a gene location are available.
To create an navigation element on a HTML page, add
<epiviz-navigation
chr="chr11"
start=1
end=10000>
.. can have epiviz-charts as children html nodes
<epiviz-genes-track></epiviz-genes-track>
<epiviz-scatter-plot></epiviz-scatter-plot>
</epiviz-navigation>
@demo demo/index-navigation.html Example page showing a navigation element with charts
-->
<dom-module id="epiviz-navigation">
<!-- <link rel="import" href="bower_components/epiviz-imports/epiviz-common-css.html"> -->
<template>
<style include="shared-settings"></style>
<style>
:host {
display: inline-block;
resize: both;
width: 99%;
margin: 10px;
border-radius: 5px;
/* overflow: auto; */
transition: width 0.01s, height 0.01s;
@apply (--shadow-elevation-2dp);
}
.flex {
@apply (--layout-horizontal);
align-items: center;
}
.flexchild {
padding: 10px;
}
#disableHeader {
pointer-events: none;
opacity: 0.4;
}
paper-button {
display: inline-block;
background: #4285f4;
color: #fff;
vertical-align: middle;
}
paper-icon-button {
background-color: #dedede;
color: black;
border-radius: 3px;
padding: 2px;
width: 28px;
height: 28px;
}
#logo {
vertical-align: middle;
}
.paper-header {
background-color: var(--google-grey-300);
padding-left: 5px;
}
paper-menu-button {
float: right;
}
iron-label {
color: #4285f4;
font-weight: bold;
font-size: 16px;
}
.isempty {
position: relative;
top: 50%;
left: 50%;
transform: translateX(-50%) translateY(-50%);
}
#header {
/* height: 50px; */
/* linear-gradient(white, #e0e2e2) */
}
.content {
min-height: 250px;
padding: 5px;
/* overflow: auto; */
}
.chartContainer {
/* min height should be height of largest plot */
display: grid;
grid-template-columns: repeat(6, 1fr);
grid-auto-rows: minmax(max-content, 100px);
grid-row-gap: 2px;
grid-column-gap: 2px;
}
#chartSettingsContainer {
position: absolute;
top: 0;
right: 0;
border: 1px solid #000;
border-radius: 2px;
margin: 1px;
}
.chartContainer ::slotted(.grid-plot) {
grid-row: span 1;
grid-column: span 2;
}
.chartContainer ::slotted(.grid-track) {
grid-column: span 6;
grid-row: span 1;
}
.chartContainer ::slotted(.grid-navigation) {
grid-row: span 1;
grid-column: span 6;
order: 2;
}
#header > a {
text-decoration: none;
}
#genomeInput {
--paper-dropdown-menu: {
width: 75px;
}
}
#geneSearch {
--paper-dropdown-menu: {
width: 125px;
}
} </style>
<div id="header" class="paper-header">
<!-- <iron-label>EPIVIZ NAVIGATION</iron-label> -->
<a href="http://epiviz.github.io" target="_blank" hidden$="{{noLogo}}">
<img id="logo" style="margin-top: 7px;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOYAAAA3CAYAAAAYCDYxAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACoJJREFUeNrsXT1MHDkUHiLaU9irTwrZ9IEIykhsJFKHSLc0d1I2zVKGq6AL6dgqSQkNm+J0EttsapCySClBIunhiHT1LejqO86P+5wzXnvGM2t7PMRPsvaHWa/f8j6/975neyYuLy+TKFGihCW34k8QJUp4Msmf/PDT7hv2MKD2x6/L5zdJSaZbgz3MsjaFt6bweoDXpO8x03sQTSJKCDLBQ1lmvGJM+0kAab+CQCTQLaHN5PjoBfTuM7270TyihAZMWd6TscJgzwMFI3nBFtqMhS4JpBRFdJnOZ4FPRGvCS3peU1y2zfRYiSZ/s4ApG+ubUAAKQK6i3Xb0NW9Z2whI5zn2sMjaZo6PRWDeYGAGBVA2ZgLjhkNAjujM9N0oGZCbAGVeCRKYTKc6dGrirXU2zk7Z4/pYvz8yroennzuhA5PLFwodfZMmyCG7BiEr5coUhh4nIHjwPid/+ONCjq//BJ2PPeu8xR7aY3QRKjD3FBNN6eBkwFSOyxc4xwWm91CPjZM81ssUr9ZH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zAMyvYNTULp2RPkVqlZUCpkCMNDLCO04MDVyEt/CQq6wRIHeS64vweT45cKB7lz38zNrfij/vhe45sctEtcTPOjA1JBCvaXojfYrWKisHTCH3amWEtjz3/ACAtiwY1izWsJ4hj5SPDKHzY2ddnmnL+v6NPfyoyzcdnBBgC5SLGgNdd/i1PY3H9rLSZ5xaZZpMJoELhbbCFqqFDIAuoLRifP8SrDDiN7ptJPqze7yeaQu9aafGnoZYOWF/Jw/Qc7GZGtuxjkx3mMCTq/KrngtvKXjNHgMHGb84Ua35IH2EfZWFapWVBiaMlLxTw+BMVx7iPkMjg/kC70dCoOJ3+ErwaHKAdSn3xyTAsfHPJ/pCNXkGKqfQ8w5m6aGl2wvU0fcWPN5Iv8J9Otua8ZFh+rjD2LY0KdQ85bg6vVfG9c6VAKbkRcjDrSb6kxFkuSN4wby3ejgAIAcl6kzGfc/gNnxrkrcbMd4xbsO3mdKvTq72Zno6SKyXpJeUejY2OGsiF5VsoZZZRK72Zd5KKibIPTfY07sZ5NA4QoAkxrVRJiglvQlUjxP1+TqhCU0C875O9wPoehke1YU4069ywBTDW5BDdxFqXozZ5QWA/iAkQMqhLW6T8NgxocK9UF7D24eXLOMGueua8fYcrvRxtiVvMqm4IP+k0HYVrCzloU9ygPGKKKrSYWAge6h1FCcQbFr6DvIy22Ba+YIB3Qlz/D6dpd3CgbwmCx+XoT9f3NBh7687/M4j9p3z+F2slrGcH8ZVlqC2SW0ajcsxyKBB1c6vdfQ7XVrMRaNEj5k541MoOoj/4ihVlFvxJ4gSJQIzSpQoEZhRokRgRokSJQIzSpQIzChRokRgRokSgRklSpQIzChRokRgRolSQbmxa2WjRKmy/CvAADGRSCbKNK1nAAAAAElFTkSuQmCC" alt="Epiviz" width="105" height="30"/>
</a>
<div style="display:inline-block" hidden$="{{collapsed}}">
<!-- <div style="display:inline-block" > -->
<epiviz-measurement-browser
user="{{user}}"
user-token="{{userToken}}"
collection-genome="{{collectionGenome}}"
hidden$="{{hideAddChart}}"
id="addChart"
ms-api="{{msApi}}"
genome="{{genome}}">
</epiviz-measurement-browser>
<!-- <epiviz-add-chart hidden$="{{hideAddChart}}" id="addChart"></epiviz-add-chart> -->
<!-- <slot id="chartHeader" name="header"></slot> -->
<!-- </div> -->
<!-- <div style="display:inline-block" > -->
<paper-icon-button hidden$="{{!showViewer}}" style="margin-top:10px;margin-left:10px;" dynamic-align vertical-align="bottom" title="Open viewer in a new window" icon="image:filter" on-click="openFullViewer"></paper-icon-button>
<!-- </div> -->
</div>
<!-- <a href="{{viewer}}" target="_blank">Full Viewer</a> -->
<paper-menu-button dynamic-align vertical-align="bottom" vertical-offset="24">
<paper-icon-button icon="menu" slot="dropdown-trigger"></paper-icon-button>
<paper-listbox slot="dropdown-content">
<paper-item toggles on-click="toggleSelected">Delete</paper-item>
<paper-item on-click="cloneNavigation">Clone</paper-item>
<paper-item on-click="toggleHeader">{{ _toggleText }}</paper-item>
</paper-listbox>
</paper-menu-button>
</div>
<div class="content">
<div hidden$="{{!collapsed}}">
<epiviz-ideogram-track hidden$="{{!collapsed}}" gene-in-range="{{geneInRange}}" id="navTrack" chromosome="{{chr}}"
start="{{start}}" end="{{end}}"></epiviz-ideogram-track>
</div>
<iron-collapse id="navHeader" hidden$="{{collapsed}}" opened>
<div class="container flex" id="{{_headerName}}">
<div class="flexchild" hidden$="{{hideNav}}">
<paper-icon-button title="move left" icon="icons:chevron-left" on-click="moveLeft"></paper-icon-button>
<paper-icon-button title="move right" icon="icons:chevron-right" on-click="moveRight"></paper-icon-button>
<paper-icon-button id="ZoomOutButton" on-down="_onZoomOutDown" on-up="_onZoomOutUp"
title="zoom out" icon="icons:zoom-out" ></paper-icon-button>
<iron-dropdown id="ZoomOutDropdown" no-cancel-on-outside-click no-overlap>
<paper-listbox slot="dropdown-content">
<paper-item value="2" on-click="setZoomOut">2x ([[getBPZoomOut(range, zoomOutRatio, 2)]])</paper-item>
<paper-item value="5" on-click="setZoomOut">5x ([[getBPZoomOut(range, zoomOutRatio, 5)]])</paper-item>
<paper-item value="10" on-click="setZoomOut">10x ([[getBPZoomOut(range, zoomOutRatio, 10)]])</paper-item>
<paper-item value="100" on-click="setZoomOut">100x ([[getBPZoomOut(range, zoomOutRatio, 100)]])</paper-item>
</paper-listbox>
</iron-dropdown>
<!-- on-click="zoomIn" -->
<paper-icon-button id="ZoomInButton" on-down="_onZoomInDown" on-up="_onZoomInUp"
title="zoom in" icon="icons:zoom-in" ></paper-icon-button>
<iron-dropdown id="ZoomInDropdown" no-cancel-on-outside-click no-overlap>
<paper-listbox slot="dropdown-content">
<paper-item value="2" on-click="setZoomIn">1/2x ([[getBPZoomIn(range, zoomInRatio, 2)]])</paper-item>
<paper-item value="5" on-click="setZoomIn">1/5x ([[getBPZoomIn(range, zoomInRatio, 5)]])</paper-item>
<paper-item value="10" on-click="setZoomIn">1/10x ([[getBPZoomIn(range, zoomInRatio, 10)]])</paper-item>
<paper-item value="100" on-click="setZoomIn">1/100x ([[getBPZoomIn(range, zoomInRatio, 100)]])</paper-item>
</paper-listbox>
</iron-dropdown>
</div>
<div class="flexchild" hidden$="{{hideSearch}}">
<paper-dropdown-input id="geneSearch" label="Search" on-search-value-changed="_searchGene">
<template>
<dom-repeat items="[[items]]" as="item">
<template>
<paper-item on-tap="_selectGene" role="option" aria-selected="false">
<div>
[[item.gene]]
</div>
<paper-ripple></paper-ripple>
</paper-item>
</template>
</dom-repeat>
</template>
</paper-dropdown-input>
</div>
<div class="flexchild" hidden$="{{hideGenomeInput}}">
<!-- <paper-input id="textGenome" value="{{genome}}"
label="Genome"
on-change="_updateGenome"
></paper-input> -->
<paper-dropdown disabled id="genomeInput" name="Genome" label="Genome" value="{{genome}}" no-animations
horizontal-align="left">
<template id="itemRepeater" is="dom-repeat" items="[[_genomeList]]">
<paper-item value$="[[item]]">[[item]]</paper-item>
</template>
</paper-dropdown>
</div>
<div class="flexchild" hidden$="{{hideChrInput}}" on-mouseover="locationHovered" on-mouseout="locationUnhovered">
<paper-input id="textRange" value="{{_strRange}}"
label="Chromosome Location"
on-change="_updateStrRange"
></paper-input>
</div>
</div>
<div class="content chartContainer">
<slot id="chartNav" name="charts"></slot>
</div>
</iron-collapse>
</div>
</template>
<script>
// Extend Polymer.Element base class
class EpivizNavigation extends EpivizChartDraggableBehavior(
EpivizChartGridBehavior(
EpivizChartWorkspaceBehavior(
EpivizChartAddBehavior(
EpivizChartDataBehavior(EpivizChartBehavior(Polymer.Element))
)
)
)
) {
static get is() {
return "epiviz-navigation";
}
static get properties() {
return {
/**
* genome.
* Default genome to set to all the children chart elements.
*
* @example: hg38
*
* @type {string}
*/
genome: {
type: String,
notify: true,
observer: "_genomeChanged",
value: null
},
msApi: {
type: String,
notify:true
},
/**
* Chromosome location.
* Default Location Attribute to set to all the children chart elements.
*
* @example: chr1
*
* @type {string}
*/
chr: {
type: String,
notify: true,
reflectToAttribute: true
},
/**
* Chromosome start.
* Default Chromosome start value to use. (defaults to 0).
*
* @type {number}
*/
start: {
type: Number,
notify: true,
reflectToAttribute: true
},
/**
* Chromosome end.
* Default Chromosome end value to use. (defaults to the `<chr>` length).
*
* @type {number}
*/
end: {
type: Number,
notify: true,
reflectToAttribute: true
},
viewer: {
type: String
},
/**
* Unique plot-id. an id will be assigned if not set
*
* @type {string}
*/
plotId: {
type: String,
reflectToAttribute: true,
notify: true
},
/**
* Updates location attributes(chr, start, end) to this gene's location.
*
* @type {string}
*/
gene: {
type: String,
observer: "_geneUpdate"
},
/**
* Computed Range from `<chr>`, `<start>` & `<end>`.
*
* @type {Object<epiviz.datatypes.GenomicRange>}
*/
range: {
type: Object,
observer: "_rangeUpdate"
},
/**
* Computed Range from `<chr>`, `<start>` & `<end>`.
*
* @type {string}
*/
_strRange: {
type: String,
notify: true,
computed: "getStrRange(chr, start, end)"
},
/**
* helper header name
*
* @type {string}
*/
_headerName: {
type: String,
notify: true,
value: "enableHeader"
},
/**
* helper toggle text
*
* @type {string}
*/
_toggleText: {
type: String,
notify: true,
computed: "_computeToggleText(collapsed)"
},
/**
* Default scroll left/right ratio
*
* @type {number}
*/
stepRatio: {
type: Number,
notify: true,
value: 0.2
},
/**
* Default zoom in/out ratio
*
* @type {number}
*/
zoomRatio: {
type: Number,
notify: true,
value: 0.2
},
zoomInRatio: {
type: Number,
notify: true,
value: 1.2
},
zoomOutRatio: {
type: Number,
notify: true,
value: 1.2
},
/**
* padding around gene (wrt gene length)
*
* @type {number}
*/
geneRatio: {
type: Number,
notify: true,
value: 0.2
},
/**
* Whether the element is collapsed
*
* @type {boolean}
*/
collapsed: {
type: Boolean,
notify: true,
value: function () {
return false;
}
},
/**
* Whether the element has no children
*
* @type {boolean}
*/
_isEmpty: {
type: Boolean,
notify: true,
value: function () {
return false;
}
},
/**
* Current gene in range (set automatically)
*
* @type {string}
*/
geneInRange: {
type: String,
notify: true
},
/**
* helper header class name
*
* @type {string}
*/
headerClassName: {
type: String,
notify: true
},
/**
* Whether to hide logo
*
* @type {string}
*/
noLogo: {
type: Boolean,
notify: true,
reflectToAttribute: true,
value: false
},
/**
* measurements available on this element
*
* @type {string}
*/
measurements: {
type: Object,
notify: true,
reflectToAttribute: true
},
measurementSet: {
type: Object,
notify: true
},
/**
* Default chart properties for navigation element.
*
* @type {Object}
*/
configSrc: {
type: Object,
notify: true,
value: function () {
epiviz.Config.SETTINGS = {
dataProviders: [
[
"epiviz.data.WebServerDataProvider",
"umd",
"http://epiviz-dev.cbcb.umd.edu/api/"
]
],
workspacesDataProvider: sprintf(
"epiviz.data.EmptyResponseDataProvider",
"empty",
""
),
useCache: true,
colorPalettes: [],
maxSearchResults: 12
};
return epiviz.Config.SETTINGS;
}
},
geneMeasurements: {
type: Object,
notify: true
},
hideSearch: {
type: Boolean,
notify: true,
value: false
},
hideNav: {
type: Boolean,
notify: true,
value: false
},
hideChrInput: {
type: Boolean,
notify: true,
value: false
},
hideAddChart: {
type: Boolean,
notify: true,
value: false
},
hideGenomeInput: {
type: Boolean,
notify: true,
value: false
},
showViewer: {
type: Boolean,
notify: true,
value: false
},
_zoomIn: {
type: Number,
value: 0
},
_genomeList: {
type: String,
notify: true,
computed: "_getGenomes(genomes)"
},
genomes: {
type: Object,
notify: true
},
collectionGenome: {
type: String,
notify: true,
observer: "_collectionGenomeUpdated"
},
upstream: {
type: Number,
value: 100000
},
downstream: {
type: Number,
value: 50000
},
user: {
type: String,
notify: true
},
userToken: {
type: String,
notify: true
}
};
}
static get observers() {
return [
'_measurementSetChanged(measurementSet.*)',
'_genomicRegionChanged(chr, start, end)'
];
}
constructor() {
super();
this.addEventListener("hover", e => this.onHover(e));
this.addEventListener("unHover", e => this.onUnhover(e));
this.addEventListener("select", e => this.onSelect(e));
this.addEventListener("deSelect", e => this.onDeSelect(e));
this.addEventListener("GenesTrackRangeUpdate", e => this.onGenesTrackRangeUpdate(e));
this.addEventListener("iron-resize", e => {
this._debouncer = Polymer.Debouncer.debounce(
this._debouncer,
Polymer.Async.timeOut.after(750),
() => this._onResize(e)
);
});
this._getElementSeqInfo(this, this);
this.geneUpdateFlag = true;
// this.addEventListener('transitionend', e => this._onResize(e));
}
setZoomOut(e) {
// console.log(e);
var zoomOutRatio = e.target.getAttribute("value");
this.shadowRoot.querySelector("#ZoomOutDropdown").close();
var width = Math.round(this.end - this.start);
// var mid = Math.round(this.start + width / 2);
var newWidthFactor = Math.round(width * zoomOutRatio);
var center = Math.round( (this.start + this.end) /2 );
var newStart = center - Math.round(newWidthFactor/2);
var newEnd = center + Math.round(newWidthFactor/2);
this.start = Math.max(0, newStart);
this.end = Math.min(newEnd, this.seqInfo[this.chr].max);
this.range = this.getGenomicRange(this.chr, this.start, this.end, this.genome);
this._strRange = this.getStrRange(this.chr, this.start, this.end);
}
setZoomIn(e) {
// console.log(e);
var zoomInRatio = e.target.getAttribute("value");
this.shadowRoot.querySelector("#ZoomInDropdown").close();
this._zoomIn++;
var width = Math.round(this.end - this.start);
// var mid = Math.round(this.start + width / 2);
var newWidthFactor = Math.round(width / zoomInRatio);
var center = Math.round( (this.start + this.end) /2 );
var newStart = center + Math.round(newWidthFactor/2);
var newEnd = center - Math.round(newWidthFactor/2);
this.start = Math.max(0, newStart);
this.end = Math.min(newEnd, this.seqInfo[this.chr].max);
this.range = this.getGenomicRange(this.chr, this.start, this.end, this.genome);
this._strRange = this.getStrRange(this.chr, this.start, this.end);
}
_collectionGenomeUpdated(nVal, oVal) {
if (this.genome != this.collectionGenome) {
this.genome = this.collectionGenome;
}
}
_getCurrentZoomOutValue(range, xfactor) {
if (this.range) {
return xfactor + "x ("+ Math.round(this.range.width() * xfactor/1000) + "Kb)";
}
}
_getCurrentZoomInValue(range, xfactor) {
if (this.range) {
return xfactor + "x ("+ Math.round(this.range.width() / (xfactor * 1000)) + "Kb)";
}
}
getBPZoomIn(range, ratio, xfactor) {
// console.log(ratio, xfactor);
if (this.range) {
return Math.round(this.range.width() / (xfactor * 1000)) + " Kb";
}
}
getBPZoomOut(range, ratio, xfactor) {
// console.log(ratio, xfactor);
if (this.range) {
return Math.round(this.range.width() * xfactor/1000) + " Kb";
}
}
_onZoomOutDown(e) {
this.startZoomOutTime = Date.now();
var self = this;
self._zoomOutTimeout = setTimeout(check, 300);
function check() {
self.shadowRoot.querySelector("#ZoomInDropdown").close();
self.shadowRoot.querySelector("#ZoomOutDropdown").open();
}
}
_onZoomOutUp(e) {
// console.log(e);
e.stopPropagation();
e.preventDefault();
clearTimeout(this._zoomOutTimeout);
if (!this.shadowRoot.querySelector("#ZoomOutDropdown").opened) {
var width = Math.round(this.end - this.start);
// var mid = Math.round(this.start + width / 2);
var newWidthFactor = Math.round(width * this.zoomOutRatio);
var center = Math.round( (this.start + this.end) /2 );
var newStart = center - Math.round(newWidthFactor/2);
var newEnd = center + Math.round(newWidthFactor/2);
this.start = Math.max(0, newStart);
this.end = Math.min(newEnd, this.seqInfo[this.chr].max);
this.range = this.getGenomicRange(this.chr, this.start, this.end, this.genome);
this._strRange = this.getStrRange(this.chr, this.start, this.end);
}
}
_onZoomInDown(e) {
this.startZoomInTime = Date.now();
var self = this;
self._zoomInTimeout = setTimeout(check, 300);
function check() {
self.shadowRoot.querySelector("#ZoomOutDropdown").close();
self.shadowRoot.querySelector("#ZoomInDropdown").open();
}
}
_onZoomInUp(e) {
// console.log(e);
e.stopPropagation();
e.preventDefault();
clearTimeout(this._zoomInTimeout);
if (!this.shadowRoot.querySelector("#ZoomInDropdown").opened) {
this._zoomIn++;
var width = Math.round(this.end - this.start);
// var mid = Math.round(this.start + width / 2);
var newWidthFactor = Math.round(width / this.zoomInRatio);
var center = Math.round( (this.start + this.end) /2 );
var newStart = center + Math.round(newWidthFactor/2);
var newEnd = center - Math.round(newWidthFactor/2);
this.start = Math.max(0, newStart);
this.end = Math.min(newEnd, this.seqInfo[this.chr].max);
this.range = this.getGenomicRange(this.chr, this.start, this.end, this.genome);
this._strRange = this.getStrRange(this.chr, this.start, this.end);
}
}
_genomicRegionChanged(chr, start, end) {
this.chr = chr;
this.start = start;
this.end = end;
this.range = this.getGenomicRange(this.chr, this.start, this.end, this.genome);
this._strRange = this.getStrRange(this.chr, this.start, this.end);
}
getUrlParameter(sParam) {
var currPage = decodeURIComponent(window.location.search.substring(1));
var pageVars = currPage.split('&');
for (var i = 0; i < pageVars.length; i++) {
var pageParamName = pageVars[i].split('=');
if (pageParamName[0] === sParam) {
return pageParamName[1] === undefined ? true : pageParamName[1];
}
}
}
connectedCallback() {
super.connectedCallback();
var self = this;
self._initializeGrid();
self._initializeSortable();
// self.shadowRoot.querySelector("#ZoomOutButton").addEventListener('long-press', function(e) {
// console.log(e.target);
// });
// self.shadowRoot.querySelector("#ZoomInButton").addEventListener('long-press', function(e) {
// console.log(e.target);
// });
var origCollapsed = self.collapsed || false;
self.collapsed = false;
if (!self.dataManager) {
self._headerName = "disableHeader";
}
if (self.useDefaultDataProvider) {
var dataProviderFactory = new epiviz.data.DataProviderFactory(
new epiviz.Config(self.configSrc)
);
var dataManager = new epiviz.data.DataManager(
self.config,
dataProviderFactory
);
dataManager.getSeqInfos(function (data) {
var seqinfo = {};
data.forEach(function (s) {
seqinfo[s.seqName] = s;
});
self.seqInfo = seqinfo;
});
}
// var ws = self.getUrlParameter("ws");
// var wid = self.getUrlParameter("wid");
// // if (!(ws || wid)) {
// var gene = self.getUrlParameter("gene");
// if (gene && gene != "") {
// this.flagWS = true;
// this.gene = gene;
// } else {
// if(self.workspace) {
// self.loadWorkspace(self.workspace);
// }
// }
// this.gene = gene;
// } else {
// var gene = self.getUrlParameter("gene");
// if (gene == "" || gene == null) {
// gene = this.gene;
// }
// this.gene = gene;
// }
// if (self.gene) {
// var range = {
// range: self.getGenomicRange(null, null, null, self.genome)
// }
// self._getElementSearch(self.gene, range, null, function (data) {
// self.chr = data[0].chr;
// var width = data[0].end - data[0].start;
// var newWidthFactor = Math.round(width * self.geneRatio);
// var newStart = data[0].start - newWidthFactor;
// var newEnd = data[0].end + newWidthFactor;
// self.start = Math.max(0, newStart);
// self.end = Math.min(newEnd, self.seqInfo[self.chr].max);
// self.range = self.getGenomicRange(self.chr, self.start, self.end, self.genome);
// self._strRange = self.getStrRange(self.chr, self.start, self.end);
// self.chartObject = new epiviz.ui.charts.ChartObject(
// self.plotId,
// self.start,
// self.end,
// undefined,
// undefined,
// undefined,
// undefined,
// undefined,
// self.chr
// );
// });
// } else
if (self.chr && self.start && self.end) {
self.range = self.getGenomicRange(self.chr, self.start, self.end, self.genome);
self._strRange = self.getStrRange(self.chr, self.start, self.end);
self.chartObject = new epiviz.ui.charts.ChartObject(
self.plotId,
self.start,
self.end,
undefined,
undefined,
undefined,
undefined,
undefined,
self.chr
);
}