@genome-spy/core 0.64.0 → 0.66.1

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 (285) hide show
  1. package/dist/bundle/{index-CCJIjehY.js → AbortablePromiseCache-CcuMrnn7.js} +22 -91
  2. package/dist/bundle/browser-BRemItdO.js +138 -0
  3. package/dist/bundle/index-BatuyGAI.js +271 -0
  4. package/dist/bundle/index-ByuE8dvu.js +332 -0
  5. package/dist/bundle/index-Cq3QFUxX.js +1781 -0
  6. package/dist/bundle/{index-C08YCM2T.js → index-D-w7Mmt9.js} +246 -126
  7. package/dist/bundle/index-D28m8tSW.js +1607 -0
  8. package/dist/bundle/index-D74H8TTz.js +508 -0
  9. package/dist/bundle/index-DbJ0oeYM.js +631 -0
  10. package/dist/bundle/index.es.js +15034 -13842
  11. package/dist/bundle/index.js +223 -237
  12. package/dist/bundle/inflate-GtwLkvSP.js +1048 -0
  13. package/dist/bundle/unzip-NywezaRR.js +1492 -0
  14. package/dist/schema.json +22 -4
  15. package/dist/src/config/scaleDefaults.d.ts +8 -0
  16. package/dist/src/config/scaleDefaults.d.ts.map +1 -0
  17. package/dist/src/config/scaleDefaults.js +45 -0
  18. package/dist/src/data/collector.d.ts +7 -2
  19. package/dist/src/data/collector.d.ts.map +1 -1
  20. package/dist/src/data/collector.js +13 -2
  21. package/dist/src/data/dataFlow.d.ts +20 -42
  22. package/dist/src/data/dataFlow.d.ts.map +1 -1
  23. package/dist/src/data/dataFlow.js +57 -80
  24. package/dist/src/data/flowHandle.d.ts +15 -0
  25. package/dist/src/data/flowHandle.d.ts.map +1 -0
  26. package/dist/src/data/flowHandle.js +13 -0
  27. package/dist/src/data/flowInit.d.ts +85 -0
  28. package/dist/src/data/flowInit.d.ts.map +1 -0
  29. package/dist/src/data/flowInit.js +238 -0
  30. package/dist/src/data/flowInit.test.d.ts +2 -0
  31. package/dist/src/data/flowInit.test.d.ts.map +1 -0
  32. package/dist/src/data/flowOptimizer.d.ts +6 -4
  33. package/dist/src/data/flowOptimizer.d.ts.map +1 -1
  34. package/dist/src/data/flowOptimizer.js +29 -14
  35. package/dist/src/data/sources/lazy/axisTickSource.js +1 -1
  36. package/dist/src/data/sources/lazy/bamSource.js +1 -1
  37. package/dist/src/data/sources/lazy/bigBedSource.js +1 -1
  38. package/dist/src/data/sources/lazy/bigWigSource.js +1 -1
  39. package/dist/src/data/sources/lazy/gff3Source.d.ts +2 -6
  40. package/dist/src/data/sources/lazy/gff3Source.d.ts.map +1 -1
  41. package/dist/src/data/sources/lazy/gff3Source.js +4 -8
  42. package/dist/src/data/sources/lazy/indexedFastaSource.d.ts.map +1 -1
  43. package/dist/src/data/sources/lazy/indexedFastaSource.js +17 -17
  44. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +1 -1
  45. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
  46. package/dist/src/data/sources/lazy/singleAxisLazySource.js +10 -3
  47. package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
  48. package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +5 -1
  49. package/dist/src/data/sources/lazy/tabixSource.js +1 -1
  50. package/dist/src/data/transforms/filterScoredLabels.d.ts +1 -1
  51. package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
  52. package/dist/src/data/transforms/filterScoredLabels.js +1 -1
  53. package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -1
  54. package/dist/src/data/transforms/linearizeGenomicCoordinate.js +2 -1
  55. package/dist/src/encoder/encoder.d.ts +1 -1
  56. package/dist/src/encoder/encoder.d.ts.map +1 -1
  57. package/dist/src/encoder/encoder.js +1 -1
  58. package/dist/src/genome/scaleLocus.d.ts +39 -0
  59. package/dist/src/genome/scaleLocus.d.ts.map +1 -1
  60. package/dist/src/genome/scaleLocus.js +76 -0
  61. package/dist/src/genomeSpy/canvasExport.d.ts +19 -0
  62. package/dist/src/genomeSpy/canvasExport.d.ts.map +1 -0
  63. package/dist/src/genomeSpy/canvasExport.js +66 -0
  64. package/dist/src/genomeSpy/containerUi.d.ts +17 -0
  65. package/dist/src/genomeSpy/containerUi.d.ts.map +1 -0
  66. package/dist/src/genomeSpy/containerUi.js +78 -0
  67. package/dist/src/genomeSpy/eventListenerRegistry.d.ts +19 -0
  68. package/dist/src/genomeSpy/eventListenerRegistry.d.ts.map +1 -0
  69. package/dist/src/genomeSpy/eventListenerRegistry.js +38 -0
  70. package/dist/src/genomeSpy/inputBindingManager.d.ts +14 -0
  71. package/dist/src/genomeSpy/inputBindingManager.d.ts.map +1 -0
  72. package/dist/src/genomeSpy/inputBindingManager.js +63 -0
  73. package/dist/src/genomeSpy/interactionController.d.ts +40 -0
  74. package/dist/src/genomeSpy/interactionController.d.ts.map +1 -0
  75. package/dist/src/genomeSpy/interactionController.js +371 -0
  76. package/dist/src/genomeSpy/keyboardListenerManager.d.ts +10 -0
  77. package/dist/src/genomeSpy/keyboardListenerManager.d.ts.map +1 -0
  78. package/dist/src/genomeSpy/keyboardListenerManager.js +31 -0
  79. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +15 -0
  80. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -0
  81. package/dist/src/genomeSpy/loadingIndicatorManager.js +92 -0
  82. package/dist/src/genomeSpy/renderCoordinator.d.ts +22 -0
  83. package/dist/src/genomeSpy/renderCoordinator.d.ts.map +1 -0
  84. package/dist/src/genomeSpy/renderCoordinator.js +118 -0
  85. package/dist/src/genomeSpy/viewContextFactory.d.ts +18 -0
  86. package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -0
  87. package/dist/src/genomeSpy/viewContextFactory.js +79 -0
  88. package/dist/src/genomeSpy/viewDataInit.d.ts +12 -0
  89. package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -0
  90. package/dist/src/genomeSpy/viewDataInit.js +41 -0
  91. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts +14 -0
  92. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts.map +1 -0
  93. package/dist/src/genomeSpy/viewHierarchyConfig.js +24 -0
  94. package/dist/src/genomeSpy/viewHighlight.d.ts +5 -0
  95. package/dist/src/genomeSpy/viewHighlight.d.ts.map +1 -0
  96. package/dist/src/genomeSpy/viewHighlight.js +30 -0
  97. package/dist/src/genomeSpy.d.ts +17 -72
  98. package/dist/src/genomeSpy.d.ts.map +1 -1
  99. package/dist/src/genomeSpy.js +180 -789
  100. package/dist/src/gl/glslScaleGenerator.d.ts +1 -1
  101. package/dist/src/gl/webGLHelper.d.ts +2 -2
  102. package/dist/src/gl/webGLHelper.d.ts.map +1 -1
  103. package/dist/src/gl/webGLHelper.js +4 -4
  104. package/dist/src/index.d.ts.map +1 -1
  105. package/dist/src/index.js +2 -12
  106. package/dist/src/marks/mark.d.ts +1 -0
  107. package/dist/src/marks/mark.d.ts.map +1 -1
  108. package/dist/src/marks/mark.js +26 -3
  109. package/dist/src/{view → scales}/axisResolution.d.ts +12 -14
  110. package/dist/src/scales/axisResolution.d.ts.map +1 -0
  111. package/dist/src/{view → scales}/axisResolution.js +38 -12
  112. package/dist/src/scales/axisResolution.test.d.ts.map +1 -0
  113. package/dist/src/scales/scaleDomainAggregator.d.ts +57 -0
  114. package/dist/src/scales/scaleDomainAggregator.d.ts.map +1 -0
  115. package/dist/src/scales/scaleDomainAggregator.js +162 -0
  116. package/dist/src/scales/scaleDomainAggregator.test.d.ts +2 -0
  117. package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +1 -0
  118. package/dist/src/scales/scaleInstanceManager.d.ts +40 -0
  119. package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -0
  120. package/dist/src/scales/scaleInstanceManager.js +313 -0
  121. package/dist/src/scales/scaleInstanceManager.test.d.ts +2 -0
  122. package/dist/src/scales/scaleInstanceManager.test.d.ts.map +1 -0
  123. package/dist/src/scales/scaleInteractionController.d.ts +73 -0
  124. package/dist/src/scales/scaleInteractionController.d.ts.map +1 -0
  125. package/dist/src/scales/scaleInteractionController.js +336 -0
  126. package/dist/src/scales/scaleInteractionController.test.d.ts +2 -0
  127. package/dist/src/scales/scaleInteractionController.test.d.ts.map +1 -0
  128. package/dist/src/scales/scalePropsResolver.d.ts +23 -0
  129. package/dist/src/scales/scalePropsResolver.d.ts.map +1 -0
  130. package/dist/src/scales/scalePropsResolver.js +74 -0
  131. package/dist/src/{view → scales}/scaleResolution.d.ts +53 -31
  132. package/dist/src/scales/scaleResolution.d.ts.map +1 -0
  133. package/dist/src/scales/scaleResolution.js +658 -0
  134. package/dist/src/scales/scaleResolution.test.d.ts.map +1 -0
  135. package/dist/src/scales/scaleResolutionConstants.d.ts +6 -0
  136. package/dist/src/scales/scaleResolutionConstants.d.ts.map +1 -0
  137. package/dist/src/scales/scaleResolutionConstants.js +5 -0
  138. package/dist/src/scales/scaleRules.d.ts +16 -0
  139. package/dist/src/scales/scaleRules.d.ts.map +1 -0
  140. package/dist/src/scales/scaleRules.js +103 -0
  141. package/dist/src/scales/scaleRules.test.d.ts +2 -0
  142. package/dist/src/scales/scaleRules.test.d.ts.map +1 -0
  143. package/dist/src/spec/channel.d.ts +13 -18
  144. package/dist/src/spec/sampleView.d.ts +3 -2
  145. package/dist/src/spec/scale.d.ts +6 -0
  146. package/dist/src/types/embedApi.d.ts +5 -0
  147. package/dist/src/types/scaleResolutionApi.d.ts +1 -1
  148. package/dist/src/types/viewContext.d.ts +1 -1
  149. package/dist/src/view/concatView.d.ts +18 -0
  150. package/dist/src/view/concatView.d.ts.map +1 -1
  151. package/dist/src/view/concatView.js +73 -0
  152. package/dist/src/view/concatView.test.d.ts +2 -0
  153. package/dist/src/view/concatView.test.d.ts.map +1 -0
  154. package/dist/src/view/containerMutationHelper.d.ts +74 -0
  155. package/dist/src/view/containerMutationHelper.d.ts.map +1 -0
  156. package/dist/src/view/containerMutationHelper.js +114 -0
  157. package/dist/src/view/containerView.d.ts +0 -7
  158. package/dist/src/view/containerView.d.ts.map +1 -1
  159. package/dist/src/view/containerView.js +0 -10
  160. package/dist/src/view/facetView.d.ts.map +1 -1
  161. package/dist/src/view/facetView.js +0 -14
  162. package/dist/src/view/flowBuilder.d.ts +2 -2
  163. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  164. package/dist/src/view/flowBuilder.js +21 -4
  165. package/dist/src/view/gridView/gridChild.d.ts +11 -0
  166. package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
  167. package/dist/src/view/gridView/gridChild.js +32 -6
  168. package/dist/src/view/gridView/gridView.d.ts +39 -1
  169. package/dist/src/view/gridView/gridView.d.ts.map +1 -1
  170. package/dist/src/view/gridView/gridView.js +113 -42
  171. package/dist/src/view/gridView/gridView.test.d.ts +2 -0
  172. package/dist/src/view/gridView/gridView.test.d.ts.map +1 -0
  173. package/dist/src/view/gridView/scrollbar.d.ts +39 -8
  174. package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
  175. package/dist/src/view/gridView/scrollbar.js +184 -69
  176. package/dist/src/view/gridView/selectionRect.d.ts +8 -4
  177. package/dist/src/view/gridView/selectionRect.d.ts.map +1 -1
  178. package/dist/src/view/gridView/selectionRect.js +28 -3
  179. package/dist/src/view/gridView/selectionRect.test.d.ts +2 -0
  180. package/dist/src/view/gridView/selectionRect.test.d.ts.map +1 -0
  181. package/dist/src/view/layerView.d.ts +14 -0
  182. package/dist/src/view/layerView.d.ts.map +1 -1
  183. package/dist/src/view/layerView.js +66 -0
  184. package/dist/src/view/layerView.test.d.ts +2 -0
  185. package/dist/src/view/layerView.test.d.ts.map +1 -0
  186. package/dist/src/view/paramMediator.d.ts +2 -1
  187. package/dist/src/view/paramMediator.d.ts.map +1 -1
  188. package/dist/src/view/paramMediator.js +13 -1
  189. package/dist/src/view/testUtils.d.ts.map +1 -1
  190. package/dist/src/view/testUtils.js +18 -5
  191. package/dist/src/view/unitView.d.ts.map +1 -1
  192. package/dist/src/view/unitView.js +52 -12
  193. package/dist/src/view/view.d.ts +23 -7
  194. package/dist/src/view/view.d.ts.map +1 -1
  195. package/dist/src/view/view.js +61 -5
  196. package/dist/src/view/viewDispose.test.d.ts +2 -0
  197. package/dist/src/view/viewDispose.test.d.ts.map +1 -0
  198. package/dist/src/view/viewUtils.d.ts +4 -4
  199. package/dist/src/view/viewUtils.d.ts.map +1 -1
  200. package/dist/src/view/viewUtils.js +19 -15
  201. package/dist/src/view/viewUtils.test.d.ts +2 -0
  202. package/dist/src/view/viewUtils.test.d.ts.map +1 -0
  203. package/package.json +10 -10
  204. package/dist/bundle/__vite-browser-external-C--ziKoh.js +0 -8
  205. package/dist/bundle/_commonjsHelpers-DjF3Plf2.js +0 -26
  206. package/dist/bundle/index-5ajWdKly.js +0 -1319
  207. package/dist/bundle/index-B03-Om4z.js +0 -274
  208. package/dist/bundle/index-BftNdA0O.js +0 -27
  209. package/dist/bundle/index-Bg7C4Xat.js +0 -2750
  210. package/dist/bundle/index-C3QR8Lv6.js +0 -2131
  211. package/dist/bundle/index-DTcHjAHp.js +0 -505
  212. package/dist/bundle/index-DnIkxb0L.js +0 -1025
  213. package/dist/bundle/index-Ww3TAo6_.js +0 -71
  214. package/dist/bundle/index-g8iXgW0W.js +0 -651
  215. package/dist/bundle/long-B-FASCSo.js +0 -2387
  216. package/dist/bundle/remoteFile-BuaqFGWk.js +0 -94
  217. package/dist/src/data/collector.test.js +0 -138
  218. package/dist/src/data/dataFlow.test.js +0 -5
  219. package/dist/src/data/flow.test.js +0 -81
  220. package/dist/src/data/flowNode.test.js +0 -50
  221. package/dist/src/data/flowOptimizer.test.js +0 -204
  222. package/dist/src/data/formats/fasta.test.js +0 -27
  223. package/dist/src/data/sources/inlineSource.test.js +0 -63
  224. package/dist/src/data/sources/sequenceSource.test.js +0 -81
  225. package/dist/src/data/transforms/aggregate.test.js +0 -134
  226. package/dist/src/data/transforms/clone.test.js +0 -11
  227. package/dist/src/data/transforms/coverage.test.js +0 -238
  228. package/dist/src/data/transforms/filter.test.js +0 -20
  229. package/dist/src/data/transforms/flatten.test.js +0 -96
  230. package/dist/src/data/transforms/flattenDelimited.test.js +0 -90
  231. package/dist/src/data/transforms/flattenSequence.test.js +0 -34
  232. package/dist/src/data/transforms/formula.test.js +0 -25
  233. package/dist/src/data/transforms/identifier.test.js +0 -92
  234. package/dist/src/data/transforms/pileup.test.js +0 -70
  235. package/dist/src/data/transforms/project.test.js +0 -32
  236. package/dist/src/data/transforms/regexExtract.test.js +0 -70
  237. package/dist/src/data/transforms/regexFold.test.js +0 -201
  238. package/dist/src/data/transforms/sample.test.js +0 -38
  239. package/dist/src/data/transforms/stack.test.js +0 -91
  240. package/dist/src/encoder/accessor.test.js +0 -162
  241. package/dist/src/encoder/encoder.test.js +0 -105
  242. package/dist/src/genome/genome.test.js +0 -268
  243. package/dist/src/genome/genomes.test.js +0 -8
  244. package/dist/src/genome/scaleIndex.test.js +0 -78
  245. package/dist/src/genome/scaleLocus.test.js +0 -4
  246. package/dist/src/scale/scale.test.js +0 -326
  247. package/dist/src/scale/ticks.test.js +0 -46
  248. package/dist/src/selection/selection.test.js +0 -14
  249. package/dist/src/utils/addBaseUrl.test.js +0 -30
  250. package/dist/src/utils/binnedIndex.test.js +0 -201
  251. package/dist/src/utils/cloner.test.js +0 -35
  252. package/dist/src/utils/coalesce.test.js +0 -16
  253. package/dist/src/utils/concatIterables.test.js +0 -8
  254. package/dist/src/utils/domainArray.test.js +0 -130
  255. package/dist/src/utils/indexer.test.js +0 -49
  256. package/dist/src/utils/interactionEvent.test.js +0 -35
  257. package/dist/src/utils/iterateNestedMaps.test.js +0 -33
  258. package/dist/src/utils/kWayMerge.test.js +0 -30
  259. package/dist/src/utils/mergeObjects.test.js +0 -42
  260. package/dist/src/utils/numberExtractor.test.js +0 -6
  261. package/dist/src/utils/propertyCacher.test.js +0 -89
  262. package/dist/src/utils/propertyCoalescer.test.js +0 -25
  263. package/dist/src/utils/radixSort.test.js +0 -51
  264. package/dist/src/utils/reservationMap.test.js +0 -20
  265. package/dist/src/utils/ringBuffer.test.js +0 -39
  266. package/dist/src/utils/topK.test.js +0 -54
  267. package/dist/src/utils/trees.test.js +0 -135
  268. package/dist/src/utils/url.test.js +0 -28
  269. package/dist/src/utils/variableTools.test.js +0 -13
  270. package/dist/src/view/axisResolution.d.ts.map +0 -1
  271. package/dist/src/view/axisResolution.test.d.ts.map +0 -1
  272. package/dist/src/view/axisResolution.test.js +0 -206
  273. package/dist/src/view/flowBuilder.test.js +0 -125
  274. package/dist/src/view/layout/flexLayout.test.js +0 -323
  275. package/dist/src/view/layout/grid.test.js +0 -71
  276. package/dist/src/view/layout/rectangle.test.js +0 -192
  277. package/dist/src/view/paramMediator.test.js +0 -260
  278. package/dist/src/view/scaleResolution.d.ts.map +0 -1
  279. package/dist/src/view/scaleResolution.js +0 -1049
  280. package/dist/src/view/scaleResolution.test.d.ts.map +0 -1
  281. package/dist/src/view/scaleResolution.test.js +0 -645
  282. package/dist/src/view/view.test.js +0 -245
  283. package/dist/src/view/viewFactory.test.js +0 -25
  284. /package/dist/src/{view → scales}/axisResolution.test.d.ts +0 -0
  285. /package/dist/src/{view → scales}/scaleResolution.test.d.ts +0 -0
@@ -1,34 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
- import FlattenSequenceTransform from "./flattenSequence.js";
4
-
5
- /**
6
- * @param {import("../../spec/transform.js").FlattenSequenceParams} params
7
- * @param {any[]} data
8
- */
9
- function transform(params, data) {
10
- return processData(new FlattenSequenceTransform(params), data);
11
- }
12
-
13
- test("FlattenSequenece", () => {
14
- expect(
15
- transform(
16
- {
17
- type: "flattenSequence",
18
- field: "seq",
19
- as: ["p", "seq"],
20
- },
21
- [
22
- { identifier: "A", seq: "TCG" },
23
- { identifier: "B", seq: "AAT" },
24
- ]
25
- )
26
- ).toEqual([
27
- { identifier: "A", seq: "T", p: 0 },
28
- { identifier: "A", seq: "C", p: 1 },
29
- { identifier: "A", seq: "G", p: 2 },
30
- { identifier: "B", seq: "A", p: 0 },
31
- { identifier: "B", seq: "A", p: 1 },
32
- { identifier: "B", seq: "T", p: 2 },
33
- ]);
34
- });
@@ -1,25 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { makeParamMediatorProvider, processData } from "../flowTestUtils.js";
3
- import FormulaTransform from "./formula.js";
4
-
5
- test.todo("Implement stub for ParamMediator");
6
-
7
- test("FormulaTransform", () => {
8
- const data = [{ a: 2 }, { a: 3 }];
9
-
10
- const t = new FormulaTransform(
11
- {
12
- type: "formula",
13
- expr: "datum.a * 2",
14
- as: "b",
15
- },
16
- makeParamMediatorProvider()
17
- );
18
-
19
- t.initialize();
20
-
21
- expect(processData(t, data)).toEqual([
22
- { a: 2, b: 4 },
23
- { a: 3, b: 6 },
24
- ]);
25
- });
@@ -1,92 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { range } from "d3-array";
3
- import { processData } from "../flowTestUtils.js";
4
- import IdentifierTransform, {
5
- BLOCK_SIZE,
6
- UNIQUE_ID_KEY,
7
- } from "./identifier.js";
8
-
9
- test("An IdentifierTransform adds identifiers correctly", () => {
10
- const data = range(BLOCK_SIZE * 2).map((x) => ({ data: x }));
11
-
12
- const identifiedData = processData(
13
- new IdentifierTransform({ type: "identifier" }),
14
- data
15
- );
16
-
17
- // The fist block is skipped
18
- const firstId = BLOCK_SIZE;
19
-
20
- expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
21
- expect(identifiedData[1]).toEqual({
22
- data: 1,
23
- [UNIQUE_ID_KEY]: firstId + 1,
24
- });
25
- expect(identifiedData[BLOCK_SIZE]).toEqual({
26
- data: BLOCK_SIZE,
27
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
28
- });
29
- expect(identifiedData[BLOCK_SIZE + 1]).toEqual({
30
- data: BLOCK_SIZE + 1,
31
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE + 1,
32
- });
33
- });
34
-
35
- test("Another transform instance adds identifiers correctly", () => {
36
- const data = range(BLOCK_SIZE * 2).map((x) => ({ data: x }));
37
- // Another instance
38
- const identifiedData = processData(
39
- new IdentifierTransform({ type: "identifier" }),
40
- data
41
- );
42
-
43
- // The fist block was skipped and the previous test case consumed two blocks
44
- const firstId = BLOCK_SIZE * 3;
45
-
46
- expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
47
- expect(identifiedData[1]).toEqual({
48
- data: 1,
49
- [UNIQUE_ID_KEY]: firstId + 1,
50
- });
51
- expect(identifiedData[BLOCK_SIZE]).toEqual({
52
- data: BLOCK_SIZE,
53
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
54
- });
55
- expect(identifiedData[BLOCK_SIZE + 1]).toEqual({
56
- data: BLOCK_SIZE + 1,
57
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE + 1,
58
- });
59
- });
60
-
61
- test("IdentifierTransform recycles allocated blocks", () => {
62
- let data = range(BLOCK_SIZE * 2).map((x) => ({ data: x }));
63
-
64
- const transform = new IdentifierTransform({ type: "identifier" });
65
- let identifiedData = processData(transform, data);
66
-
67
- let firstId = BLOCK_SIZE * 5;
68
-
69
- expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
70
- expect(identifiedData[BLOCK_SIZE]).toEqual({
71
- data: BLOCK_SIZE,
72
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
73
- });
74
-
75
- data = range(BLOCK_SIZE * 3).map((x) => ({ data: x }));
76
-
77
- // Resetting the transform. It should now reuse the allocated blocks.
78
- transform.reset();
79
- identifiedData = processData(transform, data);
80
-
81
- expect(identifiedData[0]).toEqual({ data: 0, [UNIQUE_ID_KEY]: firstId });
82
- expect(identifiedData[BLOCK_SIZE]).toEqual({
83
- data: BLOCK_SIZE,
84
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE,
85
- });
86
-
87
- // ... and reserve one extra
88
- expect(identifiedData[BLOCK_SIZE * 2]).toEqual({
89
- data: BLOCK_SIZE * 2,
90
- [UNIQUE_ID_KEY]: firstId + BLOCK_SIZE * 2,
91
- });
92
- });
@@ -1,70 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import PileupTransform from "./pileup.js";
3
- import { processData } from "../flowTestUtils.js";
4
-
5
- // TODO: Test for lane preferences
6
-
7
- /**
8
- * @typedef {import("../../spec/transform.js").PileupParams} PileupParams
9
- */
10
-
11
- const reads = [
12
- [0, 4],
13
- [1, 3],
14
- [2, 6],
15
- [4, 8],
16
- [8, 10],
17
- [11, 14],
18
- [11, 13],
19
- [11, 12],
20
- [15, 18],
21
- [16, 18],
22
- [17, 18],
23
- ].map((d) => ({
24
- start: d[0],
25
- end: d[1],
26
- }));
27
-
28
- const lanes = [0, 1, 2, 1, 0, 0, 1, 2, 0, 1, 2];
29
-
30
- /** @type {PileupParams} */
31
- const params = {
32
- type: "pileup",
33
- start: "start",
34
- end: "end",
35
- };
36
-
37
- /**
38
- * @param {PileupParams} params
39
- * @param {any[]} data
40
- */
41
- function pileupTransform(params, data) {
42
- const t = new PileupTransform(params);
43
- t.initialize();
44
- return processData(t, data);
45
- }
46
-
47
- test("Pileup transform produces correct pileup", () => {
48
- const piledUp = lanes.map((d, i) => ({
49
- ...reads[i],
50
- lane: d,
51
- }));
52
-
53
- expect(pileupTransform(params, reads)).toEqual(piledUp);
54
- });
55
-
56
- test("Pileup transform produces correct pileup with consecutive contigs", () => {
57
- // Simulate data having multiple chromosomes, sorted by [chrom, pos].
58
- // Piling should handle suddenly decreasing start positions by freeing all
59
- // reserved lanes.
60
-
61
- const repeatedReads = [...reads, ...reads];
62
- const repeatedLanes = [...lanes, ...lanes];
63
-
64
- const piledUp = repeatedLanes.map((d, i) => ({
65
- ...repeatedReads[i],
66
- lane: d,
67
- }));
68
-
69
- expect(pileupTransform(params, repeatedReads)).toEqual(piledUp);
70
- });
@@ -1,32 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
- import ProjectTransform from "./project.js";
4
-
5
- test("Project", () => {
6
- const data = [
7
- {
8
- foo: "FOO",
9
- bar: "BAR",
10
- baz: { a: "A" },
11
- },
12
- ];
13
-
14
- /** @param {import("../../spec/transform.js").ProjectParams} params */
15
- const p = (params) => processData(new ProjectTransform(params), data);
16
-
17
- expect(p({ type: "project", fields: ["bar"] })).toEqual([{ bar: "BAR" }]);
18
-
19
- expect(
20
- p({ type: "project", fields: ["bar", "foo"], as: ["xBar", "xFoo"] })
21
- ).toEqual([{ xBar: "BAR", xFoo: "FOO" }]);
22
-
23
- expect(p({ type: "project", fields: ["baz.a"] })).toEqual([
24
- { "baz.a": "A" },
25
- ]);
26
-
27
- expect(p({ type: "project", fields: ["baz.a"], as: ["a"] })).toEqual([
28
- { a: "A" },
29
- ]);
30
-
31
- expect(() => p({ type: "project", fields: ["bar"], as: [] })).toThrow();
32
- });
@@ -1,70 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
-
4
- import RegexExtractTransform from "./regexExtract.js";
5
-
6
- /**
7
- * @param {import("../../spec/transform.js").RegexExtractParams} params
8
- * @param {any[]} data
9
- */
10
- function transform(params, data) {
11
- return processData(new RegexExtractTransform(params), data);
12
- }
13
-
14
- describe("RegexExtractTransform", () => {
15
- /**
16
- * @typedef {import("../../spec/transform.js").RegexExtractParams} RegexExtractParams
17
- */
18
- const rows = [{ a: "12-34" }, { a: "23-45" }];
19
-
20
- /** @type {RegexExtractParams} */
21
- const params = {
22
- type: "regexExtract",
23
- regex: "^(\\d+)-(\\d+)$",
24
- field: "a",
25
- as: ["b", "c"],
26
- };
27
-
28
- test("Valid config and input", () => {
29
- expect(transform(params, rows)).toEqual([
30
- { a: "12-34", b: "12", c: "34" },
31
- { a: "23-45", b: "23", c: "45" },
32
- ]);
33
- });
34
-
35
- test("Invalid config", () => {
36
- /** @type {RegexExtractParams} */
37
- const config2 = {
38
- type: "regexExtract",
39
- regex: "^(\\d+)-(\\d+)$",
40
- field: "a",
41
- as: ["b", "c", "d"],
42
- };
43
-
44
- expect(() => transform(config2, rows)).toThrow();
45
- });
46
-
47
- test("Invalid data", () => {
48
- const rows2 = [{ a: "12--34" }];
49
-
50
- expect(() => transform(params, rows2)).toThrow();
51
- });
52
-
53
- test("Invalid, non-string data", () => {
54
- const rows2 = [{ a: 123 }];
55
-
56
- expect(() => transform(params, rows2)).toThrow();
57
- });
58
-
59
- test("Skip invalid or non-string data", () => {
60
- const rows2 = [{ a: 123 }, { a: "xyzzy" }, { a: "12-34" }];
61
-
62
- expect(transform({ ...params, skipInvalidInput: true }, rows2)).toEqual(
63
- [
64
- { a: 123, b: undefined, c: undefined },
65
- { a: "xyzzy", b: undefined, c: undefined },
66
- { a: "12-34", b: "12", c: "34" },
67
- ]
68
- );
69
- });
70
- });
@@ -1,201 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
- import RegexFoldTransform from "./regexFold.js";
4
-
5
- describe("RegexFold", () => {
6
- test("Throws error if the number of capture groups in columnRegex != 1", () => {
7
- /** @type { import("../../spec/transform.js").RegexFoldParams } */
8
- const singleGatherConfig = {
9
- type: "regexFold",
10
- columnRegex: "^.+_a$",
11
- asValue: "a",
12
- };
13
-
14
- expect(() => new RegexFoldTransform(singleGatherConfig)).toThrowError(
15
- `Regex /^.+_a$/ must have exactly one capturing group!`
16
- );
17
- });
18
-
19
- test("Transform single variable", () => {
20
- const sampleData = [
21
- {
22
- row: 1,
23
- sample1_a: "r1s1a",
24
- sample2_a: "r1s2a",
25
- },
26
- {
27
- row: 2,
28
- sample1_a: "r2s1a",
29
- sample2_a: "r2s2a",
30
- },
31
- ];
32
-
33
- /** @type { import("../../spec/transform.js").RegexFoldParams } */
34
- const singleGatherConfig = {
35
- type: "regexFold",
36
- columnRegex: "^(.*)_a$",
37
- asValue: "a",
38
- };
39
-
40
- const result = processData(
41
- new RegexFoldTransform(singleGatherConfig),
42
- sampleData
43
- );
44
-
45
- expect(result).toEqual([
46
- {
47
- row: 1,
48
- sample: "sample1",
49
- a: "r1s1a",
50
- },
51
- {
52
- row: 1,
53
- sample: "sample2",
54
- a: "r1s2a",
55
- },
56
- {
57
- row: 2,
58
- sample: "sample1",
59
- a: "r2s1a",
60
- },
61
- {
62
- row: 2,
63
- sample: "sample2",
64
- a: "r2s2a",
65
- },
66
- ]);
67
- });
68
-
69
- test("Transform single variable and skip specific columns", () => {
70
- const sampleData = [
71
- {
72
- row: 1,
73
- sample1_a: "r1s1a",
74
- sample2_a: "r1s2a",
75
- },
76
- {
77
- row: 2,
78
- sample1_a: "r2s1a",
79
- sample2_a: "r2s2a",
80
- },
81
- ];
82
-
83
- /** @type { import("../../spec/transform.js").RegexFoldParams } */
84
- const singleGatherConfig = {
85
- type: "regexFold",
86
- columnRegex: "^(.*)_a$",
87
- asValue: "a",
88
- skipRegex: "^row$",
89
- };
90
-
91
- const result = processData(
92
- new RegexFoldTransform(singleGatherConfig),
93
- sampleData
94
- );
95
-
96
- expect(result).toEqual([
97
- {
98
- sample: "sample1",
99
- a: "r1s1a",
100
- },
101
- {
102
- sample: "sample2",
103
- a: "r1s2a",
104
- },
105
- {
106
- sample: "sample1",
107
- a: "r2s1a",
108
- },
109
- {
110
- sample: "sample2",
111
- a: "r2s2a",
112
- },
113
- ]);
114
- });
115
-
116
- test("Transform multiple variables", () => {
117
- const sampleData = [
118
- {
119
- row: 1,
120
- sample1_a: "r1s1a",
121
- sample2_a: "r1s2a",
122
- sample1_b: "r1s1b",
123
- sample2_b: "r1s2b",
124
- },
125
- {
126
- row: 2,
127
- sample1_a: "r2s1a",
128
- sample2_a: "r2s2a",
129
- sample1_b: "r2s1b",
130
- sample2_b: "r2s2b",
131
- },
132
- ];
133
-
134
- /** @type { import("../../spec/transform.js").RegexFoldParams } */
135
- const singleGatherConfig = {
136
- type: "regexFold",
137
- columnRegex: ["^(.*)_a$", "^(.*)_b$"],
138
- asValue: ["a", "b"],
139
- };
140
-
141
- const result = processData(
142
- new RegexFoldTransform(singleGatherConfig),
143
- sampleData
144
- );
145
-
146
- expect(result).toEqual([
147
- {
148
- row: 1,
149
- sample: "sample1",
150
- a: "r1s1a",
151
- b: "r1s1b",
152
- },
153
- {
154
- row: 1,
155
- sample: "sample2",
156
- a: "r1s2a",
157
- b: "r1s2b",
158
- },
159
- {
160
- row: 2,
161
- sample: "sample1",
162
- a: "r2s1a",
163
- b: "r2s1b",
164
- },
165
- {
166
- row: 2,
167
- sample: "sample2",
168
- a: "r2s2a",
169
- b: "r2s2b",
170
- },
171
- ]);
172
- });
173
-
174
- test("Throws error if no columns match the regex", () => {
175
- const sampleData = [
176
- {
177
- row: 1,
178
- sample1_a: "r1s1a",
179
- sample2_a: "r1s2a",
180
- },
181
- {
182
- row: 2,
183
- sample1_a: "r2s1a",
184
- sample2_a: "r2s2a",
185
- },
186
- ];
187
-
188
- /** @type { import("../../spec/transform.js").RegexFoldParams } */
189
- const singleGatherConfig = {
190
- type: "regexFold",
191
- columnRegex: "^(.*)_c$",
192
- asValue: "a",
193
- };
194
-
195
- expect(() =>
196
- processData(new RegexFoldTransform(singleGatherConfig), sampleData)
197
- ).toThrowError(
198
- "No columns matching the regex /^(.*)_c$/ found in the data!"
199
- );
200
- });
201
- });
@@ -1,38 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import SampleTransform from "./sample.js";
3
- import { extent } from "d3-array";
4
- import { createChain } from "../../view/flowBuilder.js";
5
-
6
- test("SampleTransform produces roughly uniform distributions", () => {
7
- const size = 10;
8
- const n = 20;
9
- const rounds = 10000;
10
-
11
- const freqs = [];
12
- for (let i = 0; i < n; i++) {
13
- freqs[i] = 0;
14
- }
15
-
16
- const { dataSource, collector } = createChain(
17
- new SampleTransform({ type: "sample", size })
18
- );
19
-
20
- for (let r = 0; r < rounds; r++) {
21
- for (let i = 0; i < n; i++) {
22
- dataSource.handle({ data: i });
23
- }
24
- dataSource.complete();
25
-
26
- for (const datum of collector.getData()) {
27
- freqs[datum.data] = freqs[datum.data] + 1;
28
- }
29
-
30
- dataSource.reset();
31
- }
32
-
33
- const e = extent(freqs);
34
-
35
- // Not a deterministic test! TODO: Come up with some sensical testing method
36
- expect(e[0]).toBeGreaterThan(4800);
37
- expect(e[1]).toBeLessThan(5200);
38
- });
@@ -1,91 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
- import StackTransform from "./stack.js";
4
-
5
- const sampleData = [
6
- { group: "a", choice: "q", value: 1 },
7
- { group: "b", choice: "x", value: 1 },
8
- { group: "b", choice: "y", value: 3 },
9
- ];
10
-
11
- /** @type {import("../../spec/transform.js").StackParams} */
12
- const baseParams = {
13
- type: "stack",
14
- field: "value",
15
- groupby: ["group"],
16
- sort: {
17
- field: "value",
18
- order: "ascending",
19
- },
20
- offset: "zero",
21
- as: ["z0", "z1"],
22
- };
23
-
24
- /**
25
- *
26
- * @param {import("../../spec/transform.js").StackParams} params
27
- * @param {any[]} data
28
- */
29
- function transform(params, data) {
30
- return processData(new StackTransform(params), data);
31
- }
32
-
33
- describe("Stack transform", () => {
34
- test("No field", () => {
35
- const conf = Object.assign({}, baseParams, {
36
- field: undefined,
37
- });
38
-
39
- expect(transform(conf, sampleData)).toEqual([
40
- { group: "a", choice: "q", value: 1, z0: 0, z1: 1 },
41
- { group: "b", choice: "x", value: 1, z0: 0, z1: 1 },
42
- { group: "b", choice: "y", value: 3, z0: 1, z1: 2 },
43
- ]);
44
- });
45
-
46
- test("Zero offset", () => {
47
- expect(transform(baseParams, sampleData)).toEqual([
48
- { group: "a", choice: "q", value: 1, z0: 0, z1: 1 },
49
- { group: "b", choice: "x", value: 1, z0: 0, z1: 1 },
50
- { group: "b", choice: "y", value: 3, z0: 1, z1: 4 },
51
- ]);
52
- });
53
-
54
- test("Normalize offset", () => {
55
- const conf = Object.assign({}, baseParams, {
56
- offset: "normalize",
57
- });
58
-
59
- expect(transform(conf, sampleData)).toEqual([
60
- { group: "a", choice: "q", value: 1, z0: 0, z1: 1 },
61
- { group: "b", choice: "x", value: 1, z0: 0, z1: 0.25 },
62
- { group: "b", choice: "y", value: 3, z0: 0.25, z1: 1 },
63
- ]);
64
- });
65
-
66
- test("Center offset", () => {
67
- const conf = Object.assign({}, baseParams, {
68
- offset: "center",
69
- });
70
-
71
- expect(transform(conf, sampleData)).toEqual([
72
- { group: "a", choice: "q", value: 1, z0: -0.5, z1: 0.5 },
73
- { group: "b", choice: "x", value: 1, z0: -2, z1: -1 },
74
- { group: "b", choice: "y", value: 3, z0: -1, z1: 2 },
75
- ]);
76
- });
77
-
78
- test("Descending sort", () => {
79
- const conf = Object.assign({}, baseParams, {
80
- sort: {
81
- field: "value",
82
- order: "descending",
83
- },
84
- });
85
- expect(transform(conf, sampleData)).toEqual([
86
- { group: "a", choice: "q", value: 1, z0: 0, z1: 1 },
87
- { group: "b", choice: "y", value: 3, z0: 0, z1: 3 },
88
- { group: "b", choice: "x", value: 1, z0: 3, z1: 4 },
89
- ]);
90
- });
91
- });