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