@jbrowse/core 2.3.2 → 2.3.3
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/PluginManager.js +1 -1
- package/data_adapters/BaseAdapter.d.ts +1 -0
- package/data_adapters/BaseAdapter.js +9 -9
- package/package.json +4 -3
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +3 -3
- package/pluggableElementTypes/renderers/FeatureRendererType.js +3 -1
- package/rpc/methods/CoreGetFeatures.js +3 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/FatalErrorDialog.js +0 -1
- package/util/Base1DUtils.d.ts +6 -0
- package/util/Base1DUtils.js +57 -24
- package/util/Base1DViewModel.d.ts +3 -1
- package/util/index.d.ts +4 -0
- package/util/index.js +31 -3
- package/util/stats.js +3 -4
package/ui/FatalErrorDialog.js
CHANGED
|
@@ -36,7 +36,6 @@ const ResetComponent = ({ onFactoryReset, resetButtonText, }) => {
|
|
|
36
36
|
react_1.default.createElement(FactoryResetDialog_1.default, { onClose: () => setDialogOpen(false), open: dialogOpen, onFactoryReset: onFactoryReset })));
|
|
37
37
|
};
|
|
38
38
|
const FatalErrorDialog = ({ componentStack, error = 'No error message provided', onFactoryReset, resetButtonText = 'Factory Reset', }) => {
|
|
39
|
-
console.error(error);
|
|
40
39
|
return (react_1.default.createElement(material_1.Dialog, { open: true },
|
|
41
40
|
react_1.default.createElement(material_1.DialogTitle, { style: { background: '#e88' } }, "Fatal error"),
|
|
42
41
|
react_1.default.createElement(material_1.DialogContent, null,
|
package/util/Base1DUtils.d.ts
CHANGED
|
@@ -30,3 +30,9 @@ export declare function bpToPx({ refName, coord, regionNumber, self, }: {
|
|
|
30
30
|
index: number;
|
|
31
31
|
offsetPx: number;
|
|
32
32
|
} | undefined;
|
|
33
|
+
export declare function bpToPxMap({ refName, coord, regionNumber, self, }: {
|
|
34
|
+
refName: string;
|
|
35
|
+
coord: number;
|
|
36
|
+
regionNumber?: number;
|
|
37
|
+
self: ViewSnap;
|
|
38
|
+
}): {};
|
package/util/Base1DUtils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bpToPx = exports.pxToBp = exports.moveTo = void 0;
|
|
3
|
+
exports.bpToPxMap = exports.bpToPx = exports.pxToBp = exports.moveTo = void 0;
|
|
4
4
|
const mobx_state_tree_1 = require("mobx-state-tree");
|
|
5
5
|
function lengthBetween(self, start, end) {
|
|
6
6
|
let bpSoFar = 0;
|
|
@@ -57,6 +57,9 @@ function moveTo(self, start, end) {
|
|
|
57
57
|
self.scrollTo(Math.round(bpToStart / self.bpPerPx));
|
|
58
58
|
}
|
|
59
59
|
exports.moveTo = moveTo;
|
|
60
|
+
function coord(r, bp) {
|
|
61
|
+
return Math.floor(r.reversed ? r.end - bp : r.start + bp) + 1;
|
|
62
|
+
}
|
|
60
63
|
// manual return type since getSnapshot hard to infer here
|
|
61
64
|
function pxToBp(self, px) {
|
|
62
65
|
var _a;
|
|
@@ -65,16 +68,14 @@ function pxToBp(self, px) {
|
|
|
65
68
|
const blocks = staticBlocks.contentBlocks;
|
|
66
69
|
const bp = (offsetPx + px) * bpPerPx;
|
|
67
70
|
if (bp < 0) {
|
|
68
|
-
const
|
|
69
|
-
const snap = (0, mobx_state_tree_1.getSnapshot)(
|
|
71
|
+
const r = displayedRegions[0];
|
|
72
|
+
const snap = (0, mobx_state_tree_1.getSnapshot)(r);
|
|
70
73
|
// @ts-ignore
|
|
71
74
|
return {
|
|
72
75
|
// xref https://github.com/mobxjs/mobx-state-tree/issues/1524 for Omit
|
|
73
76
|
...snap,
|
|
74
77
|
oob: true,
|
|
75
|
-
coord:
|
|
76
|
-
? Math.floor(region.end - bp) + 1
|
|
77
|
-
: Math.floor(region.start + bp) + 1,
|
|
78
|
+
coord: coord(r, bp),
|
|
78
79
|
offset: bp,
|
|
79
80
|
index: 0,
|
|
80
81
|
};
|
|
@@ -82,20 +83,18 @@ function pxToBp(self, px) {
|
|
|
82
83
|
const interRegionPaddingBp = interRegionPaddingWidth * bpPerPx;
|
|
83
84
|
let currBlock = 0;
|
|
84
85
|
for (let i = 0; i < displayedRegions.length; i++) {
|
|
85
|
-
const
|
|
86
|
-
const len =
|
|
86
|
+
const r = displayedRegions[i];
|
|
87
|
+
const len = r.end - r.start;
|
|
87
88
|
const offset = bp - bpSoFar;
|
|
88
89
|
if (len + bpSoFar > bp && bpSoFar <= bp) {
|
|
89
|
-
const snap = (0, mobx_state_tree_1.getSnapshot)(
|
|
90
|
+
const snap = (0, mobx_state_tree_1.getSnapshot)(r);
|
|
90
91
|
// @ts-ignore
|
|
91
92
|
return {
|
|
92
93
|
// xref https://github.com/mobxjs/mobx-state-tree/issues/1524 for Omit
|
|
93
94
|
...snap,
|
|
94
95
|
oob: false,
|
|
95
96
|
offset,
|
|
96
|
-
coord:
|
|
97
|
-
? Math.floor(region.end - offset) + 1
|
|
98
|
-
: Math.floor(region.start + offset) + 1,
|
|
97
|
+
coord: coord(r, offset),
|
|
99
98
|
index: i,
|
|
100
99
|
};
|
|
101
100
|
}
|
|
@@ -110,19 +109,17 @@ function pxToBp(self, px) {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
if (bp >= bpSoFar && displayedRegions.length) {
|
|
113
|
-
const
|
|
114
|
-
const len =
|
|
112
|
+
const r = displayedRegions[displayedRegions.length - 1];
|
|
113
|
+
const len = r.end - r.start;
|
|
115
114
|
const offset = bp - bpSoFar + len;
|
|
116
|
-
const snap = (0, mobx_state_tree_1.getSnapshot)(
|
|
115
|
+
const snap = (0, mobx_state_tree_1.getSnapshot)(r);
|
|
117
116
|
// @ts-ignore
|
|
118
117
|
return {
|
|
119
118
|
// xref https://github.com/mobxjs/mobx-state-tree/issues/1524 for Omit
|
|
120
119
|
...snap,
|
|
121
120
|
oob: true,
|
|
122
121
|
offset,
|
|
123
|
-
coord:
|
|
124
|
-
? Math.floor(region.end - offset) + 1
|
|
125
|
-
: Math.floor(region.start + offset) + 1,
|
|
122
|
+
coord: coord(r, offset),
|
|
126
123
|
index: displayedRegions.length - 1,
|
|
127
124
|
};
|
|
128
125
|
}
|
|
@@ -148,13 +145,11 @@ function bpToPx({ refName, coord, regionNumber, self, }) {
|
|
|
148
145
|
let currBlock = 0;
|
|
149
146
|
let i = 0;
|
|
150
147
|
for (; i < displayedRegions.length; i++) {
|
|
151
|
-
const
|
|
152
|
-
const len =
|
|
153
|
-
if (refName ===
|
|
154
|
-
coord >= region.start &&
|
|
155
|
-
coord <= region.end) {
|
|
148
|
+
const r = displayedRegions[i];
|
|
149
|
+
const len = r.end - r.start;
|
|
150
|
+
if (refName === r.refName && coord >= r.start && coord <= r.end) {
|
|
156
151
|
if (regionNumber ? regionNumber === i : true) {
|
|
157
|
-
bpSoFar +=
|
|
152
|
+
bpSoFar += r.reversed ? r.end - coord : coord - r.start;
|
|
158
153
|
break;
|
|
159
154
|
}
|
|
160
155
|
}
|
|
@@ -178,3 +173,41 @@ function bpToPx({ refName, coord, regionNumber, self, }) {
|
|
|
178
173
|
return undefined;
|
|
179
174
|
}
|
|
180
175
|
exports.bpToPx = bpToPx;
|
|
176
|
+
function bpToPxMap({ refName, coord, regionNumber, self, }) {
|
|
177
|
+
var _a;
|
|
178
|
+
let bpSoFar = 0;
|
|
179
|
+
const { interRegionPaddingWidth, bpPerPx, displayedRegions, staticBlocks } = self;
|
|
180
|
+
const blocks = staticBlocks.contentBlocks;
|
|
181
|
+
const interRegionPaddingBp = interRegionPaddingWidth * bpPerPx;
|
|
182
|
+
const map = {};
|
|
183
|
+
let currBlock = 0;
|
|
184
|
+
let i = 0;
|
|
185
|
+
for (; i < displayedRegions.length; i++) {
|
|
186
|
+
const r = displayedRegions[i];
|
|
187
|
+
const len = r.end - r.start;
|
|
188
|
+
if (refName === r.refName && coord >= r.start && coord <= r.end) {
|
|
189
|
+
if (regionNumber !== undefined ? regionNumber === i : true) {
|
|
190
|
+
bpSoFar += r.reversed ? r.end - coord : coord - r.start;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
// add the interRegionPaddingWidth if the boundary is in the screen e.g. in
|
|
195
|
+
// a static block
|
|
196
|
+
if (((_a = blocks[currBlock]) === null || _a === void 0 ? void 0 : _a.regionNumber) === i) {
|
|
197
|
+
bpSoFar += len + interRegionPaddingBp;
|
|
198
|
+
currBlock++;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
bpSoFar += len;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
const found = displayedRegions[i];
|
|
205
|
+
if (found) {
|
|
206
|
+
return {
|
|
207
|
+
index: i,
|
|
208
|
+
offsetPx: Math.round(bpSoFar / bpPerPx),
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
return map;
|
|
212
|
+
}
|
|
213
|
+
exports.bpToPxMap = bpToPxMap;
|
package/util/index.d.ts
CHANGED
|
@@ -342,3 +342,7 @@ export declare function getEnv(obj: any): {
|
|
|
342
342
|
pluginManager: PluginManager;
|
|
343
343
|
};
|
|
344
344
|
export declare function localStorageGetItem(item: string): string | null | undefined;
|
|
345
|
+
export declare function max(arr: number[]): number;
|
|
346
|
+
export declare function min(arr: number[]): number;
|
|
347
|
+
export declare function sum(arr: number[]): number;
|
|
348
|
+
export declare function avg(arr: number[]): number;
|
package/util/index.js
CHANGED
|
@@ -30,7 +30,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
30
30
|
};
|
|
31
31
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
32
|
exports.bytesForRegions = exports.objectHash = exports.hashCode = exports.updateStatus = exports.generateCodonTable = exports.defaultCodonTable = exports.defaultStops = exports.defaultStarts = exports.measureText = exports.rIC = exports.blobToDataURL = exports.complement = exports.reverse = exports.revcom = exports.isElectron = exports.stringify = exports.shorten = exports.minmax = exports.renameRegionsIfNeeded = exports.renameRegionIfNeeded = exports.makeAbortableReaction = exports.findLastIndex = exports.iterMap = exports.bpSpanPx = exports.featureSpanPx = exports.cartesianToPolar = exports.polarToCartesian = exports.degToRad = exports.radToDeg = exports.bpToPx = exports.clamp = exports.compareLocStrings = exports.compareLocs = exports.parseLocString = exports.parseLocStringOneBased = exports.assembleLocStringFast = exports.assembleLocString = exports.getContainingDisplay = exports.getContainingTrack = exports.getContainingView = exports.getSession = exports.findParentThatIs = exports.springAnimate = exports.findParentThat = exports.useDebouncedCallback = exports.useDebounce = exports.inProduction = exports.inDevelopment = exports.isFeature = exports.SimpleFeature = void 0;
|
|
33
|
-
exports.localStorageGetItem = exports.getEnv = exports.measureGridWidth = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr = exports.supportedIndexingAdapters = void 0;
|
|
33
|
+
exports.avg = exports.sum = exports.min = exports.max = exports.localStorageGetItem = exports.getEnv = exports.measureGridWidth = exports.getStr = exports.getUriLink = exports.useLocalStorage = exports.getLayoutId = exports.getViewParams = exports.getTickDisplayStr = exports.toLocale = exports.getBpDisplayStr = exports.supportedIndexingAdapters = void 0;
|
|
34
34
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
35
35
|
const react_1 = require("react");
|
|
36
36
|
const is_object_1 = __importDefault(require("is-object"));
|
|
@@ -66,7 +66,7 @@ function useDebounce(value, delay) {
|
|
|
66
66
|
return debouncedValue;
|
|
67
67
|
}
|
|
68
68
|
exports.useDebounce = useDebounce;
|
|
69
|
-
// https://stackoverflow.com/questions/56283920/
|
|
69
|
+
// https://stackoverflow.com/questions/56283920/
|
|
70
70
|
function useDebouncedCallback(callback, wait = 400) {
|
|
71
71
|
// track args & timeout handle between calls
|
|
72
72
|
const argsRef = (0, react_1.useRef)();
|
|
@@ -1004,7 +1004,7 @@ function getStr(obj) {
|
|
|
1004
1004
|
exports.getStr = getStr;
|
|
1005
1005
|
// heuristic measurement for a column of a @mui/x-data-grid, pass in values from a column
|
|
1006
1006
|
function measureGridWidth(elements) {
|
|
1007
|
-
return
|
|
1007
|
+
return max(elements.map(element => Math.min(Math.max(measureText(getStr(element), 14) + 50, 80), 1000)));
|
|
1008
1008
|
}
|
|
1009
1009
|
exports.measureGridWidth = measureGridWidth;
|
|
1010
1010
|
function getEnv(obj) {
|
|
@@ -1017,3 +1017,31 @@ function localStorageGetItem(item) {
|
|
|
1017
1017
|
: undefined;
|
|
1018
1018
|
}
|
|
1019
1019
|
exports.localStorageGetItem = localStorageGetItem;
|
|
1020
|
+
function max(arr) {
|
|
1021
|
+
let max = -Infinity;
|
|
1022
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1023
|
+
max = arr[i] > max ? arr[i] : max;
|
|
1024
|
+
}
|
|
1025
|
+
return max;
|
|
1026
|
+
}
|
|
1027
|
+
exports.max = max;
|
|
1028
|
+
function min(arr) {
|
|
1029
|
+
let min = Infinity;
|
|
1030
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1031
|
+
min = arr[i] < min ? arr[i] : min;
|
|
1032
|
+
}
|
|
1033
|
+
return min;
|
|
1034
|
+
}
|
|
1035
|
+
exports.min = min;
|
|
1036
|
+
function sum(arr) {
|
|
1037
|
+
let sum = 0;
|
|
1038
|
+
for (let i = 0; i < arr.length; i++) {
|
|
1039
|
+
sum += arr[i];
|
|
1040
|
+
}
|
|
1041
|
+
return sum;
|
|
1042
|
+
}
|
|
1043
|
+
exports.sum = sum;
|
|
1044
|
+
function avg(arr) {
|
|
1045
|
+
return sum(arr) / arr.length;
|
|
1046
|
+
}
|
|
1047
|
+
exports.avg = avg;
|
package/util/stats.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blankStats = exports.scoresToStats = exports.calcPerBaseStats = exports.rectifyStats = exports.calcStdFromSums = void 0;
|
|
4
|
+
const rxjs_1 = require("rxjs");
|
|
4
5
|
const operators_1 = require("rxjs/operators");
|
|
5
6
|
/**
|
|
6
7
|
* calculate standard deviation using the 'shortcut method' that accepts
|
|
@@ -96,8 +97,7 @@ async function scoresToStats(region, feats) {
|
|
|
96
97
|
featureCount: 0,
|
|
97
98
|
};
|
|
98
99
|
let found = false;
|
|
99
|
-
const { scoreMin, scoreMax, scoreSum, scoreSumSquares, featureCount } = await feats
|
|
100
|
-
.pipe((0, operators_1.reduce)((acc, f) => {
|
|
100
|
+
const { scoreMin, scoreMax, scoreSum, scoreSumSquares, featureCount } = await (0, rxjs_1.firstValueFrom)(feats.pipe((0, operators_1.reduce)((acc, f) => {
|
|
101
101
|
const s = f.get('score');
|
|
102
102
|
const summary = f.get('summary');
|
|
103
103
|
const { scoreMax, scoreMin } = acc;
|
|
@@ -108,8 +108,7 @@ async function scoresToStats(region, feats) {
|
|
|
108
108
|
acc.featureCount += 1;
|
|
109
109
|
found = true;
|
|
110
110
|
return acc;
|
|
111
|
-
}, seed))
|
|
112
|
-
.toPromise();
|
|
111
|
+
}, seed)));
|
|
113
112
|
return found
|
|
114
113
|
? rectifyStats({
|
|
115
114
|
scoreMax,
|