@jbrowse/plugin-breakpoint-split-view 2.16.1 → 2.18.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/BreakpointAlignmentsFeatureDetail/BreakpointAlignmentsFeatureDetail.d.ts +5 -1
  2. package/dist/BreakpointAlignmentsFeatureDetail/BreakpointAlignmentsFeatureDetail.js +4 -3
  3. package/dist/BreakpointAlignmentsFeatureDetail/index.d.ts +1 -1
  4. package/dist/BreakpointAlignmentsFeatureDetail/index.js +1 -1
  5. package/dist/BreakpointSplitView/BreakpointSplitView.d.ts +22 -40
  6. package/dist/BreakpointSplitView/BreakpointSplitView.js +41 -90
  7. package/dist/BreakpointSplitView/components/AlignmentConnections.d.ts +1 -1
  8. package/dist/BreakpointSplitView/components/AlignmentConnections.js +5 -14
  9. package/dist/BreakpointSplitView/components/Breakends.d.ts +1 -1
  10. package/dist/BreakpointSplitView/components/Breakends.js +4 -7
  11. package/dist/BreakpointSplitView/components/BreakpointSplitView.d.ts +1 -1
  12. package/dist/BreakpointSplitView/components/BreakpointSplitView.js +1 -1
  13. package/dist/BreakpointSplitView/components/BreakpointSplitViewOverlay.d.ts +1 -1
  14. package/dist/BreakpointSplitView/components/BreakpointSplitViewOverlay.js +2 -9
  15. package/dist/BreakpointSplitView/components/ExportSvgDialog.d.ts +1 -1
  16. package/dist/BreakpointSplitView/components/ExportSvgDialog.js +2 -4
  17. package/dist/BreakpointSplitView/components/Overlay.d.ts +1 -1
  18. package/dist/BreakpointSplitView/components/Overlay.js +1 -3
  19. package/dist/BreakpointSplitView/components/PairedFeatures.d.ts +1 -1
  20. package/dist/BreakpointSplitView/components/PairedFeatures.js +2 -5
  21. package/dist/BreakpointSplitView/components/Translocations.d.ts +1 -1
  22. package/dist/BreakpointSplitView/components/Translocations.js +5 -12
  23. package/dist/BreakpointSplitView/components/getOrientationColor.js +0 -8
  24. package/dist/BreakpointSplitView/components/util.d.ts +1 -1
  25. package/dist/BreakpointSplitView/components/util.js +14 -17
  26. package/dist/BreakpointSplitView/index.d.ts +1 -1
  27. package/dist/BreakpointSplitView/index.js +2 -3
  28. package/dist/BreakpointSplitView/model.d.ts +8 -64
  29. package/dist/BreakpointSplitView/model.js +15 -91
  30. package/dist/BreakpointSplitView/svgcomponents/SVGBackground.js +1 -1
  31. package/dist/BreakpointSplitView/svgcomponents/SVGBreakpointSplitView.d.ts +1 -1
  32. package/dist/BreakpointSplitView/svgcomponents/SVGBreakpointSplitView.js +4 -7
  33. package/dist/BreakpointSplitView/svgcomponents/util.d.ts +2 -2
  34. package/dist/BreakpointSplitView/svgcomponents/util.js +0 -1
  35. package/dist/BreakpointSplitView/util.d.ts +2 -2
  36. package/dist/BreakpointSplitView/util.js +0 -8
  37. package/dist/index.d.ts +1 -1
  38. package/esm/BreakpointAlignmentsFeatureDetail/BreakpointAlignmentsFeatureDetail.d.ts +5 -1
  39. package/esm/BreakpointAlignmentsFeatureDetail/BreakpointAlignmentsFeatureDetail.js +4 -3
  40. package/esm/BreakpointAlignmentsFeatureDetail/index.d.ts +1 -1
  41. package/esm/BreakpointAlignmentsFeatureDetail/index.js +1 -1
  42. package/esm/BreakpointSplitView/BreakpointSplitView.d.ts +22 -40
  43. package/esm/BreakpointSplitView/BreakpointSplitView.js +41 -90
  44. package/esm/BreakpointSplitView/components/AlignmentConnections.d.ts +1 -1
  45. package/esm/BreakpointSplitView/components/AlignmentConnections.js +6 -15
  46. package/esm/BreakpointSplitView/components/Breakends.d.ts +1 -1
  47. package/esm/BreakpointSplitView/components/Breakends.js +6 -9
  48. package/esm/BreakpointSplitView/components/BreakpointSplitView.d.ts +1 -1
  49. package/esm/BreakpointSplitView/components/BreakpointSplitView.js +1 -1
  50. package/esm/BreakpointSplitView/components/BreakpointSplitViewOverlay.d.ts +1 -1
  51. package/esm/BreakpointSplitView/components/BreakpointSplitViewOverlay.js +2 -9
  52. package/esm/BreakpointSplitView/components/ExportSvgDialog.d.ts +1 -1
  53. package/esm/BreakpointSplitView/components/ExportSvgDialog.js +2 -4
  54. package/esm/BreakpointSplitView/components/Overlay.d.ts +1 -1
  55. package/esm/BreakpointSplitView/components/Overlay.js +1 -3
  56. package/esm/BreakpointSplitView/components/PairedFeatures.d.ts +1 -1
  57. package/esm/BreakpointSplitView/components/PairedFeatures.js +4 -7
  58. package/esm/BreakpointSplitView/components/Translocations.d.ts +1 -1
  59. package/esm/BreakpointSplitView/components/Translocations.js +7 -14
  60. package/esm/BreakpointSplitView/components/getOrientationColor.js +0 -8
  61. package/esm/BreakpointSplitView/components/util.d.ts +1 -1
  62. package/esm/BreakpointSplitView/components/util.js +14 -17
  63. package/esm/BreakpointSplitView/index.d.ts +1 -1
  64. package/esm/BreakpointSplitView/index.js +2 -3
  65. package/esm/BreakpointSplitView/model.d.ts +8 -64
  66. package/esm/BreakpointSplitView/model.js +14 -91
  67. package/esm/BreakpointSplitView/svgcomponents/SVGBackground.js +1 -1
  68. package/esm/BreakpointSplitView/svgcomponents/SVGBreakpointSplitView.d.ts +1 -1
  69. package/esm/BreakpointSplitView/svgcomponents/SVGBreakpointSplitView.js +4 -7
  70. package/esm/BreakpointSplitView/svgcomponents/util.d.ts +2 -2
  71. package/esm/BreakpointSplitView/svgcomponents/util.js +0 -1
  72. package/esm/BreakpointSplitView/util.d.ts +2 -2
  73. package/esm/BreakpointSplitView/util.js +1 -9
  74. package/esm/index.d.ts +1 -1
  75. package/package.json +3 -3
@@ -7,8 +7,6 @@ exports.getLongReadOrientationAbnormal = getLongReadOrientationAbnormal;
7
7
  exports.isAbnormalOrientation = isAbnormalOrientation;
8
8
  exports.getPairedOrientationColor = getPairedOrientationColor;
9
9
  const material_1 = require("@mui/material");
10
- // orientation definitions from igv.js, see also
11
- // https://software.broadinstitute.org/software/igv/interpreting_pair_orientations
12
10
  exports.orientationTypes = {
13
11
  fr: {
14
12
  F1R2: 'LR',
@@ -47,12 +45,6 @@ exports.pairMap = {
47
45
  RR: 'color_pair_rr',
48
46
  RL: 'color_pair_rl',
49
47
  };
50
- // manually calculated by running
51
- // const color = require('color')
52
- // Object.fromEntries(Object.entries(fillColor).map(([key,val])=>{
53
- // return [key, color(val).darken('0.3').hex()]
54
- // }))
55
- // this avoids (expensive) use of Color module at runtime
56
48
  exports.strokeColor = {
57
49
  color_fwd_strand_not_proper: (0, material_1.alpha)('#CA6767', 0.8),
58
50
  color_rev_strand_not_proper: (0, material_1.alpha)('#7272AA', 0.8),
@@ -1,4 +1,4 @@
1
- import { Feature } from '@jbrowse/core/util';
1
+ import type { Feature } from '@jbrowse/core/util';
2
2
  export declare function getBadlyPairedAlignments(features: Map<string, Feature>): Feature[][];
3
3
  export declare function getMatchedAlignmentFeatures(features: Map<string, Feature>): Feature[][];
4
4
  export declare function hasPairedReads(features: Map<string, Feature>): boolean;
@@ -7,20 +7,26 @@ exports.findMatchingAlt = findMatchingAlt;
7
7
  exports.getMatchedBreakendFeatures = getMatchedBreakendFeatures;
8
8
  exports.getMatchedTranslocationFeatures = getMatchedTranslocationFeatures;
9
9
  exports.getMatchedPairedFeatures = getMatchedPairedFeatures;
10
- const util_1 = require("@jbrowse/core/util");
11
10
  const vcf_1 = require("@gmod/vcf");
12
- // this finds candidate alignment features, aimed at plotting split reads from
13
- // BAM/CRAM files
11
+ const util_1 = require("@jbrowse/core/util");
14
12
  function getBadlyPairedAlignments(features) {
15
13
  const candidates = new Map();
16
14
  const alreadySeen = new Set();
17
- // this finds candidate features that share the same name
15
+ const alreadyPairedWithSamePosition = new Set();
18
16
  for (const feature of features.values()) {
19
17
  const flags = feature.get('flags');
20
18
  const id = feature.id();
19
+ const supp = (0, util_1.assembleLocStringFast)({
20
+ refName: feature.get('refName'),
21
+ start: feature.get('start'),
22
+ end: feature.get('end'),
23
+ });
21
24
  const unmapped = flags & 4;
22
25
  const correctlyPaired = flags & 2;
23
- if (!alreadySeen.has(id) && !correctlyPaired && !unmapped) {
26
+ if (!alreadySeen.has(id) &&
27
+ !alreadyPairedWithSamePosition.has(supp) &&
28
+ !correctlyPaired &&
29
+ !unmapped) {
24
30
  const n = feature.get('name');
25
31
  let val = candidates.get(n);
26
32
  if (!val) {
@@ -30,23 +36,18 @@ function getBadlyPairedAlignments(features) {
30
36
  val.push(feature);
31
37
  }
32
38
  alreadySeen.add(feature.id());
39
+ alreadyPairedWithSamePosition.add(supp);
33
40
  }
34
41
  return [...candidates.values()].filter(v => v.length > 1);
35
42
  }
36
- function getTag(f, tag) {
37
- const tags = f.get('tags');
38
- return tags ? tags[tag] : f.get(tag);
39
- }
40
- // this finds candidate alignment features, aimed at plotting split reads from
41
- // BAM/CRAM files
42
43
  function getMatchedAlignmentFeatures(features) {
44
+ var _a;
43
45
  const candidates = new Map();
44
46
  const alreadySeen = new Set();
45
- // this finds candidate features that share the same name
46
47
  for (const feature of features.values()) {
47
48
  const id = feature.id();
48
49
  const unmapped = feature.get('flags') & 4;
49
- const hasSA = !!getTag(feature, 'SA');
50
+ const hasSA = !!((_a = feature.get('tags')) === null || _a === void 0 ? void 0 : _a.SA);
50
51
  if (!alreadySeen.has(id) && !unmapped && hasSA) {
51
52
  const n = feature.get('name');
52
53
  let val = candidates.get(n);
@@ -78,8 +79,6 @@ function findMatchingAlt(feat1, feat2) {
78
79
  }
79
80
  return undefined;
80
81
  }
81
- // Returns paired BND features across multiple views by inspecting the ALT
82
- // field to get exact coordinate matches
83
82
  function getMatchedBreakendFeatures(feats) {
84
83
  const candidates = new Map();
85
84
  const alreadySeen = new Set();
@@ -104,7 +103,6 @@ function getMatchedBreakendFeatures(feats) {
104
103
  }
105
104
  return [...candidates.values()].filter(v => v.length > 1);
106
105
  }
107
- // Getting "matched" TRA means just return all TRA
108
106
  function getMatchedTranslocationFeatures(feats) {
109
107
  const ret = [];
110
108
  const alreadySeen = new Set();
@@ -116,7 +114,6 @@ function getMatchedTranslocationFeatures(feats) {
116
114
  }
117
115
  return ret;
118
116
  }
119
- // Getting "matched" TRA means just return all TRA
120
117
  function getMatchedPairedFeatures(feats) {
121
118
  const candidates = new Map();
122
119
  const alreadySeen = new Set();
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function BreakpointSplitViewF(pluginManager: PluginManager): void;
@@ -28,12 +28,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.default = BreakpointSplitViewF;
30
30
  const react_1 = require("react");
31
- // locals
32
- const BreakpointSplitView_1 = __importDefault(require("./BreakpointSplitView"));
31
+ const pluggableElementTypes_1 = require("@jbrowse/core/pluggableElementTypes");
33
32
  const model_1 = __importDefault(require("./model"));
34
33
  function BreakpointSplitViewF(pluginManager) {
35
34
  pluginManager.addViewType(() => {
36
- return new BreakpointSplitView_1.default({
35
+ return new pluggableElementTypes_1.ViewType({
37
36
  name: 'BreakpointSplitView',
38
37
  displayName: 'Breakpoint split view',
39
38
  stateModel: (0, model_1.default)(pluginManager),
@@ -1,8 +1,9 @@
1
- import React from 'react';
2
- import { Instance } from 'mobx-state-tree';
3
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
4
- import PluginManager from '@jbrowse/core/PluginManager';
5
- import { Feature } from '@jbrowse/core/util';
1
+ import type React from 'react';
2
+ import type PluginManager from '@jbrowse/core/PluginManager';
3
+ import type { Feature } from '@jbrowse/core/util';
4
+ import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
5
+ import type { Instance } from 'mobx-state-tree';
6
+ export declare function getClip(cigar: string, strand: number): number;
6
7
  export interface ExportSvgOptions {
7
8
  rasterizeLayers?: boolean;
8
9
  filename?: string;
@@ -26,11 +27,6 @@ export interface Breakend {
26
27
  MatePosition: string;
27
28
  }
28
29
  export type LayoutRecord = [number, number, number, number];
29
- /**
30
- * #stateModel BreakpointSplitView
31
- * extends
32
- * - [BaseViewModel](../baseviewmodel)
33
- */
34
30
  export default function stateModelFactory(pluginManager: PluginManager): import("mobx-state-tree").IModelType<{
35
31
  id: import("mobx-state-tree").IOptionalIType<import("mobx-state-tree").ISimpleType<string>, [undefined]>;
36
32
  displayName: import("mobx-state-tree").IMaybe<import("mobx-state-tree").ISimpleType<string>>;
@@ -93,6 +89,7 @@ export default function stateModelFactory(pluginManager: PluginManager): import(
93
89
  scaleBarDisplayPrefix(): string | undefined;
94
90
  MiniControlsComponent(): React.FC<any>;
95
91
  HeaderComponent(): React.FC<any>;
92
+ readonly assembliesNotFound: string | undefined;
96
93
  readonly assemblyErrors: string;
97
94
  readonly assembliesInitialized: boolean;
98
95
  readonly initialized: boolean;
@@ -274,88 +271,35 @@ export default function stateModelFactory(pluginManager: PluginManager): import(
274
271
  width: number;
275
272
  matchedTrackFeatures: Record<string, Feature[][]>;
276
273
  } & {
277
- /**
278
- * #method
279
- * creates an svg export and save using FileSaver
280
- */
281
274
  exportSvg(opts?: ExportSvgOptions): Promise<void>;
282
275
  } & {
283
- /**
284
- * #getter
285
- * Find all track ids that match across multiple views, or return just
286
- * the single view's track if only a single row is used
287
- */
288
276
  readonly matchedTracks: (import("mobx-state-tree").IMSTArray<import("mobx-state-tree").IAnyType> & import("mobx-state-tree").IStateTreeNode<import("mobx-state-tree").IArrayType<import("mobx-state-tree").IAnyType>>) | {
289
277
  configuration: {
290
278
  trackId: string;
291
279
  };
292
280
  }[];
293
- /**
294
- * #method
295
- * Get tracks with a given trackId across multiple views
296
- */
297
281
  getMatchedTracks(trackConfigId: string): any[];
298
- /**
299
- * #method
300
- * Translocation features are handled differently since they do not have
301
- * a mate e.g. they are one sided
302
- */
303
282
  hasTranslocations(trackConfigId: string): Feature | undefined;
304
- /**
305
- * #method
306
- * Paired features similar to breakends, but simpler, like BEDPE
307
- */
308
283
  hasPairedFeatures(trackConfigId: string): Feature | undefined;
309
- /**
310
- * #method
311
- * Get a composite map of featureId-\>feature map for a track across
312
- * multiple views
313
- */
314
284
  getTrackFeatures(trackConfigId: string): Map<string, Feature>;
315
- /**
316
- * #method
317
- */
318
285
  getMatchedFeaturesInLayout(trackConfigId: string, features: Feature[][]): {
319
286
  feature: Feature;
320
287
  layout: LayoutRecord | undefined;
321
288
  level: number;
289
+ clipPos: number;
322
290
  }[][];
323
291
  } & {
324
292
  afterAttach(): void;
325
293
  onSubviewAction(actionName: string, path: string, args?: unknown[]): void;
326
- /**
327
- * #action
328
- */
329
294
  setWidth(newWidth: number): void;
330
- /**
331
- * #action
332
- */
333
295
  removeView(view: LGV): void;
334
- /**
335
- * #action
336
- */
337
296
  toggleInteract(): void;
338
- /**
339
- * #action
340
- */
341
297
  toggleIntraviewLinks(): void;
342
- /**
343
- * #action
344
- */
345
298
  toggleLinkViews(): void;
346
- /**
347
- * #action
348
- */
349
299
  setMatchedTrackFeatures(obj: Record<string, Feature[][]>): void;
350
- /**
351
- * #action
352
- */
353
300
  reverseViewOrder(): void;
354
301
  } & {
355
302
  afterAttach(): void;
356
- /**
357
- * #method
358
- */
359
303
  menuItems(): ({
360
304
  label: string;
361
305
  subMenu: import("@jbrowse/core/ui").MenuItem[];
@@ -26,21 +26,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.getClip = getClip;
29
30
  exports.default = stateModelFactory;
30
31
  const react_1 = require("react");
31
- const mobx_state_tree_1 = require("mobx-state-tree");
32
- const mobx_1 = require("mobx");
33
- const file_saver_1 = require("file-saver");
32
+ const configuration_1 = require("@jbrowse/core/configuration");
34
33
  const models_1 = require("@jbrowse/core/pluggableElementTypes/models");
35
34
  const util_1 = require("@jbrowse/core/util");
36
- const configuration_1 = require("@jbrowse/core/configuration");
37
- // icons
38
- const PhotoCamera_1 = __importDefault(require("@mui/icons-material/PhotoCamera"));
39
35
  const Link_1 = __importDefault(require("@mui/icons-material/Link"));
40
- // locals
36
+ const PhotoCamera_1 = __importDefault(require("@mui/icons-material/PhotoCamera"));
37
+ const file_saver_1 = require("file-saver");
38
+ const mobx_1 = require("mobx");
39
+ const mobx_state_tree_1 = require("mobx-state-tree");
41
40
  const util_2 = require("./util");
42
- // lazies
43
41
  const ExportSvgDialog = (0, react_1.lazy)(() => Promise.resolve().then(() => __importStar(require('./components/ExportSvgDialog'))));
42
+ const startClip = new RegExp(/(\d+)[SH]$/);
43
+ const endClip = new RegExp(/^(\d+)([SH])/);
44
+ function getClip(cigar, strand) {
45
+ return strand === -1
46
+ ? +(startClip.exec(cigar) || [])[1] || 0
47
+ : +(endClip.exec(cigar) || [])[1] || 0;
48
+ }
44
49
  function calc(track, f) {
45
50
  var _a, _b;
46
51
  return (_b = (_a = track.displays[0]).searchFeatureByID) === null || _b === void 0 ? void 0 : _b.call(_a, f.id());
@@ -55,7 +60,7 @@ async function getBlockFeatures(model, track) {
55
60
  }
56
61
  const assembly = await assemblyManager.waitForAssembly(assemblyName);
57
62
  if (!assembly) {
58
- return undefined; // throw new Error(`assembly not found: "${assemblyName}"`)
63
+ return undefined;
59
64
  }
60
65
  const sessionId = track.configuration.trackId;
61
66
  return Promise.all(views.map(async (view) => (await rpcManager.call(sessionId, 'CoreGetFeatures', {
@@ -64,43 +69,17 @@ async function getBlockFeatures(model, track) {
64
69
  regions: view.staticBlocks.contentBlocks,
65
70
  })).flat()));
66
71
  }
67
- /**
68
- * #stateModel BreakpointSplitView
69
- * extends
70
- * - [BaseViewModel](../baseviewmodel)
71
- */
72
72
  function stateModelFactory(pluginManager) {
73
73
  const minHeight = 40;
74
74
  const defaultHeight = 400;
75
75
  return mobx_state_tree_1.types
76
76
  .compose('BreakpointSplitView', models_1.BaseViewModel, mobx_state_tree_1.types.model({
77
- /**
78
- * #property
79
- */
80
77
  type: mobx_state_tree_1.types.literal('BreakpointSplitView'),
81
- /**
82
- * #property
83
- */
84
78
  height: mobx_state_tree_1.types.optional(mobx_state_tree_1.types.refinement('viewHeight', mobx_state_tree_1.types.number, (n) => n >= minHeight), defaultHeight),
85
- /**
86
- * #property
87
- */
88
79
  trackSelectorType: 'hierarchical',
89
- /**
90
- * #property
91
- */
92
80
  showIntraviewLinks: true,
93
- /**
94
- * #property
95
- */
96
81
  linkViews: false,
97
- /**
98
- * #property
99
- */
100
82
  interactToggled: false,
101
- /**
102
- * #property
103
- */
104
83
  views: mobx_state_tree_1.types.array(pluginManager.getViewType('LinearGenomeView')
105
84
  .stateModel),
106
85
  }))
@@ -109,10 +88,6 @@ function stateModelFactory(pluginManager) {
109
88
  matchedTrackFeatures: {},
110
89
  }))
111
90
  .views(self => ({
112
- /**
113
- * #method
114
- * creates an svg export and save using FileSaver
115
- */
116
91
  async exportSvg(opts = {}) {
117
92
  const { renderToSvg } = await Promise.resolve().then(() => __importStar(require('./svgcomponents/SVGBreakpointSplitView')));
118
93
  const html = await renderToSvg(self, opts);
@@ -121,54 +96,27 @@ function stateModelFactory(pluginManager) {
121
96
  },
122
97
  }))
123
98
  .views(self => ({
124
- /**
125
- * #getter
126
- * Find all track ids that match across multiple views, or return just
127
- * the single view's track if only a single row is used
128
- */
129
99
  get matchedTracks() {
130
100
  return self.views.length === 1
131
101
  ? self.views[0].tracks
132
102
  : (0, util_2.intersect)(elt => elt.configuration.trackId, ...self.views.map(view => view.tracks));
133
103
  },
134
- /**
135
- * #method
136
- * Get tracks with a given trackId across multiple views
137
- */
138
104
  getMatchedTracks(trackConfigId) {
139
105
  return self.views
140
106
  .map(view => view.getTrack(trackConfigId))
141
107
  .filter(f => !!f);
142
108
  },
143
- /**
144
- * #method
145
- * Translocation features are handled differently since they do not have
146
- * a mate e.g. they are one sided
147
- */
148
109
  hasTranslocations(trackConfigId) {
149
110
  return [...this.getTrackFeatures(trackConfigId).values()].find(f => f.get('type') === 'translocation');
150
111
  },
151
- /**
152
- * #method
153
- * Paired features similar to breakends, but simpler, like BEDPE
154
- */
155
112
  hasPairedFeatures(trackConfigId) {
156
113
  return [...this.getTrackFeatures(trackConfigId).values()].find(f => f.get('type') === 'paired_feature');
157
114
  },
158
- /**
159
- * #method
160
- * Get a composite map of featureId-\>feature map for a track across
161
- * multiple views
162
- */
163
115
  getTrackFeatures(trackConfigId) {
164
116
  var _a;
165
117
  return new Map((_a = self.matchedTrackFeatures[trackConfigId]) === null || _a === void 0 ? void 0 : _a.flat().map(f => [f.id(), f]));
166
118
  },
167
- /**
168
- * #method
169
- */
170
119
  getMatchedFeaturesInLayout(trackConfigId, features) {
171
- // use reverse to search the second track first
172
120
  const tracks = this.getMatchedTracks(trackConfigId);
173
121
  return features.map(c => c
174
122
  .map(feature => {
@@ -178,6 +126,7 @@ function stateModelFactory(pluginManager) {
178
126
  feature,
179
127
  layout: calc(tracks[level], feature),
180
128
  level,
129
+ clipPos: getClip(feature.get('CIGAR'), feature.get('strand')),
181
130
  }
182
131
  : undefined;
183
132
  })
@@ -208,53 +157,31 @@ function stateModelFactory(pluginManager) {
208
157
  self.views.forEach(view => {
209
158
  const ret = (0, mobx_state_tree_1.getPath)(view);
210
159
  if (!ret.endsWith(path)) {
211
- // @ts-ignore
212
160
  view[actionName](args === null || args === void 0 ? void 0 : args[0]);
213
161
  }
214
162
  });
215
163
  },
216
- /**
217
- * #action
218
- */
219
164
  setWidth(newWidth) {
220
165
  self.width = newWidth;
221
166
  self.views.forEach(v => {
222
167
  v.setWidth(newWidth);
223
168
  });
224
169
  },
225
- /**
226
- * #action
227
- */
228
170
  removeView(view) {
229
171
  self.views.remove(view);
230
172
  },
231
- /**
232
- * #action
233
- */
234
173
  toggleInteract() {
235
174
  self.interactToggled = !self.interactToggled;
236
175
  },
237
- /**
238
- * #action
239
- */
240
176
  toggleIntraviewLinks() {
241
177
  self.showIntraviewLinks = !self.showIntraviewLinks;
242
178
  },
243
- /**
244
- * #action
245
- */
246
179
  toggleLinkViews() {
247
180
  self.linkViews = !self.linkViews;
248
181
  },
249
- /**
250
- * #action
251
- */
252
182
  setMatchedTrackFeatures(obj) {
253
183
  self.matchedTrackFeatures = obj;
254
184
  },
255
- /**
256
- * #action
257
- */
258
185
  reverseViewOrder() {
259
186
  self.views.reverse();
260
187
  },
@@ -277,9 +204,6 @@ function stateModelFactory(pluginManager) {
277
204
  }
278
205
  }));
279
206
  },
280
- /**
281
- * #method
282
- */
283
207
  menuItems() {
284
208
  return [
285
209
  ...self.views
@@ -5,8 +5,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.default = SVGBackground;
7
7
  const react_1 = __importDefault(require("react"));
8
- const material_1 = require("@mui/material");
9
8
  const util_1 = require("@jbrowse/core/util");
9
+ const material_1 = require("@mui/material");
10
10
  function SVGBackground({ width, height, shift, }) {
11
11
  const theme = (0, material_1.useTheme)();
12
12
  return (react_1.default.createElement("rect", { width: width + shift * 2, height: height, fill: (0, util_1.stripAlpha)(theme.palette.background.default) }));
@@ -1,4 +1,4 @@
1
- import { ExportSvgOptions, BreakpointViewModel } from '../model';
1
+ import type { BreakpointViewModel, ExportSvgOptions } from '../model';
2
2
  type BSV = BreakpointViewModel;
3
3
  export declare function renderToSvg(model: BSV, opts: ExportSvgOptions): Promise<string>;
4
4
  export {};
@@ -5,17 +5,15 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.renderToSvg = renderToSvg;
7
7
  const react_1 = __importDefault(require("react"));
8
- const mobx_1 = require("mobx");
8
+ const ui_1 = require("@jbrowse/core/ui");
9
9
  const util_1 = require("@jbrowse/core/util");
10
+ const plugin_linear_genome_view_1 = require("@jbrowse/plugin-linear-genome-view");
10
11
  const material_1 = require("@mui/material");
11
- const ui_1 = require("@jbrowse/core/ui");
12
+ const mobx_1 = require("mobx");
12
13
  const mobx_state_tree_1 = require("mobx-state-tree");
13
- const plugin_linear_genome_view_1 = require("@jbrowse/plugin-linear-genome-view");
14
- // locals
15
14
  const SVGBackground_1 = __importDefault(require("./SVGBackground"));
16
- const Overlay_1 = __importDefault(require("../components/Overlay"));
17
15
  const util_2 = require("./util");
18
- // render LGV to SVG
16
+ const Overlay_1 = __importDefault(require("../components/Overlay"));
19
17
  async function renderToSvg(model, opts) {
20
18
  var _a;
21
19
  const { textHeight = 18, headerHeight = 30, rulerHeight = 30, fontSize = 13, trackLabels = 'offset', Wrapper = ({ children }) => children, themeName = 'default', } = opts;
@@ -41,7 +39,6 @@ async function renderToSvg(model, opts) {
41
39
  const trackOffsets = views.map((view, idx) => (0, util_2.getTrackOffsets)(view, textOffset, fontSize + (idx > 0 ? heights[idx - 1] : 0) + offset));
42
40
  const w = width + trackLabelOffset;
43
41
  const t = (0, ui_1.createJBrowseTheme)(theme);
44
- // the xlink namespace is used for rendering <image> tag
45
42
  return (0, util_1.renderToStaticMarkup)(react_1.default.createElement(material_1.ThemeProvider, { theme: t },
46
43
  react_1.default.createElement(Wrapper, null,
47
44
  react_1.default.createElement("svg", { width: width, height: totalHeightSvg, xmlns: "http://www.w3.org/2000/svg", xmlnsXlink: "http://www.w3.org/1999/xlink", viewBox: [0, 0, w + shift * 2, totalHeightSvg].toString() },
@@ -1,4 +1,4 @@
1
- import { AbstractSessionModel } from '@jbrowse/core/util';
2
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
1
+ import type { AbstractSessionModel } from '@jbrowse/core/util';
2
+ import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
3
3
  export declare function getTrackNameMaxLen(views: LinearGenomeViewModel[], fontSize: number, session: AbstractSessionModel): number;
4
4
  export declare function getTrackOffsets(view: LinearGenomeViewModel, textOffset: number, extra?: number): Record<string, number>;
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTrackNameMaxLen = getTrackNameMaxLen;
4
4
  exports.getTrackOffsets = getTrackOffsets;
5
5
  const util_1 = require("@jbrowse/core/util");
6
- // locals
7
6
  const tracks_1 = require("@jbrowse/core/util/tracks");
8
7
  function getTrackNameMaxLen(views, fontSize, session) {
9
8
  return (0, util_1.max)(views.flatMap(view => view.tracks.map(t => (0, util_1.measureText)((0, tracks_1.getTrackName)(t.configuration, session), fontSize))), 0);
@@ -1,5 +1,5 @@
1
- import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
2
- import { LayoutRecord } from './model';
1
+ import type { LayoutRecord } from './model';
2
+ import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view';
3
3
  type LGV = LinearGenomeViewModel;
4
4
  interface Display {
5
5
  height: number;
@@ -21,7 +21,6 @@ function getPxFromCoordinate(view, refName, coord) {
21
21
  var _a;
22
22
  return (((_a = view.bpToPx({ refName, coord })) === null || _a === void 0 ? void 0 : _a.offsetPx) || 0) - view.offsetPx;
23
23
  }
24
- // get's the yposition of a layout record in a track
25
24
  function yPos(trackId, level, views, tracks, c, getYPosOverride) {
26
25
  const display = tracks[level].displays[0];
27
26
  const min = 0;
@@ -36,10 +35,6 @@ function yPos(trackId, level, views, tracks, c, getYPosOverride) {
36
35
  heightFromSpecificLevel(views, trackId, level, getYPosOverride) +
37
36
  display.scrollTop);
38
37
  }
39
- // we combo a useEffect and useState combo to force rerender on snap changing.
40
- // the setup of this being a useEffect+useState makes it re-render once the
41
- // useEffect is called, which is generally the "next frame". If we removed the
42
- // below use
43
38
  const useNextFrame = (variable) => {
44
39
  const [, setNextFrameState] = (0, react_1.useState)();
45
40
  (0, react_1.useEffect)(() => {
@@ -47,9 +42,6 @@ const useNextFrame = (variable) => {
47
42
  }, [variable]);
48
43
  };
49
44
  exports.useNextFrame = useNextFrame;
50
- // https://stackoverflow.com/a/49186706/2129219 the array-intersection package
51
- // on npm has a large kb size, and we are just intersecting open track ids so
52
- // simple is better
53
45
  function intersect(cb, a1 = [], a2 = [], ...rest) {
54
46
  const ids = new Set(a2.map(elt => cb(elt)));
55
47
  const a12 = a1.filter(value => ids.has(cb(value)));
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
2
1
  import Plugin from '@jbrowse/core/Plugin';
2
+ import type PluginManager from '@jbrowse/core/PluginManager';
3
3
  export default class BreakpointSplitViewPlugin extends Plugin {
4
4
  name: string;
5
5
  install(pluginManager: PluginManager): void;
@@ -1,7 +1,11 @@
1
1
  import React from 'react';
2
+ import type { SimpleFeatureSerialized } from '@jbrowse/core/util';
2
3
  declare const BreakpointAlignmentsFeatureDetail: ({ model, }: {
3
4
  model: {
4
- featureData: Record<string, unknown>;
5
+ featureData: {
6
+ feature1: SimpleFeatureSerialized;
7
+ feature2: SimpleFeatureSerialized;
8
+ };
5
9
  };
6
10
  }) => React.JSX.Element;
7
11
  export default BreakpointAlignmentsFeatureDetail;
@@ -1,10 +1,11 @@
1
1
  import React from 'react';
2
+ import { BaseAttributes, BaseCoreDetails, } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
2
3
  import { Paper } from '@mui/material';
3
4
  import { observer } from 'mobx-react';
4
- import { BaseCoreDetails, BaseAttributes, } from '@jbrowse/core/BaseFeatureWidget/BaseFeatureDetail';
5
5
  const BreakpointAlignmentsFeatureDetail = observer(function ({ model, }) {
6
- const { feature1, feature2 } = JSON.parse(JSON.stringify(model.featureData));
7
- return (React.createElement(Paper, { "data-testid": "alignment-side-drawer" },
6
+ const { featureData } = model;
7
+ const { feature1, feature2 } = structuredClone(featureData);
8
+ return (React.createElement(Paper, null,
8
9
  React.createElement(BaseCoreDetails, { title: "Feature 1", feature: feature1 }),
9
10
  React.createElement(BaseCoreDetails, { title: "Feature 2", feature: feature2 }),
10
11
  React.createElement(BaseAttributes, { title: "Feature 1 attributes", feature: feature1 }),
@@ -1,2 +1,2 @@
1
- import PluginManager from '@jbrowse/core/PluginManager';
1
+ import type PluginManager from '@jbrowse/core/PluginManager';
2
2
  export default function BreakpointAlignmentsFeatureDetailF(pluginManager: PluginManager): void;
@@ -1,8 +1,8 @@
1
1
  import { lazy } from 'react';
2
2
  import { ConfigurationSchema } from '@jbrowse/core/configuration';
3
+ import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
3
4
  import { ElementId } from '@jbrowse/core/util/types/mst';
4
5
  import { types } from 'mobx-state-tree';
5
- import { WidgetType } from '@jbrowse/core/pluggableElementTypes';
6
6
  const configSchema = ConfigurationSchema('BreakpointAlignmentsWidget', {});
7
7
  const stateModel = types
8
8
  .model('BreakpointAlignmentsWidget', {