@jbrowse/plugin-linear-genome-view 2.10.2 → 2.11.0

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 (75) hide show
  1. package/dist/BaseLinearDisplay/components/BlockMsg.d.ts +2 -4
  2. package/dist/BaseLinearDisplay/components/BlockMsg.js +2 -3
  3. package/dist/BaseLinearDisplay/components/LinearBlocks.js +2 -2
  4. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.d.ts +10 -2
  5. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +40 -4
  6. package/dist/BaseLinearDisplay/components/TooLargeMessage.js +5 -4
  7. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +18 -4
  8. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +9 -2
  9. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -1
  10. package/dist/LaunchLinearGenomeView/index.js +24 -8
  11. package/dist/LinearBareDisplay/model.d.ts +18 -4
  12. package/dist/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  13. package/dist/LinearBasicDisplay/model.d.ts +22 -4
  14. package/dist/LinearGenomeView/components/Cytobands.d.ts +1 -125
  15. package/dist/LinearGenomeView/components/ExportSvgDialog.js +9 -5
  16. package/dist/LinearGenomeView/components/Highlight.d.ts +7 -0
  17. package/dist/LinearGenomeView/components/Highlight.js +126 -0
  18. package/dist/LinearGenomeView/components/MiniControls.js +13 -15
  19. package/dist/LinearGenomeView/components/OverviewHighlight.d.ts +9 -0
  20. package/dist/LinearGenomeView/components/OverviewHighlight.js +62 -0
  21. package/dist/LinearGenomeView/components/OverviewRubberband.d.ts +1 -1
  22. package/dist/LinearGenomeView/components/OverviewScalebar.js +6 -1
  23. package/dist/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +1 -1
  24. package/dist/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +9 -9
  25. package/dist/LinearGenomeView/components/RefNameAutocomplete/index.js +28 -35
  26. package/dist/LinearGenomeView/components/Rubberband.d.ts +1 -1
  27. package/dist/LinearGenomeView/components/SearchBox.d.ts +1 -1
  28. package/dist/LinearGenomeView/components/SearchResultsTable.js +1 -1
  29. package/dist/LinearGenomeView/components/TrackContainer.js +10 -23
  30. package/dist/LinearGenomeView/components/TrackLabel.js +33 -6
  31. package/dist/LinearGenomeView/components/TracksContainer.js +2 -0
  32. package/dist/LinearGenomeView/components/ZoomControls.js +4 -4
  33. package/dist/LinearGenomeView/model.d.ts +70 -5
  34. package/dist/LinearGenomeView/model.js +111 -14
  35. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +1 -1
  36. package/dist/LinearGenomeView/util.d.ts +1 -1
  37. package/dist/index.d.ts +213 -21
  38. package/esm/BaseLinearDisplay/components/BlockMsg.d.ts +2 -4
  39. package/esm/BaseLinearDisplay/components/BlockMsg.js +3 -4
  40. package/esm/BaseLinearDisplay/components/LinearBlocks.js +2 -2
  41. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.d.ts +10 -2
  42. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +17 -4
  43. package/esm/BaseLinearDisplay/components/TooLargeMessage.js +5 -4
  44. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +18 -4
  45. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +9 -2
  46. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -1
  47. package/esm/LaunchLinearGenomeView/index.js +25 -9
  48. package/esm/LinearBareDisplay/model.d.ts +18 -4
  49. package/esm/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  50. package/esm/LinearBasicDisplay/model.d.ts +22 -4
  51. package/esm/LinearGenomeView/components/Cytobands.d.ts +1 -125
  52. package/esm/LinearGenomeView/components/ExportSvgDialog.js +9 -5
  53. package/esm/LinearGenomeView/components/Highlight.d.ts +7 -0
  54. package/esm/LinearGenomeView/components/Highlight.js +98 -0
  55. package/esm/LinearGenomeView/components/MiniControls.js +14 -16
  56. package/esm/LinearGenomeView/components/OverviewHighlight.d.ts +9 -0
  57. package/esm/LinearGenomeView/components/OverviewHighlight.js +57 -0
  58. package/esm/LinearGenomeView/components/OverviewRubberband.d.ts +1 -1
  59. package/esm/LinearGenomeView/components/OverviewScalebar.js +7 -2
  60. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +1 -1
  61. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +9 -9
  62. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.js +28 -35
  63. package/esm/LinearGenomeView/components/Rubberband.d.ts +1 -1
  64. package/esm/LinearGenomeView/components/SearchBox.d.ts +1 -1
  65. package/esm/LinearGenomeView/components/SearchResultsTable.js +1 -1
  66. package/esm/LinearGenomeView/components/TrackContainer.js +10 -23
  67. package/esm/LinearGenomeView/components/TrackLabel.js +33 -6
  68. package/esm/LinearGenomeView/components/TracksContainer.js +2 -0
  69. package/esm/LinearGenomeView/components/ZoomControls.js +4 -4
  70. package/esm/LinearGenomeView/model.d.ts +70 -5
  71. package/esm/LinearGenomeView/model.js +112 -15
  72. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +1 -1
  73. package/esm/LinearGenomeView/util.d.ts +1 -1
  74. package/esm/index.d.ts +213 -21
  75. package/package.json +2 -2
@@ -2,7 +2,7 @@ import { lazy } from 'react';
2
2
  import { getConf } from '@jbrowse/core/configuration';
3
3
  import { BaseViewModel } from '@jbrowse/core/pluggableElementTypes/models';
4
4
  import { ElementId, Region as MUIRegion } from '@jbrowse/core/util/types/mst';
5
- import { assembleLocString, clamp, findLast, getContainingView, getSession, isViewContainer, isSessionModelWithWidgets, isSessionWithAddTracks, localStorageGetItem, measureText, springAnimate, sum, } from '@jbrowse/core/util';
5
+ import { assembleLocString, clamp, findLast, getContainingView, getSession, isViewContainer, isSessionModelWithWidgets, isSessionWithAddTracks, localStorageGetItem, localStorageSetItem, measureText, springAnimate, sum, } from '@jbrowse/core/util';
6
6
  import calculateDynamicBlocks from '@jbrowse/core/util/calculateDynamicBlocks';
7
7
  import calculateStaticBlocks from '@jbrowse/core/util/calculateStaticBlocks';
8
8
  import { getParentRenderProps } from '@jbrowse/core/util/tracks';
@@ -21,6 +21,8 @@ import FolderOpenIcon from '@mui/icons-material/FolderOpen';
21
21
  import PhotoCameraIcon from '@mui/icons-material/PhotoCamera';
22
22
  import ZoomInIcon from '@mui/icons-material/ZoomIn';
23
23
  import MenuOpenIcon from '@mui/icons-material/MenuOpen';
24
+ import PaletteIcon from '@mui/icons-material/Palette';
25
+ import SearchIcon from '@mui/icons-material/Search';
24
26
  import MiniControls from './components/MiniControls';
25
27
  import Header from './components/Header';
26
28
  import { generateLocations, parseLocStrings } from './util';
@@ -97,7 +99,6 @@ export function stateModelFactory(pluginManager) {
97
99
  tracks: types.array(pluginManager.pluggableMstType('track', 'stateModel')),
98
100
  /**
99
101
  * #property
100
- * array of currently displayed tracks state model's
101
102
  */
102
103
  hideHeader: false,
103
104
  /**
@@ -136,6 +137,16 @@ export function stateModelFactory(pluginManager) {
136
137
  * show the "gridlines" in the track area
137
138
  */
138
139
  showGridlines: true,
140
+ /**
141
+ * #property
142
+ * highlights on the LGV from the URL parameters
143
+ */
144
+ highlight: types.optional(types.array(types.frozen()), []),
145
+ /**
146
+ * #property
147
+ * color by CDS
148
+ */
149
+ colorByCDS: types.optional(types.boolean, () => Boolean(JSON.parse(localStorageGetItem('lgv-colorByCDS') || 'false'))),
139
150
  }))
140
151
  .volatile(() => ({
141
152
  volatileWidth: undefined,
@@ -326,7 +337,7 @@ export function stateModelFactory(pluginManager) {
326
337
  return {
327
338
  ...getParentRenderProps(self),
328
339
  bpPerPx: self.bpPerPx,
329
- highResolutionScaling: getConf(getSession(self), 'highResolutionScaling'),
340
+ colorByCDS: self.colorByCDS,
330
341
  };
331
342
  },
332
343
  /**
@@ -397,6 +408,12 @@ export function stateModelFactory(pluginManager) {
397
408
  },
398
409
  }))
399
410
  .actions(self => ({
411
+ /**
412
+ * #action
413
+ */
414
+ setColorByCDS(flag) {
415
+ self.colorByCDS = flag;
416
+ },
400
417
  /**
401
418
  * #action
402
419
  */
@@ -439,6 +456,25 @@ export function stateModelFactory(pluginManager) {
439
456
  setShowGridlines(b) {
440
457
  self.showGridlines = b;
441
458
  },
459
+ /**
460
+ * #action
461
+ */
462
+ addToHighlights(highlight) {
463
+ var _a;
464
+ (_a = self.highlight) === null || _a === void 0 ? void 0 : _a.push(highlight);
465
+ },
466
+ /**
467
+ * #action
468
+ */
469
+ setHighlight(highlight) {
470
+ self.highlight = cast(highlight);
471
+ },
472
+ /**
473
+ * #action
474
+ */
475
+ removeHighlight(highlight) {
476
+ self.highlight.remove(highlight);
477
+ },
442
478
  /**
443
479
  * #action
444
480
  */
@@ -558,6 +594,47 @@ export function stateModelFactory(pluginManager) {
558
594
  },
559
595
  }))
560
596
  .actions(self => ({
597
+ /**
598
+ * #action
599
+ */
600
+ moveTrackDown(id) {
601
+ const idx = self.tracks.findIndex(v => v.id === id);
602
+ if (idx === -1) {
603
+ return;
604
+ }
605
+ if (idx !== -1 && idx < self.tracks.length - 1) {
606
+ self.tracks.splice(idx, 2, self.tracks[idx + 1], self.tracks[idx]);
607
+ }
608
+ },
609
+ /**
610
+ * #action
611
+ */
612
+ moveTrackUp(id) {
613
+ const idx = self.tracks.findIndex(track => track.id === id);
614
+ if (idx > 0) {
615
+ self.tracks.splice(idx - 1, 2, self.tracks[idx], self.tracks[idx - 1]);
616
+ }
617
+ },
618
+ /**
619
+ * #action
620
+ */
621
+ moveTrackToTop(id) {
622
+ const idx = self.tracks.findIndex(track => track.id === id);
623
+ self.tracks = cast([
624
+ self.tracks[idx],
625
+ ...self.tracks.filter(track => track.id !== id),
626
+ ]);
627
+ },
628
+ /**
629
+ * #action
630
+ */
631
+ moveTrackToBottom(id) {
632
+ const idx = self.tracks.findIndex(track => track.id === id);
633
+ self.tracks = cast([
634
+ ...self.tracks.filter(track => track.id !== id),
635
+ self.tracks[idx],
636
+ ]);
637
+ },
561
638
  /**
562
639
  * #action
563
640
  */
@@ -570,9 +647,9 @@ export function stateModelFactory(pluginManager) {
570
647
  if (newIndex === -1) {
571
648
  throw new Error(`Track ID ${targetId} not found`);
572
649
  }
573
- const track = getSnapshot(self.tracks[oldIndex]);
574
- self.tracks.splice(oldIndex, 1);
575
- self.tracks.splice(newIndex, 0, track);
650
+ const tracks = self.tracks.filter((_, idx) => idx !== oldIndex);
651
+ tracks.splice(newIndex, 0, self.tracks[oldIndex]);
652
+ self.tracks = cast(tracks);
576
653
  },
577
654
  /**
578
655
  * #action
@@ -763,7 +840,7 @@ export function stateModelFactory(pluginManager) {
763
840
  * perform animated slide
764
841
  */
765
842
  function slide(viewWidths) {
766
- const [animate, cancelAnimation] = springAnimate(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo);
843
+ const [animate, cancelAnimation] = springAnimate(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo, undefined, undefined, 200);
767
844
  cancelLastAnimation();
768
845
  cancelLastAnimation = cancelAnimation;
769
846
  animate();
@@ -850,6 +927,7 @@ export function stateModelFactory(pluginManager) {
850
927
  ? [
851
928
  {
852
929
  label: 'Sequence search',
930
+ icon: SearchIcon,
853
931
  onClick: () => {
854
932
  getSession(self).queueDialog(handleClose => [
855
933
  SequenceSearchDialog,
@@ -879,6 +957,13 @@ export function stateModelFactory(pluginManager) {
879
957
  icon: SyncAltIcon,
880
958
  onClick: self.horizontallyFlip,
881
959
  },
960
+ {
961
+ label: 'Color by CDS',
962
+ type: 'checkbox',
963
+ checked: self.colorByCDS,
964
+ icon: PaletteIcon,
965
+ onClick: () => self.setColorByCDS(!self.colorByCDS),
966
+ },
882
967
  {
883
968
  label: 'Show...',
884
969
  icon: VisibilityIcon,
@@ -1043,11 +1128,10 @@ export function stateModelFactory(pluginManager) {
1043
1128
  }, { delay: 150 }));
1044
1129
  addDisposer(self, autorun(() => {
1045
1130
  const s = (s) => JSON.stringify(s);
1046
- const { showCytobandsSetting, showCenterLine } = self;
1047
- if (typeof localStorage !== 'undefined') {
1048
- localStorage.setItem('lgv-showCytobands', s(showCytobandsSetting));
1049
- localStorage.setItem('lgv-showCenterLine', s(showCenterLine));
1050
- }
1131
+ const { showCytobandsSetting, showCenterLine, colorByCDS } = self;
1132
+ localStorageSetItem('lgv-showCytobands', s(showCytobandsSetting));
1133
+ localStorageSetItem('lgv-showCenterLine', s(showCenterLine));
1134
+ localStorageSetItem('lgv-colorByCDS', s(colorByCDS));
1051
1135
  }));
1052
1136
  },
1053
1137
  }))
@@ -1231,8 +1315,9 @@ export function stateModelFactory(pluginManager) {
1231
1315
  },
1232
1316
  /**
1233
1317
  * #method
1234
- * scrolls the view to center on the given bp. if that is not in any
1235
- * of the displayed regions, does nothing
1318
+ * scrolls the view to center on the given bp. if that is not in any of
1319
+ * the displayed regions, does nothing
1320
+ *
1236
1321
  * @param coord - basepair at which you want to center the view
1237
1322
  * @param refName - refName of the displayedRegion you are centering at
1238
1323
  * @param regionNumber - index of the displayedRegion
@@ -1290,7 +1375,19 @@ export function stateModelFactory(pluginManager) {
1290
1375
  document.removeEventListener('keydown', handler);
1291
1376
  });
1292
1377
  },
1293
- }));
1378
+ }))
1379
+ .preProcessSnapshot(snap => {
1380
+ if (!snap) {
1381
+ return snap;
1382
+ }
1383
+ const { highlight, ...rest } = snap;
1384
+ return {
1385
+ highlight: Array.isArray(highlight) || highlight === undefined
1386
+ ? highlight
1387
+ : [highlight],
1388
+ ...rest,
1389
+ };
1390
+ });
1294
1391
  }
1295
1392
  export { default as ReactComponent, default as LinearGenomeView, } from './components/LinearGenomeView';
1296
1393
  export { default as RefNameAutocomplete } from './components/RefNameAutocomplete';
@@ -13,7 +13,7 @@ import { totalHeight } from './util';
13
13
  // render LGV to SVG
14
14
  export async function renderToSvg(model, opts) {
15
15
  await when(() => model.initialized);
16
- const { textHeight = 18, headerHeight = 40, rulerHeight = 50, fontSize = 13, cytobandHeight = 100, trackLabels = 'offset', themeName = 'default', Wrapper = ({ children }) => React.createElement(React.Fragment, null, children), } = opts;
16
+ const { textHeight = 18, headerHeight = 40, rulerHeight = 50, fontSize = 13, cytobandHeight = 100, trackLabels = 'offset', themeName = 'default', Wrapper = ({ children }) => children, } = opts;
17
17
  const session = getSession(model);
18
18
  const { allThemes } = session;
19
19
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -24,8 +24,8 @@ export declare function generateLocations(regions: ParsedLocString[] | undefined
24
24
  assemblyName: string;
25
25
  parentRegion: import("@jbrowse/core/assemblyManager/assembly").BasicRegion;
26
26
  end?: number | undefined;
27
- reversed?: boolean | undefined;
28
27
  start?: number | undefined;
28
+ reversed?: boolean | undefined;
29
29
  refName: string;
30
30
  }[]>;
31
31
  /**