@jbrowse/plugin-linear-genome-view 1.5.0 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/BaseLinearDisplay/components/Block.d.ts +7 -10
  2. package/dist/LinearGenomeView/components/HelpDialog.d.ts +5 -0
  3. package/dist/LinearGenomeView/components/LinearGenomeView.d.ts +3 -5
  4. package/dist/LinearGenomeView/components/LinearGenomeViewSvg.d.ts +4 -0
  5. package/dist/LinearGenomeView/components/OverviewRubberBand.d.ts +2 -3
  6. package/dist/LinearGenomeView/components/OverviewScaleBar.d.ts +116 -2
  7. package/dist/LinearGenomeView/components/RefNameAutocomplete.d.ts +3 -1
  8. package/dist/LinearGenomeView/components/ScaleBar.d.ts +14 -0
  9. package/dist/LinearGenomeView/components/util.d.ts +1 -1
  10. package/dist/LinearGenomeView/index.d.ts +9 -2
  11. package/dist/plugin-linear-genome-view.cjs.development.js +3163 -2886
  12. package/dist/plugin-linear-genome-view.cjs.development.js.map +1 -1
  13. package/dist/plugin-linear-genome-view.cjs.production.min.js +1 -1
  14. package/dist/plugin-linear-genome-view.cjs.production.min.js.map +1 -1
  15. package/dist/plugin-linear-genome-view.esm.js +3122 -2845
  16. package/dist/plugin-linear-genome-view.esm.js.map +1 -1
  17. package/package.json +4 -4
  18. package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +0 -1
  19. package/src/BaseLinearDisplay/components/Block.tsx +20 -33
  20. package/src/LinearGenomeView/components/Header.tsx +19 -7
  21. package/src/LinearGenomeView/components/HelpDialog.tsx +81 -0
  22. package/src/LinearGenomeView/components/ImportForm.tsx +42 -51
  23. package/src/LinearGenomeView/components/LinearGenomeView.tsx +30 -245
  24. package/src/LinearGenomeView/components/LinearGenomeViewSvg.tsx +317 -0
  25. package/src/LinearGenomeView/components/OverviewRubberBand.tsx +74 -34
  26. package/src/LinearGenomeView/components/OverviewScaleBar.tsx +326 -177
  27. package/src/LinearGenomeView/components/RefNameAutocomplete.tsx +145 -145
  28. package/src/LinearGenomeView/components/SearchResultsDialog.tsx +12 -34
  29. package/src/LinearGenomeView/components/SequenceDialog.tsx +9 -8
  30. package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +127 -78
  31. package/src/LinearGenomeView/components/util.ts +6 -4
  32. package/src/LinearGenomeView/index.tsx +55 -14
  33. package/src/declare.d.ts +0 -1
@@ -17,52 +17,54 @@ exports[`<LinearGenomeView /> renders one track, one region 1`] = `
17
17
  >
18
18
  <div
19
19
  class="makeStyles-scaleBarVisibleRegion"
20
- style="width: 800px; left: 0px;"
20
+ style="width: 800px; left: 0px; background: rgba(121, 134, 203, 0.3); border-color: #7986cb;"
21
21
  />
22
22
  <div
23
23
  class="makeStyles-scaleBarContig"
24
24
  style="width: 0px; left: 0px; background-color: rgb(153, 153, 153);"
25
25
  />
26
- <div
27
- class="makeStyles-scaleBarContig makeStyles-scaleBarContigForward"
28
- style="left: 0px; width: 800px; border-color: rgb(153, 102, 0);"
29
- >
26
+ <div>
30
27
  <p
31
28
  class="MuiTypography-root makeStyles-scaleBarRefName MuiTypography-body1"
32
- style="color: rgb(153, 102, 0); z-index: 100;"
29
+ style="left: 3px; color: rgb(153, 102, 0);"
33
30
  >
34
31
  ctgA
35
32
  </p>
36
- <p
37
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
38
- style="left: 160px; pointer-events: none; color: rgb(153, 102, 0);"
39
- >
40
- 20
41
- </p>
42
- <p
43
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
44
- style="left: 320px; pointer-events: none; color: rgb(153, 102, 0);"
45
- >
46
- 40
47
- </p>
48
- <p
49
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
50
- style="left: 480px; pointer-events: none; color: rgb(153, 102, 0);"
51
- >
52
- 60
53
- </p>
54
- <p
55
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
56
- style="left: 640px; pointer-events: none; color: rgb(153, 102, 0);"
57
- >
58
- 80
59
- </p>
60
- <p
61
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
62
- style="left: 800px; pointer-events: none; color: rgb(153, 102, 0);"
33
+ <div
34
+ class="makeStyles-scaleBarContig makeStyles-scaleBarContigForward makeStyles-scaleBarBorder"
35
+ style="left: 0px; width: 800px; border-color: rgb(153, 102, 0);"
63
36
  >
64
- 100
65
- </p>
37
+ <p
38
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
39
+ style="left: 160px; pointer-events: none; color: rgb(153, 102, 0);"
40
+ >
41
+ 20
42
+ </p>
43
+ <p
44
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
45
+ style="left: 320px; pointer-events: none; color: rgb(153, 102, 0);"
46
+ >
47
+ 40
48
+ </p>
49
+ <p
50
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
51
+ style="left: 480px; pointer-events: none; color: rgb(153, 102, 0);"
52
+ >
53
+ 60
54
+ </p>
55
+ <p
56
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
57
+ style="left: 640px; pointer-events: none; color: rgb(153, 102, 0);"
58
+ >
59
+ 80
60
+ </p>
61
+ <p
62
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
63
+ style="left: 800px; pointer-events: none; color: rgb(153, 102, 0);"
64
+ >
65
+ 100
66
+ </p>
67
+ </div>
66
68
  </div>
67
69
  <div
68
70
  class="makeStyles-scaleBarContig"
@@ -77,7 +79,6 @@ exports[`<LinearGenomeView /> renders one track, one region 1`] = `
77
79
  <svg
78
80
  class="makeStyles-overviewSvg"
79
81
  height="48"
80
- width="100%"
81
82
  >
82
83
  <polygon
83
84
  fill="rgba(121, 134, 203, 0.3)"
@@ -206,6 +207,29 @@ exports[`<LinearGenomeView /> renders one track, one region 1`] = `
206
207
  d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
207
208
  />
208
209
  </svg>
210
+ <button
211
+ class="MuiButtonBase-root MuiIconButton-root"
212
+ tabindex="0"
213
+ type="button"
214
+ >
215
+ <span
216
+ class="MuiIconButton-label"
217
+ >
218
+ <svg
219
+ aria-hidden="true"
220
+ class="MuiSvgIcon-root"
221
+ focusable="false"
222
+ viewBox="0 0 24 24"
223
+ >
224
+ <path
225
+ d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"
226
+ />
227
+ </svg>
228
+ </span>
229
+ <span
230
+ class="MuiTouchRipple-root"
231
+ />
232
+ </button>
209
233
  </div>
210
234
  <div
211
235
  class="MuiAutocomplete-endAdornment"
@@ -580,67 +604,70 @@ exports[`<LinearGenomeView /> renders two tracks, two regions 1`] = `
580
604
  >
581
605
  <div
582
606
  class="makeStyles-scaleBarVisibleRegion"
583
- style="width: 580px; left: 0px;"
607
+ style="width: 580px; left: 0px; background: rgba(121, 134, 203, 0.3); border-color: #7986cb;"
584
608
  />
585
609
  <div
586
610
  class="makeStyles-scaleBarContig"
587
611
  style="width: 0px; left: 0px; background-color: rgb(153, 153, 153);"
588
612
  />
589
- <div
590
- class="makeStyles-scaleBarContig makeStyles-scaleBarContigForward"
591
- style="left: 0px; width: 72.72727272727273px; border-color: rgb(153, 102, 0);"
592
- >
613
+ <div>
593
614
  <p
594
615
  class="MuiTypography-root makeStyles-scaleBarRefName MuiTypography-body1"
595
- style="color: rgb(153, 102, 0); z-index: 100;"
616
+ style="left: 3px; color: rgb(153, 102, 0);"
596
617
  >
597
618
  ctgA
598
619
  </p>
620
+ <div
621
+ class="makeStyles-scaleBarContig makeStyles-scaleBarContigForward makeStyles-scaleBarBorder"
622
+ style="left: 0px; width: 72.72727272727273px; border-color: rgb(153, 102, 0);"
623
+ />
599
624
  </div>
600
625
  <div
601
626
  class="makeStyles-scaleBarContig"
602
627
  style="width: 0px; left: 72.72727272727273px; background-color: rgb(153, 153, 153);"
603
628
  />
604
- <div
605
- class="makeStyles-scaleBarContig makeStyles-scaleBarContigForward"
606
- style="left: 72.72727272727273px; width: 727.2727272727273px;"
607
- >
629
+ <div>
608
630
  <p
609
631
  class="MuiTypography-root makeStyles-scaleBarRefName MuiTypography-body1"
610
- style="z-index: 100;"
632
+ style="left: 75.72727272727273px;"
611
633
  >
612
634
  ctgB
613
635
  </p>
614
- <p
615
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
616
- style="left: 145.0909090909091px; pointer-events: none;"
617
- >
618
- 1,200
619
- </p>
620
- <p
621
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
622
- style="left: 290.1818181818182px; pointer-events: none;"
623
- >
624
- 1,400
625
- </p>
626
- <p
627
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
628
- style="left: 435.27272727272725px; pointer-events: none;"
629
- >
630
- 1,600
631
- </p>
632
- <p
633
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
634
- style="left: 580.3636363636364px; pointer-events: none;"
635
- >
636
- 1,800
637
- </p>
638
- <p
639
- class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
640
- style="left: 725.4545454545454px; pointer-events: none;"
636
+ <div
637
+ class="makeStyles-scaleBarContig makeStyles-scaleBarContigForward makeStyles-scaleBarBorder"
638
+ style="left: 72.72727272727273px; width: 727.2727272727273px;"
641
639
  >
642
- 2,000
643
- </p>
640
+ <p
641
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
642
+ style="left: 145.0909090909091px; pointer-events: none;"
643
+ >
644
+ 1,200
645
+ </p>
646
+ <p
647
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
648
+ style="left: 290.1818181818182px; pointer-events: none;"
649
+ >
650
+ 1,400
651
+ </p>
652
+ <p
653
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
654
+ style="left: 435.27272727272725px; pointer-events: none;"
655
+ >
656
+ 1,600
657
+ </p>
658
+ <p
659
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
660
+ style="left: 580.3636363636364px; pointer-events: none;"
661
+ >
662
+ 1,800
663
+ </p>
664
+ <p
665
+ class="MuiTypography-root makeStyles-scaleBarLabel MuiTypography-body2"
666
+ style="left: 725.4545454545454px; pointer-events: none;"
667
+ >
668
+ 2,000
669
+ </p>
670
+ </div>
644
671
  </div>
645
672
  <div
646
673
  class="makeStyles-scaleBarContig"
@@ -655,7 +682,6 @@ exports[`<LinearGenomeView /> renders two tracks, two regions 1`] = `
655
682
  <svg
656
683
  class="makeStyles-overviewSvg"
657
684
  height="48"
658
- width="100%"
659
685
  >
660
686
  <polygon
661
687
  fill="rgba(121, 134, 203, 0.3)"
@@ -748,7 +774,7 @@ exports[`<LinearGenomeView /> renders two tracks, two regions 1`] = `
748
774
  class="MuiAutocomplete-root"
749
775
  data-testid="autocomplete"
750
776
  role="combobox"
751
- style="width: 235.22500000000002px;"
777
+ style="width: 255.22500000000002px;"
752
778
  >
753
779
  <div
754
780
  class="MuiFormControl-root MuiTextField-root makeStyles-headerRefName MuiFormControl-fullWidth"
@@ -784,6 +810,29 @@ exports[`<LinearGenomeView /> renders two tracks, two regions 1`] = `
784
810
  d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"
785
811
  />
786
812
  </svg>
813
+ <button
814
+ class="MuiButtonBase-root MuiIconButton-root"
815
+ tabindex="0"
816
+ type="button"
817
+ >
818
+ <span
819
+ class="MuiIconButton-label"
820
+ >
821
+ <svg
822
+ aria-hidden="true"
823
+ class="MuiSvgIcon-root"
824
+ focusable="false"
825
+ viewBox="0 0 24 24"
826
+ >
827
+ <path
828
+ d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"
829
+ />
830
+ </svg>
831
+ </span>
832
+ <span
833
+ class="MuiTouchRipple-root"
834
+ />
835
+ </button>
787
836
  </div>
788
837
  <div
789
838
  class="MuiAutocomplete-endAdornment"
@@ -1,8 +1,10 @@
1
1
  import BaseResult from '@jbrowse/core/TextSearch/BaseResults'
2
2
 
3
- export function dedupe(results?: BaseResult[]) {
4
- return results?.filter(
5
- (elem, index, self) =>
6
- index === self.findIndex(t => t.getId() === elem.getId()),
3
+ export function dedupe(
4
+ results: BaseResult[] = [],
5
+ cb: (result: BaseResult) => string,
6
+ ) {
7
+ return results.filter(
8
+ (elt, idx, self) => idx === self.findIndex(t => cb(t) === cb(elt)),
7
9
  )
8
10
  }
@@ -10,29 +10,34 @@ import {
10
10
  getContainingView,
11
11
  getSession,
12
12
  isViewContainer,
13
+ isSessionModelWithWidgets,
14
+ measureText,
13
15
  parseLocString,
14
16
  springAnimate,
15
- isSessionModelWithWidgets,
16
17
  } from '@jbrowse/core/util'
17
18
  import BaseResult from '@jbrowse/core/TextSearch/BaseResults'
18
19
  import { BlockSet, BaseBlock } from '@jbrowse/core/util/blockTypes'
19
20
  import calculateDynamicBlocks from '@jbrowse/core/util/calculateDynamicBlocks'
20
21
  import calculateStaticBlocks from '@jbrowse/core/util/calculateStaticBlocks'
21
22
  import { getParentRenderProps } from '@jbrowse/core/util/tracks'
22
- // misc
23
23
  import { transaction, autorun } from 'mobx'
24
24
  import {
25
- getSnapshot,
26
- types,
25
+ addDisposer,
27
26
  cast,
28
- Instance,
27
+ getSnapshot,
29
28
  getRoot,
30
29
  resolveIdentifier,
31
- addDisposer,
30
+ types,
31
+ Instance,
32
32
  } from 'mobx-state-tree'
33
33
 
34
34
  import Base1DView from '@jbrowse/core/util/Base1DViewModel'
35
35
  import PluginManager from '@jbrowse/core/PluginManager'
36
+ import clone from 'clone'
37
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
38
+ import { saveAs } from 'file-saver'
39
+
40
+ // icons
36
41
  import { TrackSelector as TrackSelectorIcon } from '@jbrowse/core/ui/Icons'
37
42
  import SyncAltIcon from '@material-ui/icons/SyncAlt'
38
43
  import VisibilityIcon from '@material-ui/icons/Visibility'
@@ -41,16 +46,13 @@ import FolderOpenIcon from '@material-ui/icons/FolderOpen'
41
46
  import PhotoCameraIcon from '@material-ui/icons/PhotoCamera'
42
47
  import ZoomInIcon from '@material-ui/icons/ZoomIn'
43
48
  import MenuOpenIcon from '@material-ui/icons/MenuOpen'
44
- import clone from 'clone'
45
- import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
46
- import { saveAs } from 'file-saver'
47
- import { renderToSvg } from './components/LinearGenomeView'
49
+
50
+ // locals
51
+ import { renderToSvg } from './components/LinearGenomeViewSvg'
48
52
  import RefNameAutocomplete from './components/RefNameAutocomplete'
49
53
  import ExportSvgDlg from './components/ExportSvgDialog'
50
54
  import ReturnToImportFormDlg from './components/ReturnToImportFormDialog'
51
55
 
52
- export { default as ReactComponent } from './components/LinearGenomeView'
53
-
54
56
  export interface BpOffset {
55
57
  refName?: string
56
58
  index: number
@@ -122,6 +124,7 @@ export function stateModelFactory(pluginManager: PluginManager) {
122
124
  ),
123
125
  trackLabels: 'overlapping' as 'overlapping' | 'hidden' | 'offset',
124
126
  showCenterLine: false,
127
+ showCytobandsSetting: true,
125
128
  }),
126
129
  )
127
130
  .volatile(() => ({
@@ -469,6 +472,9 @@ export function stateModelFactory(pluginManager: PluginManager) {
469
472
  },
470
473
  }))
471
474
  .actions(self => ({
475
+ setShowCytobands(flag: boolean) {
476
+ self.showCytobandsSetting = flag
477
+ },
472
478
  setWidth(newWidth: number) {
473
479
  self.volatileWidth = newWidth
474
480
  },
@@ -1215,11 +1221,34 @@ export function stateModelFactory(pluginManager: PluginManager) {
1215
1221
 
1216
1222
  return { zoom }
1217
1223
  })
1224
+ .views(self => ({
1225
+ get canShowCytobands() {
1226
+ return self.displayedRegions.length === 1 && this.anyCytobandsExist
1227
+ },
1228
+ get showCytobands() {
1229
+ return this.canShowCytobands && self.showCytobandsSetting
1230
+ },
1231
+ get anyCytobandsExist() {
1232
+ const { assemblyManager } = getSession(self)
1233
+ const { assemblyNames } = self
1234
+ return assemblyNames.some(
1235
+ asm => assemblyManager.get(asm)?.cytobands?.length,
1236
+ )
1237
+ },
1238
+
1239
+ get cytobandOffset() {
1240
+ return this.showCytobands
1241
+ ? measureText(self.displayedRegions[0].refName, 12) + 15
1242
+ : 0
1243
+ },
1244
+ }))
1218
1245
  .views(self => {
1219
1246
  let currentlyCalculatedStaticBlocks: BlockSet | undefined
1220
1247
  let stringifiedCurrentlyCalculatedStaticBlocks = ''
1221
1248
  return {
1222
1249
  menuItems(): MenuItem[] {
1250
+ const { canShowCytobands, showCytobands } = self
1251
+
1223
1252
  const menuItems: MenuItem[] = [
1224
1253
  {
1225
1254
  label: 'Return to import form',
@@ -1306,6 +1335,16 @@ export function stateModelFactory(pluginManager: PluginManager) {
1306
1335
  },
1307
1336
  ],
1308
1337
  },
1338
+ ...(canShowCytobands
1339
+ ? [
1340
+ {
1341
+ label: showCytobands ? 'Hide ideogram' : 'Show ideograms',
1342
+ onClick: () => {
1343
+ self.setShowCytobands(!showCytobands)
1344
+ },
1345
+ },
1346
+ ]
1347
+ : []),
1309
1348
  ]
1310
1349
 
1311
1350
  // add track's view level menu options
@@ -1399,8 +1438,9 @@ export function stateModelFactory(pluginManager: PluginManager) {
1399
1438
  label: 'Zoom to region',
1400
1439
  icon: ZoomInIcon,
1401
1440
  onClick: () => {
1402
- if (self.leftOffset && self.rightOffset) {
1403
- self.moveTo(self.leftOffset, self.rightOffset)
1441
+ const { leftOffset, rightOffset } = self
1442
+ if (leftOffset && rightOffset) {
1443
+ self.moveTo(leftOffset, rightOffset)
1404
1444
  }
1405
1445
  },
1406
1446
  },
@@ -1419,3 +1459,4 @@ export function stateModelFactory(pluginManager: PluginManager) {
1419
1459
  export { renderToSvg, RefNameAutocomplete }
1420
1460
  export type LinearGenomeViewStateModel = ReturnType<typeof stateModelFactory>
1421
1461
  export type LinearGenomeViewModel = Instance<LinearGenomeViewStateModel>
1462
+ export { default as ReactComponent } from './components/LinearGenomeView'
package/src/declare.d.ts DELETED
@@ -1 +0,0 @@
1
- declare module 'normalize-wheel'