@jbrowse/plugin-linear-genome-view 1.6.7 → 1.7.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.
- package/dist/BaseLinearDisplay/components/BaseLinearDisplay.js +232 -0
- package/dist/BaseLinearDisplay/components/Block.js +86 -0
- package/dist/BaseLinearDisplay/components/LinearBlocks.js +110 -0
- package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +192 -0
- package/dist/BaseLinearDisplay/index.js +41 -0
- package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +763 -0
- package/dist/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.js +24 -0
- package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +328 -0
- package/dist/LinearBareDisplay/configSchema.js +19 -0
- package/dist/LinearBareDisplay/index.js +21 -0
- package/dist/LinearBareDisplay/index.test.js +33 -0
- package/dist/LinearBareDisplay/model.d.ts +7 -7
- package/dist/LinearBareDisplay/model.js +44 -0
- package/dist/LinearBasicDisplay/components/SetMaxHeight.js +94 -0
- package/dist/LinearBasicDisplay/configSchema.js +25 -0
- package/dist/LinearBasicDisplay/index.js +23 -0
- package/dist/LinearBasicDisplay/model.d.ts +7 -7
- package/dist/LinearBasicDisplay/model.js +162 -0
- package/dist/LinearGenomeView/components/CenterLine.js +80 -0
- package/dist/LinearGenomeView/components/ExportSvgDialog.js +137 -0
- package/dist/LinearGenomeView/components/Header.js +144 -0
- package/dist/LinearGenomeView/components/HelpDialog.js +48 -0
- package/dist/LinearGenomeView/components/ImportForm.js +330 -0
- package/dist/LinearGenomeView/components/LinearGenomeView.js +129 -0
- package/dist/LinearGenomeView/components/LinearGenomeView.test.js +234 -0
- package/dist/LinearGenomeView/components/LinearGenomeViewSvg.js +349 -0
- package/dist/LinearGenomeView/components/MiniControls.js +83 -0
- package/dist/LinearGenomeView/components/OverviewRubberBand.js +310 -0
- package/dist/LinearGenomeView/components/OverviewScaleBar.d.ts +6 -6
- package/dist/LinearGenomeView/components/OverviewScaleBar.js +403 -0
- package/dist/LinearGenomeView/components/RefNameAutocomplete.js +331 -0
- package/dist/LinearGenomeView/components/RubberBand.js +309 -0
- package/dist/LinearGenomeView/components/Ruler.js +101 -0
- package/dist/LinearGenomeView/components/ScaleBar.js +184 -0
- package/dist/LinearGenomeView/components/ScaleBar.test.js +180 -0
- package/dist/LinearGenomeView/components/SearchBox.js +201 -0
- package/dist/LinearGenomeView/components/SearchResultsDialog.js +159 -0
- package/dist/LinearGenomeView/components/SequenceDialog.js +304 -0
- package/dist/LinearGenomeView/components/TrackContainer.js +179 -0
- package/dist/LinearGenomeView/components/TrackLabel.js +165 -0
- package/dist/LinearGenomeView/components/TracksContainer.js +214 -0
- package/dist/LinearGenomeView/components/VerticalGuides.js +116 -0
- package/dist/LinearGenomeView/components/ZoomControls.js +92 -0
- package/dist/LinearGenomeView/components/util.js +16 -0
- package/dist/LinearGenomeView/index.js +1418 -0
- package/dist/LinearGenomeView/index.test.js +1170 -0
- package/dist/LinearGenomeView/util.js +93 -0
- package/dist/LinearGenomeView/util.test.js +78 -0
- package/dist/index.d.ts +21 -21
- package/dist/index.js +293 -6
- package/dist/plugin-linear-genome-view.cjs.development.js +37 -22
- package/dist/plugin-linear-genome-view.cjs.development.js.map +1 -1
- package/dist/plugin-linear-genome-view.cjs.production.min.js +1 -1
- package/dist/plugin-linear-genome-view.cjs.production.min.js.map +1 -1
- package/dist/plugin-linear-genome-view.esm.js +37 -22
- package/dist/plugin-linear-genome-view.esm.js.map +1 -1
- package/package.json +4 -8
- package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +9 -12
- package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +2 -0
- package/src/BaseLinearDisplay/models/serverSideRenderedBlock.ts +10 -8
- package/src/LinearBasicDisplay/components/SetMaxHeight.tsx +21 -12
- package/src/LinearBasicDisplay/model.ts +17 -18
- package/src/LinearGenomeView/components/Header.tsx +1 -1
- package/src/LinearGenomeView/components/ImportForm.tsx +10 -4
- package/src/LinearGenomeView/components/LinearGenomeView.test.js +1 -0
- package/src/LinearGenomeView/components/OverviewScaleBar.tsx +2 -2
- package/src/LinearGenomeView/components/RubberBand.tsx +14 -24
- package/src/LinearGenomeView/components/ScaleBar.test.tsx +1 -0
- package/src/LinearGenomeView/components/ScaleBar.tsx +3 -6
- package/src/LinearGenomeView/components/SequenceDialog.tsx +1 -1
- package/src/LinearGenomeView/components/TrackContainer.tsx +31 -24
- package/src/LinearGenomeView/components/TrackLabel.tsx +1 -1
- package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +23 -47
- package/src/LinearGenomeView/index.tsx +2 -3
|
@@ -0,0 +1,1418 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.RESIZE_HANDLE_HEIGHT = exports.INTER_REGION_PADDING_WIDTH = exports.HEADER_OVERVIEW_HEIGHT = exports.HEADER_BAR_HEIGHT = void 0;
|
|
9
|
+
Object.defineProperty(exports, "ReactComponent", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _LinearGenomeView["default"];
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "RefNameAutocomplete", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function get() {
|
|
18
|
+
return _RefNameAutocomplete["default"];
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
exports.SPACING = exports.SCALE_BAR_HEIGHT = void 0;
|
|
22
|
+
Object.defineProperty(exports, "SearchBox", {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _SearchBox["default"];
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
exports.WIDGET_HEIGHT = void 0;
|
|
29
|
+
Object.defineProperty(exports, "renderToSvg", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function get() {
|
|
32
|
+
return _LinearGenomeViewSvg.renderToSvg;
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
exports.stateModelFactory = stateModelFactory;
|
|
36
|
+
|
|
37
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
38
|
+
|
|
39
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
40
|
+
|
|
41
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
42
|
+
|
|
43
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
44
|
+
|
|
45
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
46
|
+
|
|
47
|
+
var _configuration = require("@jbrowse/core/configuration");
|
|
48
|
+
|
|
49
|
+
var _models = require("@jbrowse/core/pluggableElementTypes/models");
|
|
50
|
+
|
|
51
|
+
var _mst = require("@jbrowse/core/util/types/mst");
|
|
52
|
+
|
|
53
|
+
var _ui = require("@jbrowse/core/ui");
|
|
54
|
+
|
|
55
|
+
var _util = require("@jbrowse/core/util");
|
|
56
|
+
|
|
57
|
+
var _calculateDynamicBlocks = _interopRequireDefault(require("@jbrowse/core/util/calculateDynamicBlocks"));
|
|
58
|
+
|
|
59
|
+
var _calculateStaticBlocks = _interopRequireDefault(require("@jbrowse/core/util/calculateStaticBlocks"));
|
|
60
|
+
|
|
61
|
+
var _tracks = require("@jbrowse/core/util/tracks");
|
|
62
|
+
|
|
63
|
+
var _mobx = require("mobx");
|
|
64
|
+
|
|
65
|
+
var _mobxStateTree = require("mobx-state-tree");
|
|
66
|
+
|
|
67
|
+
var _Base1DViewModel = _interopRequireDefault(require("@jbrowse/core/util/Base1DViewModel"));
|
|
68
|
+
|
|
69
|
+
var _clone = _interopRequireDefault(require("clone"));
|
|
70
|
+
|
|
71
|
+
var _fileSaver = require("file-saver");
|
|
72
|
+
|
|
73
|
+
var _Icons = require("@jbrowse/core/ui/Icons");
|
|
74
|
+
|
|
75
|
+
var _SyncAlt = _interopRequireDefault(require("@material-ui/icons/SyncAlt"));
|
|
76
|
+
|
|
77
|
+
var _Visibility = _interopRequireDefault(require("@material-ui/icons/Visibility"));
|
|
78
|
+
|
|
79
|
+
var _Label = _interopRequireDefault(require("@material-ui/icons/Label"));
|
|
80
|
+
|
|
81
|
+
var _FolderOpen = _interopRequireDefault(require("@material-ui/icons/FolderOpen"));
|
|
82
|
+
|
|
83
|
+
var _PhotoCamera = _interopRequireDefault(require("@material-ui/icons/PhotoCamera"));
|
|
84
|
+
|
|
85
|
+
var _ZoomIn = _interopRequireDefault(require("@material-ui/icons/ZoomIn"));
|
|
86
|
+
|
|
87
|
+
var _MenuOpen = _interopRequireDefault(require("@material-ui/icons/MenuOpen"));
|
|
88
|
+
|
|
89
|
+
var _LinearGenomeViewSvg = require("./components/LinearGenomeViewSvg");
|
|
90
|
+
|
|
91
|
+
var _RefNameAutocomplete = _interopRequireDefault(require("./components/RefNameAutocomplete"));
|
|
92
|
+
|
|
93
|
+
var _SearchBox = _interopRequireDefault(require("./components/SearchBox"));
|
|
94
|
+
|
|
95
|
+
var _ExportSvgDialog = _interopRequireDefault(require("./components/ExportSvgDialog"));
|
|
96
|
+
|
|
97
|
+
var _LinearGenomeView = _interopRequireDefault(require("./components/LinearGenomeView"));
|
|
98
|
+
|
|
99
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
100
|
+
|
|
101
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
102
|
+
|
|
103
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
104
|
+
|
|
105
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
106
|
+
|
|
107
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
108
|
+
|
|
109
|
+
function calculateVisibleLocStrings(contentBlocks) {
|
|
110
|
+
if (!contentBlocks.length) {
|
|
111
|
+
return '';
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
var isSingleAssemblyName = contentBlocks.every(function (block) {
|
|
115
|
+
return block.assemblyName === contentBlocks[0].assemblyName;
|
|
116
|
+
});
|
|
117
|
+
var locs = contentBlocks.map(function (block) {
|
|
118
|
+
return (0, _util.assembleLocString)(_objectSpread(_objectSpread({}, block), {}, {
|
|
119
|
+
start: Math.round(block.start),
|
|
120
|
+
end: Math.round(block.end),
|
|
121
|
+
assemblyName: isSingleAssemblyName ? undefined : block.assemblyName
|
|
122
|
+
}));
|
|
123
|
+
});
|
|
124
|
+
return locs.join(' ');
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
var HEADER_BAR_HEIGHT = 48;
|
|
128
|
+
exports.HEADER_BAR_HEIGHT = HEADER_BAR_HEIGHT;
|
|
129
|
+
var HEADER_OVERVIEW_HEIGHT = 20;
|
|
130
|
+
exports.HEADER_OVERVIEW_HEIGHT = HEADER_OVERVIEW_HEIGHT;
|
|
131
|
+
var SCALE_BAR_HEIGHT = 17;
|
|
132
|
+
exports.SCALE_BAR_HEIGHT = SCALE_BAR_HEIGHT;
|
|
133
|
+
var RESIZE_HANDLE_HEIGHT = 3;
|
|
134
|
+
exports.RESIZE_HANDLE_HEIGHT = RESIZE_HANDLE_HEIGHT;
|
|
135
|
+
var INTER_REGION_PADDING_WIDTH = 2;
|
|
136
|
+
exports.INTER_REGION_PADDING_WIDTH = INTER_REGION_PADDING_WIDTH;
|
|
137
|
+
var SPACING = 7;
|
|
138
|
+
exports.SPACING = SPACING;
|
|
139
|
+
var WIDGET_HEIGHT = 32;
|
|
140
|
+
exports.WIDGET_HEIGHT = WIDGET_HEIGHT;
|
|
141
|
+
|
|
142
|
+
function localStorageGetItem(item) {
|
|
143
|
+
return typeof localStorage !== 'undefined' ? localStorage.getItem(item) : undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function stateModelFactory(pluginManager) {
|
|
147
|
+
return _mobxStateTree.types.compose(_models.BaseViewModel, _mobxStateTree.types.model('LinearGenomeView', {
|
|
148
|
+
id: _mst.ElementId,
|
|
149
|
+
type: _mobxStateTree.types.literal('LinearGenomeView'),
|
|
150
|
+
offsetPx: 0,
|
|
151
|
+
bpPerPx: 1,
|
|
152
|
+
displayedRegions: _mobxStateTree.types.array(_mst.Region),
|
|
153
|
+
// we use an array for the tracks because the tracks are displayed in a
|
|
154
|
+
// specific order that we need to keep.
|
|
155
|
+
tracks: _mobxStateTree.types.array(pluginManager.pluggableMstType('track', 'stateModel')),
|
|
156
|
+
hideHeader: false,
|
|
157
|
+
hideHeaderOverview: false,
|
|
158
|
+
trackSelectorType: _mobxStateTree.types.optional(_mobxStateTree.types.enumeration(['hierarchical']), 'hierarchical'),
|
|
159
|
+
trackLabels: _mobxStateTree.types.optional(_mobxStateTree.types.string, function () {
|
|
160
|
+
return localStorageGetItem('lgv-trackLabels') || 'overlapping';
|
|
161
|
+
}),
|
|
162
|
+
showCenterLine: _mobxStateTree.types.optional(_mobxStateTree.types["boolean"], function () {
|
|
163
|
+
var setting = localStorageGetItem('lgv-showCenterLine');
|
|
164
|
+
return setting !== undefined && setting !== null ? !!+setting : false;
|
|
165
|
+
}),
|
|
166
|
+
showCytobandsSetting: _mobxStateTree.types.optional(_mobxStateTree.types["boolean"], function () {
|
|
167
|
+
var setting = localStorageGetItem('lgv-showCytobands');
|
|
168
|
+
return setting !== undefined && setting !== null ? !!+setting : true;
|
|
169
|
+
})
|
|
170
|
+
}))["volatile"](function () {
|
|
171
|
+
return {
|
|
172
|
+
volatileWidth: undefined,
|
|
173
|
+
minimumBlockWidth: 3,
|
|
174
|
+
draggingTrackId: undefined,
|
|
175
|
+
volatileError: undefined,
|
|
176
|
+
// array of callbacks to run after the next set of the displayedRegions,
|
|
177
|
+
// which is basically like an onLoad
|
|
178
|
+
afterDisplayedRegionsSetCallbacks: [],
|
|
179
|
+
scaleFactor: 1,
|
|
180
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
181
|
+
trackRefs: {},
|
|
182
|
+
coarseDynamicBlocks: [],
|
|
183
|
+
coarseTotalBp: 0,
|
|
184
|
+
leftOffset: undefined,
|
|
185
|
+
rightOffset: undefined,
|
|
186
|
+
searchResults: undefined,
|
|
187
|
+
searchQuery: undefined,
|
|
188
|
+
seqDialogDisplayed: false
|
|
189
|
+
};
|
|
190
|
+
}).views(function (self) {
|
|
191
|
+
return {
|
|
192
|
+
get width() {
|
|
193
|
+
if (self.volatileWidth === undefined) {
|
|
194
|
+
throw new Error('width undefined, make sure to check for model.initialized');
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
return self.volatileWidth;
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
get interRegionPaddingWidth() {
|
|
201
|
+
return INTER_REGION_PADDING_WIDTH;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
};
|
|
205
|
+
}).views(function (self) {
|
|
206
|
+
return {
|
|
207
|
+
get assemblyErrors() {
|
|
208
|
+
var _getSession = (0, _util.getSession)(self),
|
|
209
|
+
assemblyManager = _getSession.assemblyManager;
|
|
210
|
+
|
|
211
|
+
return this.assemblyNames.map(function (a) {
|
|
212
|
+
var _assemblyManager$get;
|
|
213
|
+
|
|
214
|
+
return (_assemblyManager$get = assemblyManager.get(a)) === null || _assemblyManager$get === void 0 ? void 0 : _assemblyManager$get.error;
|
|
215
|
+
}).filter(function (f) {
|
|
216
|
+
return !!f;
|
|
217
|
+
}).join(', ');
|
|
218
|
+
},
|
|
219
|
+
|
|
220
|
+
get assembliesInitialized() {
|
|
221
|
+
var _getSession2 = (0, _util.getSession)(self),
|
|
222
|
+
assemblyManager = _getSession2.assemblyManager;
|
|
223
|
+
|
|
224
|
+
return this.assemblyNames.every(function (a) {
|
|
225
|
+
var _assemblyManager$get2;
|
|
226
|
+
|
|
227
|
+
return (_assemblyManager$get2 = assemblyManager.get(a)) === null || _assemblyManager$get2 === void 0 ? void 0 : _assemblyManager$get2.initialized;
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
|
|
231
|
+
get initialized() {
|
|
232
|
+
return self.volatileWidth !== undefined && this.assembliesInitialized;
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
get hasDisplayedRegions() {
|
|
236
|
+
return self.displayedRegions.length > 0;
|
|
237
|
+
},
|
|
238
|
+
|
|
239
|
+
get isSearchDialogDisplayed() {
|
|
240
|
+
return self.searchResults !== undefined;
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
get scaleBarHeight() {
|
|
244
|
+
return SCALE_BAR_HEIGHT + RESIZE_HANDLE_HEIGHT;
|
|
245
|
+
},
|
|
246
|
+
|
|
247
|
+
get headerHeight() {
|
|
248
|
+
if (self.hideHeader) {
|
|
249
|
+
return 0;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (self.hideHeaderOverview) {
|
|
253
|
+
return HEADER_BAR_HEIGHT;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return HEADER_BAR_HEIGHT + HEADER_OVERVIEW_HEIGHT;
|
|
257
|
+
},
|
|
258
|
+
|
|
259
|
+
get trackHeights() {
|
|
260
|
+
return self.tracks.map(function (t) {
|
|
261
|
+
return t.displays[0].height;
|
|
262
|
+
}).reduce(function (a, b) {
|
|
263
|
+
return a + b;
|
|
264
|
+
}, 0);
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
get trackHeightsWithResizeHandles() {
|
|
268
|
+
return this.trackHeights + self.tracks.length * RESIZE_HANDLE_HEIGHT;
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
get height() {
|
|
272
|
+
return this.trackHeightsWithResizeHandles + this.headerHeight + this.scaleBarHeight;
|
|
273
|
+
},
|
|
274
|
+
|
|
275
|
+
get totalBp() {
|
|
276
|
+
return self.displayedRegions.reduce(function (a, b) {
|
|
277
|
+
return a + b.end - b.start;
|
|
278
|
+
}, 0);
|
|
279
|
+
},
|
|
280
|
+
|
|
281
|
+
get maxBpPerPx() {
|
|
282
|
+
return this.totalBp / (self.width * 0.9);
|
|
283
|
+
},
|
|
284
|
+
|
|
285
|
+
get minBpPerPx() {
|
|
286
|
+
return 1 / 50;
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
get error() {
|
|
290
|
+
return self.volatileError || this.assemblyErrors;
|
|
291
|
+
},
|
|
292
|
+
|
|
293
|
+
get maxOffset() {
|
|
294
|
+
// objectively determined to keep the linear genome on the main screen
|
|
295
|
+
var leftPadding = 10;
|
|
296
|
+
return this.displayedRegionsTotalPx - leftPadding;
|
|
297
|
+
},
|
|
298
|
+
|
|
299
|
+
get minOffset() {
|
|
300
|
+
// objectively determined to keep the linear genome on the main screen
|
|
301
|
+
var rightPadding = 30;
|
|
302
|
+
return -self.width + rightPadding;
|
|
303
|
+
},
|
|
304
|
+
|
|
305
|
+
get displayedRegionsTotalPx() {
|
|
306
|
+
return this.totalBp / self.bpPerPx;
|
|
307
|
+
},
|
|
308
|
+
|
|
309
|
+
renderProps: function renderProps() {
|
|
310
|
+
return _objectSpread(_objectSpread({}, (0, _tracks.getParentRenderProps)(self)), {}, {
|
|
311
|
+
bpPerPx: self.bpPerPx,
|
|
312
|
+
highResolutionScaling: (0, _configuration.getConf)((0, _util.getSession)(self), 'highResolutionScaling')
|
|
313
|
+
});
|
|
314
|
+
},
|
|
315
|
+
|
|
316
|
+
get assemblyNames() {
|
|
317
|
+
return (0, _toConsumableArray2["default"])(new Set(self.displayedRegions.map(function (region) {
|
|
318
|
+
return region.assemblyName;
|
|
319
|
+
})));
|
|
320
|
+
},
|
|
321
|
+
|
|
322
|
+
searchScope: function searchScope(assemblyName) {
|
|
323
|
+
return {
|
|
324
|
+
assemblyName: assemblyName,
|
|
325
|
+
includeAggregateIndexes: true,
|
|
326
|
+
tracks: self.tracks
|
|
327
|
+
};
|
|
328
|
+
},
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* @param refName - refName of the displayedRegion
|
|
332
|
+
* @param coord - coordinate at the displayed Region
|
|
333
|
+
* @param regionNumber - optional param used as identifier when
|
|
334
|
+
* there are multiple displayedRegions with the same refName
|
|
335
|
+
* @returns offsetPx of the displayed region that it lands in
|
|
336
|
+
*/
|
|
337
|
+
bpToPx: function bpToPx(_ref) {
|
|
338
|
+
var refName = _ref.refName,
|
|
339
|
+
coord = _ref.coord,
|
|
340
|
+
regionNumber = _ref.regionNumber;
|
|
341
|
+
return (0, _util.viewBpToPx)({
|
|
342
|
+
refName: refName,
|
|
343
|
+
coord: coord,
|
|
344
|
+
regionNumber: regionNumber,
|
|
345
|
+
self: self
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
*
|
|
351
|
+
* @param px - px in the view area, return value is the displayed regions
|
|
352
|
+
* @returns BpOffset of the displayed region that it lands in
|
|
353
|
+
*/
|
|
354
|
+
pxToBp: function pxToBp(px) {
|
|
355
|
+
var bpSoFar = 0;
|
|
356
|
+
var bp = (self.offsetPx + px) * self.bpPerPx;
|
|
357
|
+
var n = self.displayedRegions.length;
|
|
358
|
+
|
|
359
|
+
if (bp < 0) {
|
|
360
|
+
var region = self.displayedRegions[0];
|
|
361
|
+
var offset = bp;
|
|
362
|
+
return _objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(region)), {}, {
|
|
363
|
+
oob: true,
|
|
364
|
+
coord: region.reversed ? Math.floor(region.end - offset) + 1 : Math.floor(region.start + offset) + 1,
|
|
365
|
+
offset: offset,
|
|
366
|
+
index: 0
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
var interRegionPaddingBp = self.interRegionPaddingWidth * self.bpPerPx;
|
|
371
|
+
var minimumBlockBp = self.minimumBlockWidth * self.bpPerPx;
|
|
372
|
+
|
|
373
|
+
for (var index = 0; index < self.displayedRegions.length; index += 1) {
|
|
374
|
+
var _region = self.displayedRegions[index];
|
|
375
|
+
var len = _region.end - _region.start;
|
|
376
|
+
|
|
377
|
+
var _offset = bp - bpSoFar;
|
|
378
|
+
|
|
379
|
+
if (len + bpSoFar > bp && bpSoFar <= bp) {
|
|
380
|
+
return _objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(_region)), {}, {
|
|
381
|
+
oob: false,
|
|
382
|
+
offset: _offset,
|
|
383
|
+
coord: _region.reversed ? Math.floor(_region.end - _offset) + 1 : Math.floor(_region.start + _offset) + 1,
|
|
384
|
+
index: index
|
|
385
|
+
});
|
|
386
|
+
} // add the interRegionPaddingWidth if the boundary is in the screen
|
|
387
|
+
// e.g. offset>0 && offset<width
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
if (_region.end - _region.start > minimumBlockBp && _offset / self.bpPerPx > 0 && _offset / self.bpPerPx < self.width) {
|
|
391
|
+
bpSoFar += len + interRegionPaddingBp;
|
|
392
|
+
} else {
|
|
393
|
+
bpSoFar += len;
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
if (bp >= bpSoFar) {
|
|
398
|
+
var _region2 = self.displayedRegions[n - 1];
|
|
399
|
+
|
|
400
|
+
var _len = _region2.end - _region2.start;
|
|
401
|
+
|
|
402
|
+
var _offset2 = bp - bpSoFar + _len;
|
|
403
|
+
|
|
404
|
+
return _objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(_region2)), {}, {
|
|
405
|
+
oob: true,
|
|
406
|
+
offset: _offset2,
|
|
407
|
+
coord: _region2.reversed ? Math.floor(_region2.end - _offset2) + 1 : Math.floor(_region2.start + _offset2) + 1,
|
|
408
|
+
index: n - 1
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return {
|
|
413
|
+
coord: 0,
|
|
414
|
+
index: 0,
|
|
415
|
+
refName: '',
|
|
416
|
+
oob: true,
|
|
417
|
+
assemblyName: '',
|
|
418
|
+
offset: 0,
|
|
419
|
+
start: 0,
|
|
420
|
+
end: 0,
|
|
421
|
+
reversed: false
|
|
422
|
+
};
|
|
423
|
+
},
|
|
424
|
+
getTrack: function getTrack(id) {
|
|
425
|
+
return self.tracks.find(function (t) {
|
|
426
|
+
return t.configuration.trackId === id;
|
|
427
|
+
});
|
|
428
|
+
},
|
|
429
|
+
rankSearchResults: function rankSearchResults(results) {
|
|
430
|
+
// order of rank
|
|
431
|
+
var openTrackIds = self.tracks.map(function (track) {
|
|
432
|
+
return track.configuration.trackId;
|
|
433
|
+
});
|
|
434
|
+
results.forEach(function (result) {
|
|
435
|
+
if (openTrackIds !== []) {
|
|
436
|
+
if (openTrackIds.includes(result.trackId)) {
|
|
437
|
+
result.updateScore(result.getScore() + 1);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
});
|
|
441
|
+
return results;
|
|
442
|
+
},
|
|
443
|
+
// modifies view menu action onClick to apply to all tracks of same type
|
|
444
|
+
rewriteOnClicks: function rewriteOnClicks(trackType, viewMenuActions) {
|
|
445
|
+
var _this = this;
|
|
446
|
+
|
|
447
|
+
viewMenuActions.forEach(function (action) {
|
|
448
|
+
// go to lowest level menu
|
|
449
|
+
if ('subMenu' in action) {
|
|
450
|
+
_this.rewriteOnClicks(trackType, action.subMenu);
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
if ('onClick' in action) {
|
|
454
|
+
var holdOnClick = action.onClick;
|
|
455
|
+
|
|
456
|
+
action.onClick = function () {
|
|
457
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key = 0; _key < _len2; _key++) {
|
|
458
|
+
args[_key] = arguments[_key];
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
self.tracks.forEach(function (track) {
|
|
462
|
+
if (track.type === trackType) {
|
|
463
|
+
holdOnClick.apply(track, [track].concat(args));
|
|
464
|
+
}
|
|
465
|
+
});
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
get trackTypeActions() {
|
|
472
|
+
var _this2 = this;
|
|
473
|
+
|
|
474
|
+
var allActions = new Map();
|
|
475
|
+
self.tracks.forEach(function (track) {
|
|
476
|
+
var trackInMap = allActions.get(track.type);
|
|
477
|
+
|
|
478
|
+
if (!trackInMap) {
|
|
479
|
+
var viewMenuActions = (0, _clone["default"])(track.viewMenuActions);
|
|
480
|
+
|
|
481
|
+
_this2.rewriteOnClicks(track.type, viewMenuActions);
|
|
482
|
+
|
|
483
|
+
allActions.set(track.type, viewMenuActions);
|
|
484
|
+
}
|
|
485
|
+
});
|
|
486
|
+
return allActions;
|
|
487
|
+
},
|
|
488
|
+
|
|
489
|
+
get centerLineInfo() {
|
|
490
|
+
return self.displayedRegions.length ? this.pxToBp(self.width / 2) : undefined;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
};
|
|
494
|
+
}).actions(function (self) {
|
|
495
|
+
return {
|
|
496
|
+
setShowCytobands: function setShowCytobands(flag) {
|
|
497
|
+
self.showCytobandsSetting = flag;
|
|
498
|
+
localStorage.setItem('lgv-showCytobands', "".concat(+flag));
|
|
499
|
+
},
|
|
500
|
+
setWidth: function setWidth(newWidth) {
|
|
501
|
+
self.volatileWidth = newWidth;
|
|
502
|
+
},
|
|
503
|
+
setError: function setError(error) {
|
|
504
|
+
self.volatileError = error;
|
|
505
|
+
},
|
|
506
|
+
toggleHeader: function toggleHeader() {
|
|
507
|
+
self.hideHeader = !self.hideHeader;
|
|
508
|
+
},
|
|
509
|
+
toggleHeaderOverview: function toggleHeaderOverview() {
|
|
510
|
+
self.hideHeaderOverview = !self.hideHeaderOverview;
|
|
511
|
+
},
|
|
512
|
+
scrollTo: function scrollTo(offsetPx) {
|
|
513
|
+
var newOffsetPx = (0, _util.clamp)(offsetPx, self.minOffset, self.maxOffset);
|
|
514
|
+
self.offsetPx = newOffsetPx;
|
|
515
|
+
return newOffsetPx;
|
|
516
|
+
},
|
|
517
|
+
zoomTo: function zoomTo(bpPerPx) {
|
|
518
|
+
var newBpPerPx = (0, _util.clamp)(bpPerPx, self.minBpPerPx, self.maxBpPerPx);
|
|
519
|
+
|
|
520
|
+
if (newBpPerPx === self.bpPerPx) {
|
|
521
|
+
return newBpPerPx;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
var oldBpPerPx = self.bpPerPx;
|
|
525
|
+
self.bpPerPx = newBpPerPx;
|
|
526
|
+
|
|
527
|
+
if (Math.abs(oldBpPerPx - newBpPerPx) < 0.000001) {
|
|
528
|
+
console.warn('zoomTo bpPerPx rounding error');
|
|
529
|
+
return oldBpPerPx;
|
|
530
|
+
} // tweak the offset so that the center of the view remains at the same coordinate
|
|
531
|
+
|
|
532
|
+
|
|
533
|
+
var viewWidth = self.width;
|
|
534
|
+
this.scrollTo(Math.round((self.offsetPx + viewWidth / 2) * oldBpPerPx / newBpPerPx - viewWidth / 2));
|
|
535
|
+
return newBpPerPx;
|
|
536
|
+
},
|
|
537
|
+
setOffsets: function setOffsets(left, right) {
|
|
538
|
+
// sets offsets used in the get sequence dialog
|
|
539
|
+
self.leftOffset = left;
|
|
540
|
+
self.rightOffset = right;
|
|
541
|
+
},
|
|
542
|
+
setSearchResults: function setSearchResults(results, query) {
|
|
543
|
+
self.searchResults = results;
|
|
544
|
+
self.searchQuery = query;
|
|
545
|
+
},
|
|
546
|
+
setSequenceDialogOpen: function setSequenceDialogOpen(open) {
|
|
547
|
+
self.seqDialogDisplayed = open;
|
|
548
|
+
},
|
|
549
|
+
setNewView: function setNewView(bpPerPx, offsetPx) {
|
|
550
|
+
this.zoomTo(bpPerPx);
|
|
551
|
+
this.scrollTo(offsetPx);
|
|
552
|
+
},
|
|
553
|
+
horizontallyFlip: function horizontallyFlip() {
|
|
554
|
+
self.displayedRegions = (0, _mobxStateTree.cast)(self.displayedRegions.slice().reverse().map(function (region) {
|
|
555
|
+
return _objectSpread(_objectSpread({}, region), {}, {
|
|
556
|
+
reversed: !region.reversed
|
|
557
|
+
});
|
|
558
|
+
}));
|
|
559
|
+
this.scrollTo(self.totalBp / self.bpPerPx - self.offsetPx - self.width);
|
|
560
|
+
},
|
|
561
|
+
showTrack: function showTrack(trackId) {
|
|
562
|
+
var initialSnapshot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
563
|
+
var displayInitialSnapshot = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
564
|
+
var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
|
|
565
|
+
var configuration = (0, _mobxStateTree.resolveIdentifier)(trackConfigSchema, (0, _mobxStateTree.getRoot)(self), trackId);
|
|
566
|
+
|
|
567
|
+
if (!configuration) {
|
|
568
|
+
throw new Error("Could not resolve identifier \"".concat(trackId, "\""));
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
var trackType = pluginManager.getTrackType(configuration === null || configuration === void 0 ? void 0 : configuration.type);
|
|
572
|
+
|
|
573
|
+
if (!trackType) {
|
|
574
|
+
throw new Error("Unknown track type ".concat(configuration.type));
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
var viewType = pluginManager.getViewType(self.type);
|
|
578
|
+
var supportedDisplays = viewType.displayTypes.map(function (displayType) {
|
|
579
|
+
return displayType.name;
|
|
580
|
+
});
|
|
581
|
+
var displayConf = configuration.displays.find(function (d) {
|
|
582
|
+
return supportedDisplays.includes(d.type);
|
|
583
|
+
});
|
|
584
|
+
|
|
585
|
+
if (!displayConf) {
|
|
586
|
+
throw new Error("Could not find a compatible display for view type ".concat(self.type));
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
var shownTracks = self.tracks.filter(function (t) {
|
|
590
|
+
return t.configuration === configuration;
|
|
591
|
+
});
|
|
592
|
+
|
|
593
|
+
if (shownTracks.length === 0) {
|
|
594
|
+
var track = trackType.stateModel.create(_objectSpread(_objectSpread({}, initialSnapshot), {}, {
|
|
595
|
+
type: configuration.type,
|
|
596
|
+
configuration: configuration,
|
|
597
|
+
displays: [_objectSpread({
|
|
598
|
+
type: displayConf.type,
|
|
599
|
+
configuration: displayConf
|
|
600
|
+
}, displayInitialSnapshot)]
|
|
601
|
+
}));
|
|
602
|
+
self.tracks.push(track);
|
|
603
|
+
return track;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
return shownTracks[0];
|
|
607
|
+
},
|
|
608
|
+
hideTrack: function hideTrack(trackId) {
|
|
609
|
+
var trackConfigSchema = pluginManager.pluggableConfigSchemaType('track');
|
|
610
|
+
var configuration = (0, _mobxStateTree.resolveIdentifier)(trackConfigSchema, (0, _mobxStateTree.getRoot)(self), trackId); // if we have any tracks with that configuration, turn them off
|
|
611
|
+
|
|
612
|
+
var shownTracks = self.tracks.filter(function (t) {
|
|
613
|
+
return t.configuration === configuration;
|
|
614
|
+
});
|
|
615
|
+
(0, _mobx.transaction)(function () {
|
|
616
|
+
return shownTracks.forEach(function (t) {
|
|
617
|
+
return self.tracks.remove(t);
|
|
618
|
+
});
|
|
619
|
+
});
|
|
620
|
+
return shownTracks.length;
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
}).actions(function (self) {
|
|
624
|
+
return {
|
|
625
|
+
moveTrack: function moveTrack(movingTrackId, targetTrackId) {
|
|
626
|
+
var oldIndex = self.tracks.findIndex(function (track) {
|
|
627
|
+
return track.id === movingTrackId;
|
|
628
|
+
});
|
|
629
|
+
|
|
630
|
+
if (oldIndex === -1) {
|
|
631
|
+
throw new Error("Track ID ".concat(movingTrackId, " not found"));
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
var newIndex = self.tracks.findIndex(function (track) {
|
|
635
|
+
return track.id === targetTrackId;
|
|
636
|
+
});
|
|
637
|
+
|
|
638
|
+
if (newIndex === -1) {
|
|
639
|
+
throw new Error("Track ID ".concat(targetTrackId, " not found"));
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
var track = (0, _mobxStateTree.getSnapshot)(self.tracks[oldIndex]);
|
|
643
|
+
self.tracks.splice(oldIndex, 1);
|
|
644
|
+
self.tracks.splice(newIndex, 0, track);
|
|
645
|
+
},
|
|
646
|
+
closeView: function closeView() {
|
|
647
|
+
var parent = (0, _util.getContainingView)(self);
|
|
648
|
+
|
|
649
|
+
if (parent) {
|
|
650
|
+
// I am embedded in a some other view
|
|
651
|
+
if ((0, _util.isViewContainer)(parent)) {
|
|
652
|
+
parent.removeView(self);
|
|
653
|
+
}
|
|
654
|
+
} else {
|
|
655
|
+
// I am part of a session
|
|
656
|
+
(0, _util.getSession)(self).removeView(self);
|
|
657
|
+
}
|
|
658
|
+
},
|
|
659
|
+
toggleTrack: function toggleTrack(trackId) {
|
|
660
|
+
// if we have any tracks with that configuration, turn them off
|
|
661
|
+
var hiddenCount = self.hideTrack(trackId); // if none had that configuration, turn one on
|
|
662
|
+
|
|
663
|
+
if (!hiddenCount) {
|
|
664
|
+
self.showTrack(trackId);
|
|
665
|
+
}
|
|
666
|
+
},
|
|
667
|
+
setTrackLabels: function setTrackLabels(setting) {
|
|
668
|
+
self.trackLabels = setting;
|
|
669
|
+
localStorage.setItem('lgv-trackLabels', setting);
|
|
670
|
+
},
|
|
671
|
+
toggleCenterLine: function toggleCenterLine() {
|
|
672
|
+
self.showCenterLine = !self.showCenterLine;
|
|
673
|
+
localStorage.setItem('lgv-showCenterLine', "".concat(+self.showCenterLine));
|
|
674
|
+
},
|
|
675
|
+
setDisplayedRegions: function setDisplayedRegions(regions) {
|
|
676
|
+
self.displayedRegions = (0, _mobxStateTree.cast)(regions);
|
|
677
|
+
self.zoomTo(self.bpPerPx);
|
|
678
|
+
},
|
|
679
|
+
activateTrackSelector: function activateTrackSelector() {
|
|
680
|
+
if (self.trackSelectorType === 'hierarchical') {
|
|
681
|
+
var session = (0, _util.getSession)(self);
|
|
682
|
+
|
|
683
|
+
if ((0, _util.isSessionModelWithWidgets)(session)) {
|
|
684
|
+
var selector = session.addWidget('HierarchicalTrackSelectorWidget', 'hierarchicalTrackSelector', {
|
|
685
|
+
view: self
|
|
686
|
+
});
|
|
687
|
+
session.showWidget(selector);
|
|
688
|
+
return selector;
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
throw new Error("invalid track selector type ".concat(self.trackSelectorType));
|
|
693
|
+
},
|
|
694
|
+
navToLocString: function navToLocString(locString, optAssemblyName) {
|
|
695
|
+
var assemblyNames = self.assemblyNames;
|
|
696
|
+
|
|
697
|
+
var _getSession3 = (0, _util.getSession)(self),
|
|
698
|
+
assemblyManager = _getSession3.assemblyManager;
|
|
699
|
+
|
|
700
|
+
var isValidRefName = assemblyManager.isValidRefName;
|
|
701
|
+
var assemblyName = optAssemblyName || assemblyNames[0];
|
|
702
|
+
var parsedLocStrings = locString.split(' ').filter(function (f) {
|
|
703
|
+
return !!f.trim();
|
|
704
|
+
}).map(function (l) {
|
|
705
|
+
return (0, _util.parseLocString)(l, function (ref) {
|
|
706
|
+
return isValidRefName(ref, assemblyName);
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
var locations = parsedLocStrings.map(function (region) {
|
|
710
|
+
var asmName = region.assemblyName || assemblyName;
|
|
711
|
+
var asm = assemblyManager.get(asmName);
|
|
712
|
+
var refName = region.refName;
|
|
713
|
+
|
|
714
|
+
if (!asm) {
|
|
715
|
+
throw new Error("assembly ".concat(asmName, " not found"));
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
var regions = asm.regions;
|
|
719
|
+
|
|
720
|
+
if (!regions) {
|
|
721
|
+
throw new Error("regions not loaded yet for ".concat(asmName));
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
var canonicalRefName = asm.getCanonicalRefName(region.refName);
|
|
725
|
+
|
|
726
|
+
if (!canonicalRefName) {
|
|
727
|
+
throw new Error("Could not find refName ".concat(refName, " in ").concat(asm.name));
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
var parentRegion = regions.find(function (region) {
|
|
731
|
+
return region.refName === canonicalRefName;
|
|
732
|
+
});
|
|
733
|
+
|
|
734
|
+
if (!parentRegion) {
|
|
735
|
+
throw new Error("Could not find refName ".concat(refName, " in ").concat(asmName));
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
return _objectSpread(_objectSpread({}, region), {}, {
|
|
739
|
+
assemblyName: asmName,
|
|
740
|
+
parentRegion: parentRegion
|
|
741
|
+
});
|
|
742
|
+
});
|
|
743
|
+
|
|
744
|
+
if (locations.length === 1) {
|
|
745
|
+
var loc = locations[0];
|
|
746
|
+
this.setDisplayedRegions([_objectSpread({
|
|
747
|
+
reversed: loc.reversed
|
|
748
|
+
}, loc.parentRegion)]);
|
|
749
|
+
var start = loc.start,
|
|
750
|
+
end = loc.end,
|
|
751
|
+
parentRegion = loc.parentRegion;
|
|
752
|
+
this.navTo(_objectSpread(_objectSpread({}, loc), {}, {
|
|
753
|
+
start: (0, _util.clamp)(start !== null && start !== void 0 ? start : 0, 0, parentRegion.end),
|
|
754
|
+
end: (0, _util.clamp)(end !== null && end !== void 0 ? end : parentRegion.end, 0, parentRegion.end)
|
|
755
|
+
}));
|
|
756
|
+
} else {
|
|
757
|
+
this.setDisplayedRegions( // @ts-ignore
|
|
758
|
+
locations.map(function (r) {
|
|
759
|
+
return r.start === undefined ? r.parentRegion : r;
|
|
760
|
+
}));
|
|
761
|
+
this.showAllRegions();
|
|
762
|
+
}
|
|
763
|
+
},
|
|
764
|
+
|
|
765
|
+
/**
|
|
766
|
+
* Navigate to a location based on its refName and optionally start, end,
|
|
767
|
+
* and assemblyName. Can handle if there are multiple displayedRegions
|
|
768
|
+
* from same refName. Only navigates to a location if it is entirely
|
|
769
|
+
* within a displayedRegion. Navigates to the first matching location
|
|
770
|
+
* encountered.
|
|
771
|
+
*
|
|
772
|
+
* Throws an error if navigation was unsuccessful
|
|
773
|
+
*
|
|
774
|
+
* @param location - a proposed location to navigate to
|
|
775
|
+
*/
|
|
776
|
+
navTo: function navTo(query) {
|
|
777
|
+
this.navToMultiple([query]);
|
|
778
|
+
},
|
|
779
|
+
navToMultiple: function navToMultiple(locations) {
|
|
780
|
+
var firstLocation = locations[0];
|
|
781
|
+
var refName = firstLocation.refName;
|
|
782
|
+
var start = firstLocation.start,
|
|
783
|
+
end = firstLocation.end,
|
|
784
|
+
_firstLocation$assemb = firstLocation.assemblyName,
|
|
785
|
+
assemblyName = _firstLocation$assemb === void 0 ? self.assemblyNames[0] : _firstLocation$assemb;
|
|
786
|
+
|
|
787
|
+
if (start !== undefined && end !== undefined && start > end) {
|
|
788
|
+
throw new Error("start \"".concat(start + 1, "\" is greater than end \"").concat(end, "\""));
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
var session = (0, _util.getSession)(self);
|
|
792
|
+
var assemblyManager = session.assemblyManager;
|
|
793
|
+
var assembly = assemblyManager.get(assemblyName);
|
|
794
|
+
|
|
795
|
+
if (assembly) {
|
|
796
|
+
var canonicalRefName = assembly.getCanonicalRefName(refName);
|
|
797
|
+
|
|
798
|
+
if (canonicalRefName) {
|
|
799
|
+
refName = canonicalRefName;
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
var s = start;
|
|
804
|
+
var e = end;
|
|
805
|
+
var refNameMatched = false;
|
|
806
|
+
|
|
807
|
+
var predicate = function predicate(r) {
|
|
808
|
+
if (refName === r.refName) {
|
|
809
|
+
refNameMatched = true;
|
|
810
|
+
|
|
811
|
+
if (s === undefined) {
|
|
812
|
+
s = r.start;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
if (e === undefined) {
|
|
816
|
+
e = r.end;
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
if (s >= r.start && s <= r.end && e <= r.end && e >= r.start) {
|
|
820
|
+
return true;
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
s = start;
|
|
824
|
+
e = end;
|
|
825
|
+
}
|
|
826
|
+
|
|
827
|
+
return false;
|
|
828
|
+
};
|
|
829
|
+
|
|
830
|
+
var lastIndex = (0, _util.findLastIndex)(self.displayedRegions, predicate);
|
|
831
|
+
var index;
|
|
832
|
+
|
|
833
|
+
while (index !== lastIndex) {
|
|
834
|
+
try {
|
|
835
|
+
var previousIndex = index;
|
|
836
|
+
index = self.displayedRegions.slice(previousIndex === undefined ? 0 : previousIndex + 1).findIndex(predicate);
|
|
837
|
+
|
|
838
|
+
if (previousIndex !== undefined) {
|
|
839
|
+
index += previousIndex + 1;
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
if (!refNameMatched) {
|
|
843
|
+
throw new Error("could not find a region with refName \"".concat(refName, "\""));
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
if (s === undefined) {
|
|
847
|
+
throw new Error("could not find a region with refName \"".concat(refName, "\" that contained an end position ").concat(e));
|
|
848
|
+
}
|
|
849
|
+
|
|
850
|
+
if (e === undefined) {
|
|
851
|
+
throw new Error("could not find a region with refName \"".concat(refName, "\" that contained a start position ").concat(s + 1));
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
if (index === -1) {
|
|
855
|
+
throw new Error("could not find a region that completely contained \"".concat((0, _util.assembleLocString)(firstLocation), "\""));
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
if (locations.length === 1) {
|
|
859
|
+
var f = self.displayedRegions[index];
|
|
860
|
+
this.moveTo({
|
|
861
|
+
index: index,
|
|
862
|
+
offset: f.reversed ? f.end - e : s - f.start
|
|
863
|
+
}, {
|
|
864
|
+
index: index,
|
|
865
|
+
offset: f.reversed ? f.end - s : e - f.start
|
|
866
|
+
});
|
|
867
|
+
return;
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
var locationIndex = 0;
|
|
871
|
+
var locationStart = 0;
|
|
872
|
+
var locationEnd = 0;
|
|
873
|
+
|
|
874
|
+
for (locationIndex; locationIndex < locations.length; locationIndex++) {
|
|
875
|
+
var location = locations[locationIndex];
|
|
876
|
+
var region = self.displayedRegions[index + locationIndex];
|
|
877
|
+
locationStart = location.start || region.start;
|
|
878
|
+
locationEnd = location.end || region.end;
|
|
879
|
+
|
|
880
|
+
if (location.refName !== region.refName) {
|
|
881
|
+
throw new Error("Entered location ".concat((0, _util.assembleLocString)(location), " does not match with displayed regions"));
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
locationIndex -= 1;
|
|
886
|
+
var startDisplayedRegion = self.displayedRegions[index];
|
|
887
|
+
var endDisplayedRegion = self.displayedRegions[index + locationIndex];
|
|
888
|
+
this.moveTo({
|
|
889
|
+
index: index,
|
|
890
|
+
offset: startDisplayedRegion.reversed ? startDisplayedRegion.end - e : s - startDisplayedRegion.start
|
|
891
|
+
}, {
|
|
892
|
+
index: index + locationIndex,
|
|
893
|
+
offset: endDisplayedRegion.reversed ? endDisplayedRegion.end - locationStart : locationEnd - endDisplayedRegion.start
|
|
894
|
+
});
|
|
895
|
+
return;
|
|
896
|
+
} catch (error) {
|
|
897
|
+
if (index === lastIndex) {
|
|
898
|
+
throw error;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
}
|
|
902
|
+
},
|
|
903
|
+
|
|
904
|
+
/**
|
|
905
|
+
* Navigate to a location based on user clicking and dragging on the
|
|
906
|
+
* overview scale bar to select a region to zoom into.
|
|
907
|
+
* Can handle if there are multiple displayedRegions from same refName.
|
|
908
|
+
* Only navigates to a location if it is entirely within a displayedRegion.
|
|
909
|
+
*
|
|
910
|
+
* @param leftPx- `object as {start, end, index, offset}`, offset = start of user drag
|
|
911
|
+
* @param rightPx- `object as {start, end, index, offset}`, offset = end of user drag
|
|
912
|
+
*/
|
|
913
|
+
zoomToDisplayedRegions: function zoomToDisplayedRegions(leftPx, rightPx) {
|
|
914
|
+
if (leftPx === undefined || rightPx === undefined) {
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
var singleRefSeq = leftPx.refName === rightPx.refName && leftPx.index === rightPx.index; // zooming into one displayed Region
|
|
919
|
+
|
|
920
|
+
if (singleRefSeq && rightPx.offset < leftPx.offset || leftPx.index > rightPx.index) {
|
|
921
|
+
;
|
|
922
|
+
var _ref2 = [rightPx, leftPx];
|
|
923
|
+
leftPx = _ref2[0];
|
|
924
|
+
rightPx = _ref2[1];
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
var startOffset = {
|
|
928
|
+
start: leftPx.start,
|
|
929
|
+
end: leftPx.end,
|
|
930
|
+
index: leftPx.index,
|
|
931
|
+
offset: leftPx.offset
|
|
932
|
+
};
|
|
933
|
+
var endOffset = {
|
|
934
|
+
start: rightPx.start,
|
|
935
|
+
end: rightPx.end,
|
|
936
|
+
index: rightPx.index,
|
|
937
|
+
offset: rightPx.offset
|
|
938
|
+
};
|
|
939
|
+
|
|
940
|
+
if (startOffset && endOffset) {
|
|
941
|
+
this.moveTo(startOffset, endOffset);
|
|
942
|
+
} else {
|
|
943
|
+
var session = (0, _util.getSession)(self);
|
|
944
|
+
session.notify('No regions found to navigate to', 'warning');
|
|
945
|
+
}
|
|
946
|
+
},
|
|
947
|
+
|
|
948
|
+
/**
|
|
949
|
+
* Helper method for the fetchSequence.
|
|
950
|
+
* Retrieves the corresponding regions that were selected by the rubberband
|
|
951
|
+
*
|
|
952
|
+
* @param leftOffset - `object as {start, end, index, offset}`, offset = start of user drag
|
|
953
|
+
* @param rightOffset - `object as {start, end, index, offset}`, offset = end of user drag
|
|
954
|
+
* @returns array of Region[]
|
|
955
|
+
*/
|
|
956
|
+
getSelectedRegions: function getSelectedRegions(leftOffset, rightOffset) {
|
|
957
|
+
var simView = _Base1DViewModel["default"].create(_objectSpread(_objectSpread({}, (0, _mobxStateTree.getSnapshot)(self)), {}, {
|
|
958
|
+
interRegionPaddingWidth: self.interRegionPaddingWidth
|
|
959
|
+
}));
|
|
960
|
+
|
|
961
|
+
simView.setVolatileWidth(self.width);
|
|
962
|
+
simView.zoomToDisplayedRegions(leftOffset, rightOffset);
|
|
963
|
+
return simView.dynamicBlocks.contentBlocks.map(function (region) {
|
|
964
|
+
return _objectSpread(_objectSpread({}, region), {}, {
|
|
965
|
+
start: Math.floor(region.start),
|
|
966
|
+
end: Math.ceil(region.end)
|
|
967
|
+
});
|
|
968
|
+
});
|
|
969
|
+
},
|
|
970
|
+
// schedule something to be run after the next time displayedRegions is set
|
|
971
|
+
afterDisplayedRegionsSet: function afterDisplayedRegionsSet(cb) {
|
|
972
|
+
self.afterDisplayedRegionsSetCallbacks.push(cb);
|
|
973
|
+
},
|
|
974
|
+
|
|
975
|
+
/**
|
|
976
|
+
* offset is the base-pair-offset in the displayed region, index is the index of the
|
|
977
|
+
* displayed region in the linear genome view
|
|
978
|
+
*
|
|
979
|
+
* @param start - object as `{start, end, offset, index}`
|
|
980
|
+
* @param end - object as `{start, end, offset, index}`
|
|
981
|
+
*/
|
|
982
|
+
moveTo: function moveTo(start, end) {
|
|
983
|
+
// find locations in the modellist
|
|
984
|
+
var bpSoFar = 0;
|
|
985
|
+
|
|
986
|
+
if (start.index === end.index) {
|
|
987
|
+
bpSoFar += end.offset - start.offset;
|
|
988
|
+
} else {
|
|
989
|
+
var s = self.displayedRegions[start.index];
|
|
990
|
+
bpSoFar += s.end - s.start - start.offset;
|
|
991
|
+
|
|
992
|
+
if (end.index - start.index >= 2) {
|
|
993
|
+
for (var i = start.index + 1; i < end.index; i += 1) {
|
|
994
|
+
bpSoFar += self.displayedRegions[i].end - self.displayedRegions[i].start;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
bpSoFar += end.offset;
|
|
999
|
+
}
|
|
1000
|
+
|
|
1001
|
+
var targetBpPerPx = bpSoFar / (self.width - self.interRegionPaddingWidth * (end.index - start.index));
|
|
1002
|
+
var newBpPerPx = self.zoomTo(targetBpPerPx); // If our target bpPerPx was smaller than the allowed minBpPerPx, adjust
|
|
1003
|
+
// the scroll so the requested range is in the middle of the screen
|
|
1004
|
+
|
|
1005
|
+
var extraBp = 0;
|
|
1006
|
+
|
|
1007
|
+
if (targetBpPerPx < newBpPerPx) {
|
|
1008
|
+
extraBp = (newBpPerPx - targetBpPerPx) * self.width / 2;
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
var bpToStart = -extraBp;
|
|
1012
|
+
|
|
1013
|
+
for (var _i = 0; _i < self.displayedRegions.length; _i += 1) {
|
|
1014
|
+
var region = self.displayedRegions[_i];
|
|
1015
|
+
|
|
1016
|
+
if (start.index === _i) {
|
|
1017
|
+
bpToStart += start.offset;
|
|
1018
|
+
break;
|
|
1019
|
+
} else {
|
|
1020
|
+
bpToStart += region.end - region.start;
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
self.scrollTo(Math.round(bpToStart / self.bpPerPx) + self.interRegionPaddingWidth * start.index);
|
|
1025
|
+
},
|
|
1026
|
+
horizontalScroll: function horizontalScroll(distance) {
|
|
1027
|
+
var oldOffsetPx = self.offsetPx; // newOffsetPx is the actual offset after the scroll is clamped
|
|
1028
|
+
|
|
1029
|
+
var newOffsetPx = self.scrollTo(self.offsetPx + distance);
|
|
1030
|
+
return newOffsetPx - oldOffsetPx;
|
|
1031
|
+
},
|
|
1032
|
+
|
|
1033
|
+
/**
|
|
1034
|
+
* scrolls the view to center on the given bp. if that is not in any
|
|
1035
|
+
* of the displayed regions, does nothing
|
|
1036
|
+
* @param bp - basepair at which you want to center the view
|
|
1037
|
+
* @param refName - refName of the displayedRegion you are centering at
|
|
1038
|
+
* @param regionIndex - index of the displayedRegion
|
|
1039
|
+
*/
|
|
1040
|
+
centerAt: function centerAt(bp, refName, regionIndex) {
|
|
1041
|
+
var centerPx = self.bpToPx({
|
|
1042
|
+
refName: refName,
|
|
1043
|
+
coord: bp,
|
|
1044
|
+
regionNumber: regionIndex
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
if (centerPx) {
|
|
1048
|
+
self.scrollTo(Math.round(centerPx.offsetPx - self.width / 2));
|
|
1049
|
+
}
|
|
1050
|
+
},
|
|
1051
|
+
center: function center() {
|
|
1052
|
+
var centerBp = self.totalBp / 2;
|
|
1053
|
+
self.scrollTo(Math.round(centerBp / self.bpPerPx - self.width / 2));
|
|
1054
|
+
},
|
|
1055
|
+
showAllRegions: function showAllRegions() {
|
|
1056
|
+
self.zoomTo(self.maxBpPerPx);
|
|
1057
|
+
this.center();
|
|
1058
|
+
},
|
|
1059
|
+
showAllRegionsInAssembly: function showAllRegionsInAssembly(assemblyName) {
|
|
1060
|
+
var session = (0, _util.getSession)(self);
|
|
1061
|
+
var assemblyManager = session.assemblyManager;
|
|
1062
|
+
|
|
1063
|
+
if (!assemblyName) {
|
|
1064
|
+
var assemblyNames = (0, _toConsumableArray2["default"])(new Set(self.displayedRegions.map(function (region) {
|
|
1065
|
+
return region.assemblyName;
|
|
1066
|
+
})));
|
|
1067
|
+
|
|
1068
|
+
if (assemblyNames.length > 1) {
|
|
1069
|
+
session.notify("Can't perform this with multiple assemblies currently");
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
|
|
1073
|
+
;
|
|
1074
|
+
|
|
1075
|
+
var _assemblyNames = (0, _slicedToArray2["default"])(assemblyNames, 1);
|
|
1076
|
+
|
|
1077
|
+
assemblyName = _assemblyNames[0];
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
var assembly = assemblyManager.get(assemblyName);
|
|
1081
|
+
|
|
1082
|
+
if (assembly) {
|
|
1083
|
+
var regions = assembly.regions;
|
|
1084
|
+
|
|
1085
|
+
if (regions) {
|
|
1086
|
+
this.setDisplayedRegions(regions);
|
|
1087
|
+
self.zoomTo(self.maxBpPerPx);
|
|
1088
|
+
this.center();
|
|
1089
|
+
}
|
|
1090
|
+
}
|
|
1091
|
+
},
|
|
1092
|
+
setDraggingTrackId: function setDraggingTrackId(idx) {
|
|
1093
|
+
self.draggingTrackId = idx;
|
|
1094
|
+
},
|
|
1095
|
+
setScaleFactor: function setScaleFactor(factor) {
|
|
1096
|
+
self.scaleFactor = factor;
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
}).actions(function (self) {
|
|
1100
|
+
var cancelLastAnimation = function cancelLastAnimation() {};
|
|
1101
|
+
|
|
1102
|
+
function slide(viewWidths) {
|
|
1103
|
+
var _springAnimate = (0, _util.springAnimate)(self.offsetPx, self.offsetPx + self.width * viewWidths, self.scrollTo),
|
|
1104
|
+
_springAnimate2 = (0, _slicedToArray2["default"])(_springAnimate, 2),
|
|
1105
|
+
animate = _springAnimate2[0],
|
|
1106
|
+
cancelAnimation = _springAnimate2[1];
|
|
1107
|
+
|
|
1108
|
+
cancelLastAnimation();
|
|
1109
|
+
cancelLastAnimation = cancelAnimation;
|
|
1110
|
+
animate();
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1113
|
+
return {
|
|
1114
|
+
slide: slide
|
|
1115
|
+
};
|
|
1116
|
+
}).actions(function (self) {
|
|
1117
|
+
var cancelLastAnimation = function cancelLastAnimation() {};
|
|
1118
|
+
|
|
1119
|
+
function zoom(targetBpPerPx) {
|
|
1120
|
+
self.zoomTo(self.bpPerPx);
|
|
1121
|
+
|
|
1122
|
+
if ( // already zoomed all the way in
|
|
1123
|
+
targetBpPerPx < self.bpPerPx && self.bpPerPx === self.minBpPerPx || // already zoomed all the way out
|
|
1124
|
+
targetBpPerPx > self.bpPerPx && self.bpPerPx === self.maxBpPerPx) {
|
|
1125
|
+
return;
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
var factor = self.bpPerPx / targetBpPerPx;
|
|
1129
|
+
|
|
1130
|
+
var _springAnimate3 = (0, _util.springAnimate)(1, factor, self.setScaleFactor, function () {
|
|
1131
|
+
self.zoomTo(targetBpPerPx);
|
|
1132
|
+
self.setScaleFactor(1);
|
|
1133
|
+
}),
|
|
1134
|
+
_springAnimate4 = (0, _slicedToArray2["default"])(_springAnimate3, 2),
|
|
1135
|
+
animate = _springAnimate4[0],
|
|
1136
|
+
cancelAnimation = _springAnimate4[1];
|
|
1137
|
+
|
|
1138
|
+
cancelLastAnimation();
|
|
1139
|
+
cancelLastAnimation = cancelAnimation;
|
|
1140
|
+
animate();
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
return {
|
|
1144
|
+
zoom: zoom
|
|
1145
|
+
};
|
|
1146
|
+
}).views(function (self) {
|
|
1147
|
+
return {
|
|
1148
|
+
get canShowCytobands() {
|
|
1149
|
+
return self.displayedRegions.length === 1 && this.anyCytobandsExist;
|
|
1150
|
+
},
|
|
1151
|
+
|
|
1152
|
+
get showCytobands() {
|
|
1153
|
+
return this.canShowCytobands && self.showCytobandsSetting;
|
|
1154
|
+
},
|
|
1155
|
+
|
|
1156
|
+
get anyCytobandsExist() {
|
|
1157
|
+
var _getSession4 = (0, _util.getSession)(self),
|
|
1158
|
+
assemblyManager = _getSession4.assemblyManager;
|
|
1159
|
+
|
|
1160
|
+
var assemblyNames = self.assemblyNames;
|
|
1161
|
+
return assemblyNames.some(function (asm) {
|
|
1162
|
+
var _assemblyManager$get3, _assemblyManager$get4;
|
|
1163
|
+
|
|
1164
|
+
return (_assemblyManager$get3 = assemblyManager.get(asm)) === null || _assemblyManager$get3 === void 0 ? void 0 : (_assemblyManager$get4 = _assemblyManager$get3.cytobands) === null || _assemblyManager$get4 === void 0 ? void 0 : _assemblyManager$get4.length;
|
|
1165
|
+
});
|
|
1166
|
+
},
|
|
1167
|
+
|
|
1168
|
+
get cytobandOffset() {
|
|
1169
|
+
return this.showCytobands ? (0, _util.measureText)(self.displayedRegions[0].refName, 12) + 15 : 0;
|
|
1170
|
+
}
|
|
1171
|
+
|
|
1172
|
+
};
|
|
1173
|
+
}).views(function (self) {
|
|
1174
|
+
return {
|
|
1175
|
+
menuItems: function menuItems() {
|
|
1176
|
+
var canShowCytobands = self.canShowCytobands,
|
|
1177
|
+
showCytobands = self.showCytobands;
|
|
1178
|
+
var menuItems = [{
|
|
1179
|
+
label: 'Return to import form',
|
|
1180
|
+
onClick: function onClick() {
|
|
1181
|
+
(0, _util.getSession)(self).queueDialog(function (handleClose) {
|
|
1182
|
+
return [_ui.ReturnToImportFormDialog, {
|
|
1183
|
+
model: self,
|
|
1184
|
+
handleClose: handleClose
|
|
1185
|
+
}];
|
|
1186
|
+
});
|
|
1187
|
+
},
|
|
1188
|
+
icon: _FolderOpen["default"]
|
|
1189
|
+
}, {
|
|
1190
|
+
label: 'Export SVG',
|
|
1191
|
+
icon: _PhotoCamera["default"],
|
|
1192
|
+
onClick: function onClick() {
|
|
1193
|
+
(0, _util.getSession)(self).queueDialog(function (handleClose) {
|
|
1194
|
+
return [_ExportSvgDialog["default"], {
|
|
1195
|
+
model: self,
|
|
1196
|
+
handleClose: handleClose
|
|
1197
|
+
}];
|
|
1198
|
+
});
|
|
1199
|
+
}
|
|
1200
|
+
}, {
|
|
1201
|
+
label: 'Open track selector',
|
|
1202
|
+
onClick: self.activateTrackSelector,
|
|
1203
|
+
icon: _Icons.TrackSelector
|
|
1204
|
+
}, {
|
|
1205
|
+
label: 'Horizontally flip',
|
|
1206
|
+
icon: _SyncAlt["default"],
|
|
1207
|
+
onClick: self.horizontallyFlip
|
|
1208
|
+
}, {
|
|
1209
|
+
type: 'divider'
|
|
1210
|
+
}, {
|
|
1211
|
+
label: 'Show all regions in assembly',
|
|
1212
|
+
icon: _Visibility["default"],
|
|
1213
|
+
onClick: self.showAllRegionsInAssembly
|
|
1214
|
+
}, {
|
|
1215
|
+
label: 'Show center line',
|
|
1216
|
+
icon: _Visibility["default"],
|
|
1217
|
+
type: 'checkbox',
|
|
1218
|
+
checked: self.showCenterLine,
|
|
1219
|
+
onClick: self.toggleCenterLine
|
|
1220
|
+
}, {
|
|
1221
|
+
label: 'Show header',
|
|
1222
|
+
icon: _Visibility["default"],
|
|
1223
|
+
type: 'checkbox',
|
|
1224
|
+
checked: !self.hideHeader,
|
|
1225
|
+
onClick: self.toggleHeader
|
|
1226
|
+
}, {
|
|
1227
|
+
label: 'Show header overview',
|
|
1228
|
+
icon: _Visibility["default"],
|
|
1229
|
+
type: 'checkbox',
|
|
1230
|
+
checked: !self.hideHeaderOverview,
|
|
1231
|
+
onClick: self.toggleHeaderOverview,
|
|
1232
|
+
disabled: self.hideHeader
|
|
1233
|
+
}, {
|
|
1234
|
+
label: 'Track labels',
|
|
1235
|
+
icon: _Label["default"],
|
|
1236
|
+
subMenu: [{
|
|
1237
|
+
label: 'Overlapping',
|
|
1238
|
+
icon: _Visibility["default"],
|
|
1239
|
+
type: 'radio',
|
|
1240
|
+
checked: self.trackLabels === 'overlapping',
|
|
1241
|
+
onClick: function onClick() {
|
|
1242
|
+
return self.setTrackLabels('overlapping');
|
|
1243
|
+
}
|
|
1244
|
+
}, {
|
|
1245
|
+
label: 'Offset',
|
|
1246
|
+
icon: _Visibility["default"],
|
|
1247
|
+
type: 'radio',
|
|
1248
|
+
checked: self.trackLabels === 'offset',
|
|
1249
|
+
onClick: function onClick() {
|
|
1250
|
+
return self.setTrackLabels('offset');
|
|
1251
|
+
}
|
|
1252
|
+
}, {
|
|
1253
|
+
label: 'Hidden',
|
|
1254
|
+
icon: _Visibility["default"],
|
|
1255
|
+
type: 'radio',
|
|
1256
|
+
checked: self.trackLabels === 'hidden',
|
|
1257
|
+
onClick: function onClick() {
|
|
1258
|
+
return self.setTrackLabels('hidden');
|
|
1259
|
+
}
|
|
1260
|
+
}]
|
|
1261
|
+
}].concat((0, _toConsumableArray2["default"])(canShowCytobands ? [{
|
|
1262
|
+
label: showCytobands ? 'Hide ideogram' : 'Show ideograms',
|
|
1263
|
+
onClick: function onClick() {
|
|
1264
|
+
self.setShowCytobands(!showCytobands);
|
|
1265
|
+
}
|
|
1266
|
+
}] : [])); // add track's view level menu options
|
|
1267
|
+
|
|
1268
|
+
var _iterator = _createForOfIteratorHelper(self.trackTypeActions.entries()),
|
|
1269
|
+
_step;
|
|
1270
|
+
|
|
1271
|
+
try {
|
|
1272
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
1273
|
+
var _step$value = (0, _slicedToArray2["default"])(_step.value, 2),
|
|
1274
|
+
_key2 = _step$value[0],
|
|
1275
|
+
value = _step$value[1];
|
|
1276
|
+
|
|
1277
|
+
if (value.length) {
|
|
1278
|
+
menuItems.push({
|
|
1279
|
+
type: 'divider'
|
|
1280
|
+
}, {
|
|
1281
|
+
type: 'subHeader',
|
|
1282
|
+
label: _key2
|
|
1283
|
+
});
|
|
1284
|
+
value.forEach(function (action) {
|
|
1285
|
+
menuItems.push(action);
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
} catch (err) {
|
|
1290
|
+
_iterator.e(err);
|
|
1291
|
+
} finally {
|
|
1292
|
+
_iterator.f();
|
|
1293
|
+
}
|
|
1294
|
+
|
|
1295
|
+
return menuItems;
|
|
1296
|
+
}
|
|
1297
|
+
};
|
|
1298
|
+
}).views(function (self) {
|
|
1299
|
+
var currentlyCalculatedStaticBlocks;
|
|
1300
|
+
var stringifiedCurrentlyCalculatedStaticBlocks = '';
|
|
1301
|
+
return {
|
|
1302
|
+
get staticBlocks() {
|
|
1303
|
+
var ret = (0, _calculateStaticBlocks["default"])(self);
|
|
1304
|
+
var sret = JSON.stringify(ret);
|
|
1305
|
+
|
|
1306
|
+
if (stringifiedCurrentlyCalculatedStaticBlocks !== sret) {
|
|
1307
|
+
currentlyCalculatedStaticBlocks = ret;
|
|
1308
|
+
stringifiedCurrentlyCalculatedStaticBlocks = sret;
|
|
1309
|
+
}
|
|
1310
|
+
|
|
1311
|
+
return currentlyCalculatedStaticBlocks;
|
|
1312
|
+
},
|
|
1313
|
+
|
|
1314
|
+
get dynamicBlocks() {
|
|
1315
|
+
return (0, _calculateDynamicBlocks["default"])(self);
|
|
1316
|
+
},
|
|
1317
|
+
|
|
1318
|
+
get roundedDynamicBlocks() {
|
|
1319
|
+
return this.dynamicBlocks.contentBlocks.map(function (block) {
|
|
1320
|
+
return _objectSpread(_objectSpread({}, block), {}, {
|
|
1321
|
+
start: Math.floor(block.start),
|
|
1322
|
+
end: Math.ceil(block.end)
|
|
1323
|
+
});
|
|
1324
|
+
});
|
|
1325
|
+
},
|
|
1326
|
+
|
|
1327
|
+
get visibleLocStrings() {
|
|
1328
|
+
return calculateVisibleLocStrings(this.dynamicBlocks.contentBlocks);
|
|
1329
|
+
},
|
|
1330
|
+
|
|
1331
|
+
get coarseVisibleLocStrings() {
|
|
1332
|
+
return calculateVisibleLocStrings(self.coarseDynamicBlocks);
|
|
1333
|
+
}
|
|
1334
|
+
|
|
1335
|
+
};
|
|
1336
|
+
}).actions(function (self) {
|
|
1337
|
+
return {
|
|
1338
|
+
// this "clears the view" and makes the view return to the import form
|
|
1339
|
+
clearView: function clearView() {
|
|
1340
|
+
self.setDisplayedRegions([]);
|
|
1341
|
+
self.tracks.clear(); // it is necessary to run these after setting displayed regions empty
|
|
1342
|
+
// or else model.offsetPx gets set to Infinity and breaks
|
|
1343
|
+
// mobx-state-tree snapshot
|
|
1344
|
+
|
|
1345
|
+
self.scrollTo(0);
|
|
1346
|
+
self.zoomTo(10);
|
|
1347
|
+
},
|
|
1348
|
+
setCoarseDynamicBlocks: function setCoarseDynamicBlocks(blocks) {
|
|
1349
|
+
self.coarseDynamicBlocks = blocks.contentBlocks;
|
|
1350
|
+
self.coarseTotalBp = blocks.totalBp;
|
|
1351
|
+
},
|
|
1352
|
+
afterAttach: function afterAttach() {
|
|
1353
|
+
var _this3 = this;
|
|
1354
|
+
|
|
1355
|
+
(0, _mobxStateTree.addDisposer)(self, (0, _mobx.autorun)(function () {
|
|
1356
|
+
if (self.initialized) {
|
|
1357
|
+
_this3.setCoarseDynamicBlocks(self.dynamicBlocks);
|
|
1358
|
+
}
|
|
1359
|
+
}, {
|
|
1360
|
+
delay: 150
|
|
1361
|
+
}));
|
|
1362
|
+
}
|
|
1363
|
+
};
|
|
1364
|
+
}).actions(function (self) {
|
|
1365
|
+
return {
|
|
1366
|
+
exportSvg: function exportSvg() {
|
|
1367
|
+
var _arguments = arguments;
|
|
1368
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
|
1369
|
+
var opts, html, blob;
|
|
1370
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
|
1371
|
+
while (1) {
|
|
1372
|
+
switch (_context.prev = _context.next) {
|
|
1373
|
+
case 0:
|
|
1374
|
+
opts = _arguments.length > 0 && _arguments[0] !== undefined ? _arguments[0] : {};
|
|
1375
|
+
_context.next = 3;
|
|
1376
|
+
return (0, _LinearGenomeViewSvg.renderToSvg)(self, opts);
|
|
1377
|
+
|
|
1378
|
+
case 3:
|
|
1379
|
+
html = _context.sent;
|
|
1380
|
+
blob = new Blob([html], {
|
|
1381
|
+
type: 'image/svg+xml'
|
|
1382
|
+
});
|
|
1383
|
+
(0, _fileSaver.saveAs)(blob, 'image.svg');
|
|
1384
|
+
|
|
1385
|
+
case 6:
|
|
1386
|
+
case "end":
|
|
1387
|
+
return _context.stop();
|
|
1388
|
+
}
|
|
1389
|
+
}
|
|
1390
|
+
}, _callee);
|
|
1391
|
+
}))();
|
|
1392
|
+
}
|
|
1393
|
+
};
|
|
1394
|
+
}).views(function (self) {
|
|
1395
|
+
return {
|
|
1396
|
+
rubberBandMenuItems: function rubberBandMenuItems() {
|
|
1397
|
+
return [{
|
|
1398
|
+
label: 'Zoom to region',
|
|
1399
|
+
icon: _ZoomIn["default"],
|
|
1400
|
+
onClick: function onClick() {
|
|
1401
|
+
var leftOffset = self.leftOffset,
|
|
1402
|
+
rightOffset = self.rightOffset;
|
|
1403
|
+
|
|
1404
|
+
if (leftOffset && rightOffset) {
|
|
1405
|
+
self.moveTo(leftOffset, rightOffset);
|
|
1406
|
+
}
|
|
1407
|
+
}
|
|
1408
|
+
}, {
|
|
1409
|
+
label: 'Get sequence',
|
|
1410
|
+
icon: _MenuOpen["default"],
|
|
1411
|
+
onClick: function onClick() {
|
|
1412
|
+
self.setSequenceDialogOpen(true);
|
|
1413
|
+
}
|
|
1414
|
+
}];
|
|
1415
|
+
}
|
|
1416
|
+
};
|
|
1417
|
+
});
|
|
1418
|
+
}
|