@jbrowse/core 1.7.11 → 2.1.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/BaseFeatureWidget/BaseFeatureDetail.d.ts +20 -4
- package/BaseFeatureWidget/BaseFeatureDetail.js +313 -558
- package/BaseFeatureWidget/SequenceFeatureDetails.js +213 -473
- package/BaseFeatureWidget/index.d.ts +2 -2
- package/BaseFeatureWidget/index.js +88 -124
- package/BaseFeatureWidget/types.d.ts +1 -0
- package/BaseFeatureWidget/types.js +1 -4
- package/BaseFeatureWidget/util.js +40 -75
- package/CorePlugin.js +55 -94
- package/Plugin.js +9 -34
- package/PluginLoader.js +153 -422
- package/PluginManager.d.ts +84 -117
- package/PluginManager.js +377 -666
- package/ReExports/Attributes.d.ts +2 -0
- package/ReExports/Attributes.js +5 -0
- package/ReExports/BaseCard.d.ts +2 -0
- package/ReExports/BaseCard.js +5 -0
- package/ReExports/DataGrid.d.ts +2 -0
- package/ReExports/DataGrid.js +6 -0
- package/ReExports/FeatureDetails.d.ts +2 -0
- package/ReExports/FeatureDetails.js +5 -0
- package/ReExports/index.js +6 -12
- package/ReExports/list.d.ts +5 -0
- package/ReExports/list.js +271 -7
- package/ReExports/material-ui-colors.d.ts +1 -19
- package/ReExports/material-ui-colors.js +16 -158
- package/ReExports/modules.d.ts +68 -109
- package/ReExports/modules.js +455 -244
- package/TextSearch/BaseResults.js +51 -123
- package/TextSearch/TextSearchManager.d.ts +3 -1
- package/TextSearch/TextSearchManager.js +66 -144
- package/assemblyManager/assembly.js +280 -554
- package/assemblyManager/assemblyConfigSchema.js +47 -64
- package/assemblyManager/assemblyManager.d.ts +12 -10
- package/assemblyManager/assemblyManager.js +126 -270
- package/assemblyManager/index.js +9 -22
- package/configuration/configurationSchema.js +167 -203
- package/configuration/configurationSlot.js +248 -326
- package/configuration/index.js +19 -35
- package/configuration/util.d.ts +1 -1
- package/configuration/util.js +131 -173
- package/data_adapters/BaseAdapter.d.ts +2 -2
- package/data_adapters/BaseAdapter.js +132 -521
- package/data_adapters/CytobandAdapter.js +40 -126
- package/data_adapters/dataAdapterCache.js +77 -158
- package/package.json +16 -18
- package/pluggableElementTypes/AdapterType.js +24 -79
- package/pluggableElementTypes/AddTrackWorkflowType.d.ts +17 -0
- package/pluggableElementTypes/AddTrackWorkflowType.js +20 -0
- package/pluggableElementTypes/ConnectionType.js +22 -65
- package/pluggableElementTypes/DisplayType.js +35 -82
- package/pluggableElementTypes/InternetAccountType.js +23 -64
- package/pluggableElementTypes/PluggableElementBase.js +8 -20
- package/pluggableElementTypes/RpcMethodType.js +85 -427
- package/pluggableElementTypes/TextSearchAdapterType.js +16 -55
- package/pluggableElementTypes/TrackType.js +26 -70
- package/pluggableElementTypes/ViewType.js +21 -63
- package/pluggableElementTypes/WidgetType.js +21 -64
- package/pluggableElementTypes/index.d.ts +4 -3
- package/pluggableElementTypes/index.js +42 -125
- package/pluggableElementTypes/models/BaseConnectionModelFactory.js +28 -43
- package/pluggableElementTypes/models/BaseDisplayModel.d.ts +10 -10
- package/pluggableElementTypes/models/BaseDisplayModel.js +58 -95
- package/pluggableElementTypes/models/BaseTrackModel.d.ts +1 -1
- package/pluggableElementTypes/models/BaseTrackModel.js +139 -200
- package/pluggableElementTypes/models/BaseViewModel.js +24 -40
- package/pluggableElementTypes/models/InternetAccountModel.js +116 -263
- package/pluggableElementTypes/models/baseConnectionConfig.js +14 -25
- package/pluggableElementTypes/models/baseInternetAccountConfig.js +29 -38
- package/pluggableElementTypes/models/baseTrackConfig.js +106 -133
- package/pluggableElementTypes/models/index.js +21 -70
- package/pluggableElementTypes/renderers/BoxRendererType.js +132 -291
- package/pluggableElementTypes/renderers/CircularChordRendererType.js +8 -38
- package/pluggableElementTypes/renderers/ComparativeServerSideRendererType.js +60 -192
- package/pluggableElementTypes/renderers/FeatureRendererType.d.ts +0 -2
- package/pluggableElementTypes/renderers/FeatureRendererType.js +89 -255
- package/pluggableElementTypes/renderers/RendererType.js +31 -105
- package/pluggableElementTypes/renderers/ServerSideRenderedContent.js +61 -72
- package/pluggableElementTypes/renderers/ServerSideRendererType.d.ts +2 -2
- package/pluggableElementTypes/renderers/ServerSideRendererType.js +112 -265
- package/pluggableElementTypes/renderers/index.js +19 -62
- package/pluggableElementTypes/renderers/util/serializableFilterChain.js +27 -65
- package/rpc/BaseRpcDriver.js +169 -405
- package/rpc/MainThreadRpcDriver.js +27 -150
- package/rpc/RpcManager.js +58 -159
- package/rpc/WebWorkerRpcDriver.js +54 -171
- package/rpc/configSchema.js +25 -49
- package/rpc/coreRpcMethods.d.ts +1 -3
- package/rpc/coreRpcMethods.js +221 -959
- package/rpc/remoteAbortSignals.js +46 -70
- package/tsconfig.build.tsbuildinfo +1 -1
- package/ui/AboutDialog.js +107 -158
- package/ui/App.js +157 -261
- package/ui/AssemblySelector.d.ts +1 -1
- package/ui/AssemblySelector.js +59 -115
- package/ui/CascadingMenu.js +100 -199
- package/ui/ColorPicker.d.ts +16 -0
- package/ui/ColorPicker.js +97 -0
- package/ui/Drawer.js +28 -58
- package/ui/DrawerWidget.js +109 -209
- package/ui/DropDownMenu.d.ts +0 -8
- package/ui/DropDownMenu.js +60 -97
- package/ui/EditableTypography.d.ts +1 -1
- package/ui/EditableTypography.js +87 -155
- package/ui/ErrorMessage.js +41 -66
- package/ui/FactoryResetDialog.js +24 -57
- package/ui/FatalErrorDialog.js +59 -91
- package/ui/FileSelector/FileSelector.js +123 -189
- package/ui/FileSelector/LocalFileChooser.js +44 -71
- package/ui/FileSelector/UrlChooser.js +17 -38
- package/ui/FileSelector/index.js +6 -12
- package/ui/Icons.d.ts +1 -1
- package/ui/Icons.js +45 -69
- package/ui/Logo.js +57 -110
- package/ui/Menu.d.ts +1 -1
- package/ui/Menu.js +232 -355
- package/ui/PrerenderedCanvas.js +63 -78
- package/ui/ResizeHandle.js +87 -114
- package/ui/ReturnToImportFormDialog.js +32 -59
- package/ui/SanitizedHTML.js +63 -52
- package/ui/Snackbar.js +74 -99
- package/ui/SnackbarModel.js +37 -51
- package/ui/Tooltip.d.ts +3 -1
- package/ui/Tooltip.js +49 -74
- package/ui/ViewContainer.js +113 -183
- package/ui/colors.d.ts +10 -0
- package/ui/colors.js +78 -0
- package/ui/index.js +51 -181
- package/ui/react-colorful.d.ts +17 -0
- package/ui/react-colorful.js +455 -0
- package/ui/theme.d.ts +279 -131
- package/ui/theme.js +197 -225
- package/util/Base1DUtils.d.ts +32 -0
- package/util/Base1DUtils.js +174 -0
- package/util/Base1DViewModel.d.ts +16 -37
- package/util/Base1DViewModel.js +116 -295
- package/util/QuickLRU.js +84 -332
- package/util/TimeTraveller.d.ts +19 -0
- package/util/TimeTraveller.js +86 -0
- package/util/aborting.js +49 -127
- package/util/analytics.js +91 -154
- package/util/blockTypes.js +106 -240
- package/util/calculateDynamicBlocks.js +98 -128
- package/util/calculateStaticBlocks.js +105 -125
- package/util/color/cssColorsLevel4.js +156 -160
- package/util/color/index.js +33 -55
- package/util/compositeMap.js +49 -333
- package/util/formatFastaStrings.js +9 -14
- package/util/idMaker.js +18 -31
- package/util/index.d.ts +18 -39
- package/util/index.js +743 -1236
- package/util/io/RemoteFileWithRangeCache.js +88 -257
- package/util/io/index.js +95 -169
- package/util/jexl.js +60 -115
- package/util/jexlStrings.js +24 -29
- package/util/layouts/BaseLayout.js +1 -4
- package/util/layouts/GranularRectLayout.js +388 -557
- package/util/layouts/MultiLayout.js +41 -109
- package/util/layouts/PrecomputedLayout.js +56 -114
- package/util/layouts/PrecomputedMultiLayout.js +22 -59
- package/util/layouts/SceneGraph.js +127 -197
- package/util/layouts/index.js +29 -66
- package/util/mst-reflection.js +55 -71
- package/util/offscreenCanvasPonyfill.js +66 -134
- package/util/offscreenCanvasUtils.d.ts +2 -7
- package/util/offscreenCanvasUtils.js +49 -146
- package/util/range.js +29 -40
- package/util/rxjs.js +20 -27
- package/util/simpleFeature.js +88 -152
- package/util/stats.js +91 -151
- package/util/tracks.js +130 -171
- package/util/types/index.d.ts +3 -3
- package/util/types/index.js +110 -179
- package/util/types/mst.d.ts +3 -3
- package/util/types/mst.js +91 -142
- package/util/types/util.js +1 -4
- package/util/when.js +54 -101
- package/BaseFeatureWidget/SequenceFeatureDetails.test.js +0 -122
- package/BaseFeatureWidget/index.test.js +0 -51
- package/TextSearch/BaseResults.test.js +0 -42
- package/configuration/configurationSchema.test.js +0 -266
- package/configuration/configurationSlot.test.js +0 -69
- package/configuration/util.test.js +0 -39
- package/data_adapters/BaseAdapter.test.js +0 -200
- package/declare.d.js +0 -1
- package/pluggableElementTypes/RpcMethodType.test.js +0 -118
- package/pluggableElementTypes/renderers/declare.d.js +0 -1
- package/pluggableElementTypes/renderers/util/serializableFilterChain.test.js +0 -20
- package/rpc/BaseRpcDriver.test.js +0 -540
- package/rpc/declaration.d.js +0 -1
- package/ui/FatalErrorDialog.test.js +0 -82
- package/ui/SanitizedHTML.test.js +0 -36
- package/ui/theme.test.js +0 -111
- package/util/Base1DViewModel.test.js +0 -130
- package/util/calculateDynamicBlocks.test.js +0 -74
- package/util/calculateStaticBlocks.test.js +0 -297
- package/util/declare.d.js +0 -1
- package/util/formatFastaStrings.test.js +0 -40
- package/util/index.test.js +0 -213
- package/util/jexlStrings.test.js +0 -48
- package/util/layouts/GranularRectLayout.test.js +0 -99
- package/util/range.test.js +0 -64
- package/util/simpleFeature.test.js +0 -34
- package/util/stats.test.js +0 -172
package/util/simpleFeature.js
CHANGED
|
@@ -1,185 +1,121 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
exports.isFeature = isFeature;
|
|
10
|
-
|
|
11
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
12
|
-
|
|
13
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
14
|
-
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
-
|
|
17
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
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; }
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Abstract feature object
|
|
25
|
-
*/
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isFeature = void 0;
|
|
26
4
|
function isFeature(thing) {
|
|
27
|
-
|
|
5
|
+
return (typeof thing === 'object' &&
|
|
6
|
+
thing !== null &&
|
|
7
|
+
typeof thing.get === 'function' &&
|
|
8
|
+
typeof thing.id === 'function');
|
|
28
9
|
}
|
|
29
|
-
|
|
10
|
+
exports.isFeature = isFeature;
|
|
30
11
|
function isSimpleFeatureSerialized(args) {
|
|
31
|
-
|
|
12
|
+
return 'uniqueId' in args && typeof args.data !== 'object';
|
|
32
13
|
}
|
|
33
14
|
/**
|
|
34
15
|
* Simple implementation of a feature object.
|
|
35
16
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (this.data.subfeatures) {
|
|
81
|
-
var _this$data$subfeature;
|
|
82
|
-
|
|
83
|
-
this.subfeatures = (_this$data$subfeature = this.data.subfeatures) === null || _this$data$subfeature === void 0 ? void 0 : _this$data$subfeature.map( // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
84
|
-
function (f, i) {
|
|
85
|
-
return typeof f.get !== 'function' ? new SimpleFeature({
|
|
86
|
-
id: f.uniqueId || "".concat(id, "-").concat(i),
|
|
87
|
-
data: _objectSpread({
|
|
88
|
-
strand: _this.data.strand
|
|
89
|
-
}, f),
|
|
90
|
-
parent: _this
|
|
91
|
-
}) : f;
|
|
92
|
-
});
|
|
17
|
+
class SimpleFeature {
|
|
18
|
+
/**
|
|
19
|
+
* @param args - SimpleFeature args
|
|
20
|
+
*
|
|
21
|
+
* Note: args.data.subfeatures can be an array of these same args,
|
|
22
|
+
* which will be inflated to more instances of this class.
|
|
23
|
+
*/
|
|
24
|
+
constructor(args) {
|
|
25
|
+
var _a;
|
|
26
|
+
if (isSimpleFeatureSerialized(args)) {
|
|
27
|
+
this.data = args;
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
this.data = args.data || {};
|
|
31
|
+
// load handle from args.parent (not args.data.parent)
|
|
32
|
+
// this reason is because if args is an object, it likely isn't properly loaded with
|
|
33
|
+
// parent as a Feature reference (probably a raw parent ID or something instead)
|
|
34
|
+
this.parentHandle = args.parent;
|
|
35
|
+
}
|
|
36
|
+
// the feature id comes from
|
|
37
|
+
// args.id, args.data.uniqueId, or args.uniqueId due to this initialization
|
|
38
|
+
const id = isSimpleFeatureSerialized(args) ? args.uniqueId : args.id;
|
|
39
|
+
if (id === undefined || id === null) {
|
|
40
|
+
throw new Error('SimpleFeature requires a unique `id` or `data.uniqueId` attribute');
|
|
41
|
+
}
|
|
42
|
+
this.uniqueId = String(id);
|
|
43
|
+
if (!(this.data.aliases || this.data.end - this.data.start >= 0)) {
|
|
44
|
+
throw new Error(`invalid feature data, end less than start. end: ${this.data.end} start: ${this.data.start}`);
|
|
45
|
+
}
|
|
46
|
+
if (this.data.subfeatures) {
|
|
47
|
+
this.subfeatures = (_a = this.data.subfeatures) === null || _a === void 0 ? void 0 : _a.map(
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
49
|
+
(f, i) => typeof f.get !== 'function'
|
|
50
|
+
? new SimpleFeature({
|
|
51
|
+
id: f.uniqueId || `${id}-${i}`,
|
|
52
|
+
data: {
|
|
53
|
+
strand: this.data.strand,
|
|
54
|
+
...f,
|
|
55
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
56
|
+
},
|
|
57
|
+
parent: this,
|
|
58
|
+
})
|
|
59
|
+
: f);
|
|
60
|
+
}
|
|
93
61
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return name === 'subfeatures' ? this.subfeatures : name === 'parent' ? this.parent() : this.data[name];
|
|
62
|
+
/**
|
|
63
|
+
* Get a piece of data about the feature. All features must have
|
|
64
|
+
* 'start' and 'end', but everything else is optional.
|
|
65
|
+
*/
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
67
|
+
get(name) {
|
|
68
|
+
return name === 'subfeatures'
|
|
69
|
+
? this.subfeatures
|
|
70
|
+
: name === 'parent'
|
|
71
|
+
? this.parent()
|
|
72
|
+
: this.data[name];
|
|
106
73
|
}
|
|
107
74
|
/**
|
|
108
75
|
* Set an item of data.
|
|
109
76
|
*/
|
|
110
77
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
key: "set",
|
|
114
|
-
value: function set(name, val) {
|
|
115
|
-
this.data[name] = val;
|
|
78
|
+
set(name, val) {
|
|
79
|
+
this.data[name] = val;
|
|
116
80
|
}
|
|
117
81
|
/**
|
|
118
82
|
* Get an array listing which data keys are present in this feature.
|
|
119
83
|
*/
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
key: "tags",
|
|
123
|
-
value: function tags() {
|
|
124
|
-
return Object.keys(this.data);
|
|
84
|
+
tags() {
|
|
85
|
+
return Object.keys(this.data);
|
|
125
86
|
}
|
|
126
87
|
/**
|
|
127
88
|
* Get the unique ID of this feature.
|
|
128
89
|
*/
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
key: "id",
|
|
132
|
-
value: function id() {
|
|
133
|
-
return this.uniqueId;
|
|
90
|
+
id() {
|
|
91
|
+
return this.uniqueId;
|
|
134
92
|
}
|
|
135
93
|
/**
|
|
136
94
|
* Get this feature's parent feature, or undefined if none.
|
|
137
95
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
key: "parent",
|
|
141
|
-
value: function parent() {
|
|
142
|
-
return this.parentHandle;
|
|
96
|
+
parent() {
|
|
97
|
+
return this.parentHandle;
|
|
143
98
|
}
|
|
144
99
|
/**
|
|
145
100
|
* Get an array of child features, or undefined if none.
|
|
146
101
|
*/
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
key: "children",
|
|
150
|
-
value: function children() {
|
|
151
|
-
return this.get('subfeatures');
|
|
102
|
+
children() {
|
|
103
|
+
return this.get('subfeatures');
|
|
152
104
|
}
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
d
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
var c = this.children();
|
|
167
|
-
|
|
168
|
-
if (c) {
|
|
169
|
-
d.subfeatures = c.map(function (child) {
|
|
170
|
-
return child.toJSON();
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return d;
|
|
105
|
+
toJSON() {
|
|
106
|
+
const d = { ...this.data, uniqueId: this.id() };
|
|
107
|
+
const p = this.parent();
|
|
108
|
+
if (p) {
|
|
109
|
+
d.parentId = p.id();
|
|
110
|
+
}
|
|
111
|
+
const c = this.children();
|
|
112
|
+
if (c) {
|
|
113
|
+
d.subfeatures = c.map(child => child.toJSON());
|
|
114
|
+
}
|
|
115
|
+
return d;
|
|
175
116
|
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
value: function fromJSON(json) {
|
|
179
|
-
return new SimpleFeature(_objectSpread({}, json));
|
|
117
|
+
static fromJSON(json) {
|
|
118
|
+
return new SimpleFeature({ ...json });
|
|
180
119
|
}
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
}();
|
|
184
|
-
|
|
185
|
-
exports.default = SimpleFeature;
|
|
120
|
+
}
|
|
121
|
+
exports.default = SimpleFeature;
|
package/util/stats.js
CHANGED
|
@@ -1,28 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.blankStats = blankStats;
|
|
9
|
-
exports.calcPerBaseStats = calcPerBaseStats;
|
|
10
|
-
exports.calcStdFromSums = calcStdFromSums;
|
|
11
|
-
exports.rectifyStats = rectifyStats;
|
|
12
|
-
exports.scoresToStats = scoresToStats;
|
|
13
|
-
|
|
14
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
-
|
|
16
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
|
-
|
|
18
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
19
|
-
|
|
20
|
-
var _operators = require("rxjs/operators");
|
|
21
|
-
|
|
22
|
-
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; }
|
|
23
|
-
|
|
24
|
-
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; }
|
|
25
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.blankStats = exports.scoresToStats = exports.calcPerBaseStats = exports.rectifyStats = exports.calcStdFromSums = void 0;
|
|
4
|
+
const operators_1 = require("rxjs/operators");
|
|
26
5
|
/*
|
|
27
6
|
* calculate standard deviation using the 'shortcut method' that accepts
|
|
28
7
|
* the sum and the sum squares of the elements
|
|
@@ -33,155 +12,116 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
33
12
|
* @param population - boolean: use population instead of sample correction
|
|
34
13
|
* @return the estimated std deviation
|
|
35
14
|
*/
|
|
36
|
-
function calcStdFromSums(sum, sumSquares, n) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
var variance;
|
|
44
|
-
|
|
45
|
-
if (population) {
|
|
46
|
-
variance = sumSquares / n - sum * sum / (n * n);
|
|
47
|
-
} else {
|
|
48
|
-
// sample correction is n-1
|
|
49
|
-
variance = sumSquares - sum * sum / n;
|
|
50
|
-
|
|
51
|
-
if (n > 1) {
|
|
52
|
-
variance /= n - 1;
|
|
15
|
+
function calcStdFromSums(sum, sumSquares, n, population = false) {
|
|
16
|
+
if (n === 0) {
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
19
|
+
let variance;
|
|
20
|
+
if (population) {
|
|
21
|
+
variance = sumSquares / n - (sum * sum) / (n * n);
|
|
53
22
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
23
|
+
else {
|
|
24
|
+
// sample correction is n-1
|
|
25
|
+
variance = sumSquares - (sum * sum) / n;
|
|
26
|
+
if (n > 1) {
|
|
27
|
+
variance /= n - 1;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return variance < 0 ? 0 : Math.sqrt(variance);
|
|
57
31
|
}
|
|
32
|
+
exports.calcStdFromSums = calcStdFromSums;
|
|
58
33
|
/*
|
|
59
34
|
* @param stats - a summary stats object with scoreSum, featureCount, scoreSumSquares, and basesCovered
|
|
60
35
|
* @return - a summary stats object with scoreMean, scoreStdDev, and featureDensity added
|
|
61
36
|
*/
|
|
62
|
-
|
|
63
|
-
|
|
64
37
|
function rectifyStats(s) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
38
|
+
return {
|
|
39
|
+
...s,
|
|
40
|
+
scoreMean: (s.scoreSum || 0) / (s.featureCount || s.basesCovered || 1),
|
|
41
|
+
scoreStdDev: calcStdFromSums(s.scoreSum, s.scoreSumSquares, s.featureCount || s.basesCovered),
|
|
42
|
+
featureDensity: (s.featureCount || 1) / s.basesCovered,
|
|
43
|
+
};
|
|
70
44
|
}
|
|
45
|
+
exports.rectifyStats = rectifyStats;
|
|
71
46
|
/*
|
|
72
47
|
* calculates per-base scores for variable width features over a region
|
|
73
48
|
* @param region - object contains start, end
|
|
74
49
|
* @param features - list of features with start, end, score
|
|
75
50
|
* @return array of numeric scores
|
|
76
51
|
*/
|
|
77
|
-
|
|
78
|
-
|
|
79
52
|
function calcPerBaseStats(region, features) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
scores[i] = 0;
|
|
53
|
+
const { start, end } = region;
|
|
54
|
+
const scores = [];
|
|
55
|
+
const feats = features.sort((a, b) => a.get('start') - b.get('start'));
|
|
56
|
+
let pos = start;
|
|
57
|
+
let currentFeat = 0;
|
|
58
|
+
let i = 0;
|
|
59
|
+
while (pos < end) {
|
|
60
|
+
while (currentFeat < feats.length && pos >= feats[currentFeat].get('end')) {
|
|
61
|
+
currentFeat += 1;
|
|
62
|
+
}
|
|
63
|
+
const f = feats[currentFeat];
|
|
64
|
+
if (!f) {
|
|
65
|
+
scores[i] = 0;
|
|
66
|
+
}
|
|
67
|
+
else if (pos >= f.get('start') && pos < f.get('end')) {
|
|
68
|
+
scores[i] = f.get('score');
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
scores[i] = 0;
|
|
72
|
+
}
|
|
73
|
+
i += 1;
|
|
74
|
+
pos += 1;
|
|
103
75
|
}
|
|
104
|
-
|
|
105
|
-
i += 1;
|
|
106
|
-
pos += 1;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return scores;
|
|
76
|
+
return scores;
|
|
110
77
|
}
|
|
78
|
+
exports.calcPerBaseStats = calcPerBaseStats;
|
|
111
79
|
/*
|
|
112
80
|
* transform a list of scores to summary statistics
|
|
113
81
|
* @param region - object with start, end
|
|
114
82
|
* @param feats - array of features which are possibly summary features
|
|
115
83
|
* @return - object with scoreMax, scoreMin, scoreSum, scoreSumSquares, etc
|
|
116
84
|
*/
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
85
|
+
async function scoresToStats(region, features) {
|
|
86
|
+
const { start, end } = region;
|
|
87
|
+
const { scoreMin, scoreMax, scoreSum, scoreSumSquares, featureCount } = await features
|
|
88
|
+
.pipe((0, operators_1.reduce)((seed, f) => {
|
|
89
|
+
const score = f.get('score');
|
|
90
|
+
seed.scoreMax = Math.max(seed.scoreMax, f.get('summary') ? f.get('maxScore') : score);
|
|
91
|
+
seed.scoreMin = Math.min(seed.scoreMin, f.get('summary') ? f.get('minScore') : score);
|
|
92
|
+
seed.scoreSum += score;
|
|
93
|
+
seed.scoreSumSquares += score * score;
|
|
94
|
+
seed.featureCount += 1;
|
|
95
|
+
return seed;
|
|
96
|
+
}, {
|
|
97
|
+
scoreMin: Number.MAX_VALUE,
|
|
98
|
+
scoreMax: Number.MIN_VALUE,
|
|
99
|
+
scoreSum: 0,
|
|
100
|
+
scoreSumSquares: 0,
|
|
101
|
+
featureCount: 0,
|
|
102
|
+
}))
|
|
103
|
+
.toPromise();
|
|
104
|
+
return rectifyStats({
|
|
105
|
+
scoreMax,
|
|
106
|
+
scoreMin,
|
|
107
|
+
scoreSum,
|
|
108
|
+
scoreSumSquares,
|
|
109
|
+
featureCount,
|
|
110
|
+
basesCovered: end - start + 1,
|
|
111
|
+
});
|
|
121
112
|
}
|
|
122
|
-
|
|
123
|
-
function _scoresToStats() {
|
|
124
|
-
_scoresToStats = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(region, features) {
|
|
125
|
-
var start, end, _yield$features$pipe$, scoreMin, scoreMax, scoreSum, scoreSumSquares, featureCount;
|
|
126
|
-
|
|
127
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
128
|
-
while (1) {
|
|
129
|
-
switch (_context.prev = _context.next) {
|
|
130
|
-
case 0:
|
|
131
|
-
start = region.start, end = region.end;
|
|
132
|
-
_context.next = 3;
|
|
133
|
-
return features.pipe((0, _operators.reduce)(function (seed, f) {
|
|
134
|
-
var score = f.get('score');
|
|
135
|
-
seed.scoreMax = Math.max(seed.scoreMax, f.get('summary') ? f.get('maxScore') : score);
|
|
136
|
-
seed.scoreMin = Math.min(seed.scoreMin, f.get('summary') ? f.get('minScore') : score);
|
|
137
|
-
seed.scoreSum += score;
|
|
138
|
-
seed.scoreSumSquares += score * score;
|
|
139
|
-
seed.featureCount += 1;
|
|
140
|
-
return seed;
|
|
141
|
-
}, {
|
|
142
|
-
scoreMin: Number.MAX_VALUE,
|
|
143
|
-
scoreMax: Number.MIN_VALUE,
|
|
144
|
-
scoreSum: 0,
|
|
145
|
-
scoreSumSquares: 0,
|
|
146
|
-
featureCount: 0
|
|
147
|
-
})).toPromise();
|
|
148
|
-
|
|
149
|
-
case 3:
|
|
150
|
-
_yield$features$pipe$ = _context.sent;
|
|
151
|
-
scoreMin = _yield$features$pipe$.scoreMin;
|
|
152
|
-
scoreMax = _yield$features$pipe$.scoreMax;
|
|
153
|
-
scoreSum = _yield$features$pipe$.scoreSum;
|
|
154
|
-
scoreSumSquares = _yield$features$pipe$.scoreSumSquares;
|
|
155
|
-
featureCount = _yield$features$pipe$.featureCount;
|
|
156
|
-
return _context.abrupt("return", rectifyStats({
|
|
157
|
-
scoreMax: scoreMax,
|
|
158
|
-
scoreMin: scoreMin,
|
|
159
|
-
scoreSum: scoreSum,
|
|
160
|
-
scoreSumSquares: scoreSumSquares,
|
|
161
|
-
featureCount: featureCount,
|
|
162
|
-
basesCovered: end - start + 1
|
|
163
|
-
}));
|
|
164
|
-
|
|
165
|
-
case 10:
|
|
166
|
-
case "end":
|
|
167
|
-
return _context.stop();
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}, _callee);
|
|
171
|
-
}));
|
|
172
|
-
return _scoresToStats.apply(this, arguments);
|
|
173
|
-
}
|
|
174
|
-
|
|
113
|
+
exports.scoresToStats = scoresToStats;
|
|
175
114
|
function blankStats() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
115
|
+
return {
|
|
116
|
+
scoreMin: 0,
|
|
117
|
+
scoreMax: 0,
|
|
118
|
+
scoreMean: 0,
|
|
119
|
+
scoreStdDev: 0,
|
|
120
|
+
scoreSum: 0,
|
|
121
|
+
scoreSumSquares: 0,
|
|
122
|
+
featureCount: 0,
|
|
123
|
+
featureDensity: 0,
|
|
124
|
+
basesCovered: 0,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
exports.blankStats = blankStats;
|