@jbrowse/plugin-linear-genome-view 2.10.3 → 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 (52) hide show
  1. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -1
  2. package/dist/LaunchLinearGenomeView/index.js +14 -6
  3. package/dist/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  4. package/dist/LinearGenomeView/components/Cytobands.d.ts +1 -125
  5. package/dist/LinearGenomeView/components/ExportSvgDialog.js +9 -5
  6. package/dist/LinearGenomeView/components/Highlight.d.ts +3 -3
  7. package/dist/LinearGenomeView/components/Highlight.js +21 -17
  8. package/dist/LinearGenomeView/components/MiniControls.js +13 -15
  9. package/dist/LinearGenomeView/components/OverviewHighlight.d.ts +1 -1
  10. package/dist/LinearGenomeView/components/OverviewHighlight.js +20 -11
  11. package/dist/LinearGenomeView/components/OverviewRubberband.d.ts +1 -1
  12. package/dist/LinearGenomeView/components/OverviewScalebar.js +4 -1
  13. package/dist/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +1 -1
  14. package/dist/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +9 -9
  15. package/dist/LinearGenomeView/components/RefNameAutocomplete/index.js +28 -35
  16. package/dist/LinearGenomeView/components/Rubberband.d.ts +1 -1
  17. package/dist/LinearGenomeView/components/SearchBox.d.ts +1 -1
  18. package/dist/LinearGenomeView/components/SearchResultsTable.js +1 -1
  19. package/dist/LinearGenomeView/components/TrackContainer.js +10 -23
  20. package/dist/LinearGenomeView/components/TrackLabel.js +33 -6
  21. package/dist/LinearGenomeView/components/ZoomControls.js +4 -4
  22. package/dist/LinearGenomeView/model.d.ts +67 -7
  23. package/dist/LinearGenomeView/model.js +102 -16
  24. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +1 -1
  25. package/dist/index.d.ts +159 -21
  26. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +0 -1
  27. package/esm/LaunchLinearGenomeView/index.js +14 -6
  28. package/esm/LinearBasicDisplay/components/SetMaxHeight.d.ts +1 -1
  29. package/esm/LinearGenomeView/components/Cytobands.d.ts +1 -125
  30. package/esm/LinearGenomeView/components/ExportSvgDialog.js +9 -5
  31. package/esm/LinearGenomeView/components/Highlight.d.ts +3 -3
  32. package/esm/LinearGenomeView/components/Highlight.js +21 -17
  33. package/esm/LinearGenomeView/components/MiniControls.js +14 -16
  34. package/esm/LinearGenomeView/components/OverviewHighlight.d.ts +1 -1
  35. package/esm/LinearGenomeView/components/OverviewHighlight.js +20 -11
  36. package/esm/LinearGenomeView/components/OverviewRubberband.d.ts +1 -1
  37. package/esm/LinearGenomeView/components/OverviewScalebar.js +5 -2
  38. package/esm/LinearGenomeView/components/OverviewScalebarPolygon.d.ts +1 -1
  39. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.d.ts +9 -9
  40. package/esm/LinearGenomeView/components/RefNameAutocomplete/index.js +28 -35
  41. package/esm/LinearGenomeView/components/Rubberband.d.ts +1 -1
  42. package/esm/LinearGenomeView/components/SearchBox.d.ts +1 -1
  43. package/esm/LinearGenomeView/components/SearchResultsTable.js +1 -1
  44. package/esm/LinearGenomeView/components/TrackContainer.js +10 -23
  45. package/esm/LinearGenomeView/components/TrackLabel.js +33 -6
  46. package/esm/LinearGenomeView/components/TracksContainer.js +2 -2
  47. package/esm/LinearGenomeView/components/ZoomControls.js +4 -4
  48. package/esm/LinearGenomeView/model.d.ts +67 -7
  49. package/esm/LinearGenomeView/model.js +103 -17
  50. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +1 -1
  51. package/esm/index.d.ts +159 -21
  52. package/package.json +2 -2
@@ -81,7 +81,8 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
81
81
  showCytobandsSetting: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
82
82
  trackLabels: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
83
83
  showGridlines: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
84
- highlight: import("mobx-state-tree").IMaybe<import("mobx-state-tree").IType<Required<ParsedLocString>, Required<ParsedLocString>, Required<ParsedLocString>>>;
84
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<Required<ParsedLocString>, Required<ParsedLocString>, Required<ParsedLocString>>>, [undefined]>;
85
+ colorByCDS: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
85
86
  }, {
86
87
  width: number;
87
88
  } & {
@@ -224,6 +225,10 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
224
225
  */
225
226
  readonly trackTypeActions: Map<string, MenuItem[]>;
226
227
  } & {
228
+ /**
229
+ * #action
230
+ */
231
+ setColorByCDS(flag: boolean): void;
227
232
  /**
228
233
  * #action
229
234
  */
@@ -255,7 +260,15 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
255
260
  /**
256
261
  * #action
257
262
  */
258
- setHighlight(highlight: Required<ParsedLocString> | undefined): void;
263
+ addToHighlights(highlight: Required<ParsedLocString>): void;
264
+ /**
265
+ * #action
266
+ */
267
+ setHighlight(highlight: Required<ParsedLocString>[] | undefined): void;
268
+ /**
269
+ * #action
270
+ */
271
+ removeHighlight(highlight: Required<ParsedLocString>): void;
259
272
  /**
260
273
  * #action
261
274
  */
@@ -292,6 +305,22 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
292
305
  */
293
306
  hideTrack(trackId: string): number;
294
307
  } & {
308
+ /**
309
+ * #action
310
+ */
311
+ moveTrackDown(id: string): void;
312
+ /**
313
+ * #action
314
+ */
315
+ moveTrackUp(id: string): void;
316
+ /**
317
+ * #action
318
+ */
319
+ moveTrackToTop(id: string): void;
320
+ /**
321
+ * #action
322
+ */
323
+ moveTrackToBottom(id: string): void;
295
324
  /**
296
325
  * #action
297
326
  */
@@ -528,20 +557,21 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
528
557
  bpToPx({ refName, coord, regionNumber, }: {
529
558
  refName: string;
530
559
  coord: number;
531
- regionNumber?: number | undefined;
560
+ regionNumber?: number;
532
561
  }): {
533
562
  index: number;
534
563
  offsetPx: number;
535
564
  } | undefined;
536
565
  /**
537
566
  * #method
538
- * scrolls the view to center on the given bp. if that is not in any
539
- * of the displayed regions, does nothing
567
+ * scrolls the view to center on the given bp. if that is not in any of
568
+ * the displayed regions, does nothing
569
+ *
540
570
  * @param coord - basepair at which you want to center the view
541
571
  * @param refName - refName of the displayedRegion you are centering at
542
572
  * @param regionNumber - index of the displayedRegion
543
573
  */
544
- centerAt(coord: number, refName: string, regionNumber: number): void;
574
+ centerAt(coord: number, refName: string, regionNumber?: number): void;
545
575
  /**
546
576
  * #method
547
577
  */
@@ -572,7 +602,37 @@ export declare function stateModelFactory(pluginManager: PluginManager): import(
572
602
  } | undefined;
573
603
  } & {
574
604
  afterCreate(): void;
575
- }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>;
605
+ }, import("mobx-state-tree").ModelCreationType<import("mobx-state-tree/dist/internal").ExtractCFromProps<{
606
+ id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
607
+ displayName: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
608
+ minimized: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
609
+ } & {
610
+ id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
611
+ type: import("mobx-state-tree").IType<string | undefined, string, string>;
612
+ offsetPx: import("mobx-state-tree").IType<number | undefined, number, number>;
613
+ bpPerPx: import("mobx-state-tree").IType<number | undefined, number, number>;
614
+ displayedRegions: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IModelType<{
615
+ refName: import("mobx-state-tree").ISimpleType<string>;
616
+ start: import("mobx-state-tree").ISimpleType<number>;
617
+ end: import("mobx-state-tree").ISimpleType<number>;
618
+ reversed: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
619
+ } & {
620
+ assemblyName: import("mobx-state-tree").ISimpleType<string>;
621
+ }, {
622
+ setRefName(newRefName: string): void;
623
+ }, import("mobx-state-tree")._NotCustomized, import("mobx-state-tree")._NotCustomized>>;
624
+ tracks: import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyType>;
625
+ hideHeader: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
626
+ hideHeaderOverview: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
627
+ hideNoTracksActive: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
628
+ trackSelectorType: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
629
+ showCenterLine: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
630
+ showCytobandsSetting: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
631
+ trackLabels: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
632
+ showGridlines: import("mobx-state-tree").IType<boolean | undefined, boolean, boolean>;
633
+ highlight: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IType<Required<ParsedLocString>, Required<ParsedLocString>, Required<ParsedLocString>>>, [undefined]>;
634
+ colorByCDS: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<boolean>, [undefined]>;
635
+ }>>, import("mobx-state-tree")._NotCustomized>;
576
636
  export type LinearGenomeViewStateModel = ReturnType<typeof stateModelFactory>;
577
637
  export type LinearGenomeViewModel = Instance<LinearGenomeViewStateModel>;
578
638
  export { default as ReactComponent, default as LinearGenomeView, } from './components/LinearGenomeView';
@@ -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
  /**
@@ -140,7 +141,12 @@ export function stateModelFactory(pluginManager) {
140
141
  * #property
141
142
  * highlights on the LGV from the URL parameters
142
143
  */
143
- highlight: types.maybe(types.frozen()),
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'))),
144
150
  }))
145
151
  .volatile(() => ({
146
152
  volatileWidth: undefined,
@@ -331,7 +337,7 @@ export function stateModelFactory(pluginManager) {
331
337
  return {
332
338
  ...getParentRenderProps(self),
333
339
  bpPerPx: self.bpPerPx,
334
- highResolutionScaling: getConf(getSession(self), 'highResolutionScaling'),
340
+ colorByCDS: self.colorByCDS,
335
341
  };
336
342
  },
337
343
  /**
@@ -402,6 +408,12 @@ export function stateModelFactory(pluginManager) {
402
408
  },
403
409
  }))
404
410
  .actions(self => ({
411
+ /**
412
+ * #action
413
+ */
414
+ setColorByCDS(flag) {
415
+ self.colorByCDS = flag;
416
+ },
405
417
  /**
406
418
  * #action
407
419
  */
@@ -444,11 +456,24 @@ export function stateModelFactory(pluginManager) {
444
456
  setShowGridlines(b) {
445
457
  self.showGridlines = b;
446
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
+ },
447
466
  /**
448
467
  * #action
449
468
  */
450
469
  setHighlight(highlight) {
451
- self.highlight = highlight;
470
+ self.highlight = cast(highlight);
471
+ },
472
+ /**
473
+ * #action
474
+ */
475
+ removeHighlight(highlight) {
476
+ self.highlight.remove(highlight);
452
477
  },
453
478
  /**
454
479
  * #action
@@ -569,6 +594,47 @@ export function stateModelFactory(pluginManager) {
569
594
  },
570
595
  }))
571
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
+ },
572
638
  /**
573
639
  * #action
574
640
  */
@@ -581,9 +647,9 @@ export function stateModelFactory(pluginManager) {
581
647
  if (newIndex === -1) {
582
648
  throw new Error(`Track ID ${targetId} not found`);
583
649
  }
584
- const track = getSnapshot(self.tracks[oldIndex]);
585
- self.tracks.splice(oldIndex, 1);
586
- 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);
587
653
  },
588
654
  /**
589
655
  * #action
@@ -774,7 +840,7 @@ export function stateModelFactory(pluginManager) {
774
840
  * perform animated slide
775
841
  */
776
842
  function slide(viewWidths) {
777
- 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);
778
844
  cancelLastAnimation();
779
845
  cancelLastAnimation = cancelAnimation;
780
846
  animate();
@@ -861,6 +927,7 @@ export function stateModelFactory(pluginManager) {
861
927
  ? [
862
928
  {
863
929
  label: 'Sequence search',
930
+ icon: SearchIcon,
864
931
  onClick: () => {
865
932
  getSession(self).queueDialog(handleClose => [
866
933
  SequenceSearchDialog,
@@ -890,6 +957,13 @@ export function stateModelFactory(pluginManager) {
890
957
  icon: SyncAltIcon,
891
958
  onClick: self.horizontallyFlip,
892
959
  },
960
+ {
961
+ label: 'Color by CDS',
962
+ type: 'checkbox',
963
+ checked: self.colorByCDS,
964
+ icon: PaletteIcon,
965
+ onClick: () => self.setColorByCDS(!self.colorByCDS),
966
+ },
893
967
  {
894
968
  label: 'Show...',
895
969
  icon: VisibilityIcon,
@@ -1054,11 +1128,10 @@ export function stateModelFactory(pluginManager) {
1054
1128
  }, { delay: 150 }));
1055
1129
  addDisposer(self, autorun(() => {
1056
1130
  const s = (s) => JSON.stringify(s);
1057
- const { showCytobandsSetting, showCenterLine } = self;
1058
- if (typeof localStorage !== 'undefined') {
1059
- localStorage.setItem('lgv-showCytobands', s(showCytobandsSetting));
1060
- localStorage.setItem('lgv-showCenterLine', s(showCenterLine));
1061
- }
1131
+ const { showCytobandsSetting, showCenterLine, colorByCDS } = self;
1132
+ localStorageSetItem('lgv-showCytobands', s(showCytobandsSetting));
1133
+ localStorageSetItem('lgv-showCenterLine', s(showCenterLine));
1134
+ localStorageSetItem('lgv-colorByCDS', s(colorByCDS));
1062
1135
  }));
1063
1136
  },
1064
1137
  }))
@@ -1242,8 +1315,9 @@ export function stateModelFactory(pluginManager) {
1242
1315
  },
1243
1316
  /**
1244
1317
  * #method
1245
- * scrolls the view to center on the given bp. if that is not in any
1246
- * 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
+ *
1247
1321
  * @param coord - basepair at which you want to center the view
1248
1322
  * @param refName - refName of the displayedRegion you are centering at
1249
1323
  * @param regionNumber - index of the displayedRegion
@@ -1301,7 +1375,19 @@ export function stateModelFactory(pluginManager) {
1301
1375
  document.removeEventListener('keydown', handler);
1302
1376
  });
1303
1377
  },
1304
- }));
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
+ });
1305
1391
  }
1306
1392
  export { default as ReactComponent, default as LinearGenomeView, } from './components/LinearGenomeView';
1307
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