@genome-spy/core 0.65.0 → 0.67.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 (249) hide show
  1. package/dist/bundle/browser-BRemItdO.js +138 -0
  2. package/dist/bundle/{index-CD7FLu9x.js → index-BatuyGAI.js} +23 -21
  3. package/dist/bundle/{index-C0llXMqm.js → index-ByuE8dvu.js} +140 -88
  4. package/dist/bundle/index-Cq3QFUxX.js +1781 -0
  5. package/dist/bundle/index-D28m8tSW.js +1607 -0
  6. package/dist/bundle/index-DbJ0oeYM.js +631 -0
  7. package/dist/bundle/index.es.js +15821 -14601
  8. package/dist/bundle/index.js +214 -212
  9. package/dist/bundle/{inflate-DRgHi_KK.js → inflate-GtwLkvSP.js} +222 -224
  10. package/dist/bundle/unzip-NywezaRR.js +1492 -0
  11. package/dist/schema.json +13 -3
  12. package/dist/src/config/scaleDefaults.d.ts +8 -0
  13. package/dist/src/config/scaleDefaults.d.ts.map +1 -0
  14. package/dist/src/config/scaleDefaults.js +45 -0
  15. package/dist/src/data/flowHandle.d.ts +2 -0
  16. package/dist/src/data/flowHandle.d.ts.map +1 -1
  17. package/dist/src/data/flowHandle.js +1 -0
  18. package/dist/src/data/flowInit.d.ts +12 -4
  19. package/dist/src/data/flowInit.d.ts.map +1 -1
  20. package/dist/src/data/flowInit.js +115 -16
  21. package/dist/src/data/sources/lazy/axisTickSource.js +1 -1
  22. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts +1 -1
  23. package/dist/src/data/sources/lazy/singleAxisLazySource.d.ts.map +1 -1
  24. package/dist/src/data/sources/lazy/singleAxisLazySource.js +10 -3
  25. package/dist/src/data/sources/lazy/singleAxisWindowedSource.d.ts.map +1 -1
  26. package/dist/src/data/sources/lazy/singleAxisWindowedSource.js +5 -1
  27. package/dist/src/data/transforms/filterScoredLabels.d.ts +1 -1
  28. package/dist/src/data/transforms/filterScoredLabels.d.ts.map +1 -1
  29. package/dist/src/data/transforms/filterScoredLabels.js +1 -1
  30. package/dist/src/data/transforms/linearizeGenomicCoordinate.d.ts.map +1 -1
  31. package/dist/src/data/transforms/linearizeGenomicCoordinate.js +2 -1
  32. package/dist/src/encoder/encoder.d.ts +1 -1
  33. package/dist/src/encoder/encoder.d.ts.map +1 -1
  34. package/dist/src/encoder/encoder.js +1 -1
  35. package/dist/src/genome/scaleLocus.d.ts +39 -0
  36. package/dist/src/genome/scaleLocus.d.ts.map +1 -1
  37. package/dist/src/genome/scaleLocus.js +76 -0
  38. package/dist/src/genomeSpy/canvasExport.d.ts +19 -0
  39. package/dist/src/genomeSpy/canvasExport.d.ts.map +1 -0
  40. package/dist/src/genomeSpy/canvasExport.js +66 -0
  41. package/dist/src/genomeSpy/containerUi.d.ts +17 -0
  42. package/dist/src/genomeSpy/containerUi.d.ts.map +1 -0
  43. package/dist/src/genomeSpy/containerUi.js +78 -0
  44. package/dist/src/genomeSpy/eventListenerRegistry.d.ts +19 -0
  45. package/dist/src/genomeSpy/eventListenerRegistry.d.ts.map +1 -0
  46. package/dist/src/genomeSpy/eventListenerRegistry.js +38 -0
  47. package/dist/src/genomeSpy/inputBindingManager.d.ts +14 -0
  48. package/dist/src/genomeSpy/inputBindingManager.d.ts.map +1 -0
  49. package/dist/src/genomeSpy/inputBindingManager.js +63 -0
  50. package/dist/src/genomeSpy/interactionController.d.ts +40 -0
  51. package/dist/src/genomeSpy/interactionController.d.ts.map +1 -0
  52. package/dist/src/genomeSpy/interactionController.js +371 -0
  53. package/dist/src/genomeSpy/keyboardListenerManager.d.ts +10 -0
  54. package/dist/src/genomeSpy/keyboardListenerManager.d.ts.map +1 -0
  55. package/dist/src/genomeSpy/keyboardListenerManager.js +31 -0
  56. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts +15 -0
  57. package/dist/src/genomeSpy/loadingIndicatorManager.d.ts.map +1 -0
  58. package/dist/src/genomeSpy/loadingIndicatorManager.js +92 -0
  59. package/dist/src/genomeSpy/renderCoordinator.d.ts +22 -0
  60. package/dist/src/genomeSpy/renderCoordinator.d.ts.map +1 -0
  61. package/dist/src/genomeSpy/renderCoordinator.js +118 -0
  62. package/dist/src/genomeSpy/viewContextFactory.d.ts +18 -0
  63. package/dist/src/genomeSpy/viewContextFactory.d.ts.map +1 -0
  64. package/dist/src/genomeSpy/viewContextFactory.js +79 -0
  65. package/dist/src/genomeSpy/viewDataInit.d.ts +22 -0
  66. package/dist/src/genomeSpy/viewDataInit.d.ts.map +1 -0
  67. package/dist/src/genomeSpy/viewDataInit.js +160 -0
  68. package/dist/src/genomeSpy/viewDataInit.test.d.ts +2 -0
  69. package/dist/src/genomeSpy/viewDataInit.test.d.ts.map +1 -0
  70. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts +14 -0
  71. package/dist/src/genomeSpy/viewHierarchyConfig.d.ts.map +1 -0
  72. package/dist/src/genomeSpy/viewHierarchyConfig.js +24 -0
  73. package/dist/src/genomeSpy/viewHighlight.d.ts +5 -0
  74. package/dist/src/genomeSpy/viewHighlight.d.ts.map +1 -0
  75. package/dist/src/genomeSpy/viewHighlight.js +30 -0
  76. package/dist/src/genomeSpy.d.ts +17 -71
  77. package/dist/src/genomeSpy.d.ts.map +1 -1
  78. package/dist/src/genomeSpy.js +197 -741
  79. package/dist/src/gl/dataToVertices.d.ts.map +1 -1
  80. package/dist/src/gl/dataToVertices.js +16 -4
  81. package/dist/src/gl/glslScaleGenerator.d.ts +1 -1
  82. package/dist/src/gl/webGLHelper.d.ts +2 -2
  83. package/dist/src/gl/webGLHelper.d.ts.map +1 -1
  84. package/dist/src/gl/webGLHelper.js +4 -4
  85. package/dist/src/index.d.ts.map +1 -1
  86. package/dist/src/index.js +2 -12
  87. package/dist/src/marks/mark.d.ts.map +1 -1
  88. package/dist/src/marks/mark.js +4 -2
  89. package/dist/src/{view → scales}/axisResolution.d.ts +9 -16
  90. package/dist/src/scales/axisResolution.d.ts.map +1 -0
  91. package/dist/src/{view → scales}/axisResolution.js +29 -18
  92. package/dist/src/scales/axisResolution.test.d.ts.map +1 -0
  93. package/dist/src/scales/scaleDomainAggregator.d.ts +57 -0
  94. package/dist/src/scales/scaleDomainAggregator.d.ts.map +1 -0
  95. package/dist/src/scales/scaleDomainAggregator.js +167 -0
  96. package/dist/src/scales/scaleDomainAggregator.test.d.ts +2 -0
  97. package/dist/src/scales/scaleDomainAggregator.test.d.ts.map +1 -0
  98. package/dist/src/scales/scaleInstanceManager.d.ts +40 -0
  99. package/dist/src/scales/scaleInstanceManager.d.ts.map +1 -0
  100. package/dist/src/scales/scaleInstanceManager.js +317 -0
  101. package/dist/src/scales/scaleInstanceManager.test.d.ts +2 -0
  102. package/dist/src/scales/scaleInstanceManager.test.d.ts.map +1 -0
  103. package/dist/src/scales/scaleInteractionController.d.ts +73 -0
  104. package/dist/src/scales/scaleInteractionController.d.ts.map +1 -0
  105. package/dist/src/scales/scaleInteractionController.js +336 -0
  106. package/dist/src/scales/scaleInteractionController.test.d.ts +2 -0
  107. package/dist/src/scales/scaleInteractionController.test.d.ts.map +1 -0
  108. package/dist/src/scales/scalePropsResolver.d.ts +23 -0
  109. package/dist/src/scales/scalePropsResolver.d.ts.map +1 -0
  110. package/dist/src/scales/scalePropsResolver.js +74 -0
  111. package/dist/src/{view → scales}/scaleResolution.d.ts +53 -35
  112. package/dist/src/scales/scaleResolution.d.ts.map +1 -0
  113. package/dist/src/scales/scaleResolution.js +732 -0
  114. package/dist/src/scales/scaleResolution.test.d.ts.map +1 -0
  115. package/dist/src/scales/scaleResolutionConstants.d.ts +6 -0
  116. package/dist/src/scales/scaleResolutionConstants.d.ts.map +1 -0
  117. package/dist/src/scales/scaleResolutionConstants.js +5 -0
  118. package/dist/src/scales/scaleRules.d.ts +16 -0
  119. package/dist/src/scales/scaleRules.d.ts.map +1 -0
  120. package/dist/src/scales/scaleRules.js +103 -0
  121. package/dist/src/scales/scaleRules.test.d.ts +2 -0
  122. package/dist/src/scales/scaleRules.test.d.ts.map +1 -0
  123. package/dist/src/spec/channel.d.ts +13 -18
  124. package/dist/src/spec/scale.d.ts +6 -0
  125. package/dist/src/types/embedApi.d.ts +5 -0
  126. package/dist/src/types/scaleResolutionApi.d.ts +1 -1
  127. package/dist/src/utils/domainArray.d.ts.map +1 -1
  128. package/dist/src/utils/domainArray.js +3 -0
  129. package/dist/src/utils/indexer.d.ts +3 -0
  130. package/dist/src/utils/indexer.d.ts.map +1 -1
  131. package/dist/src/utils/indexer.js +3 -0
  132. package/dist/src/view/concatView.d.ts +18 -0
  133. package/dist/src/view/concatView.d.ts.map +1 -1
  134. package/dist/src/view/concatView.js +73 -0
  135. package/dist/src/view/concatView.test.d.ts +2 -0
  136. package/dist/src/view/concatView.test.d.ts.map +1 -0
  137. package/dist/src/view/containerMutationHelper.d.ts +74 -0
  138. package/dist/src/view/containerMutationHelper.d.ts.map +1 -0
  139. package/dist/src/view/containerMutationHelper.js +118 -0
  140. package/dist/src/view/containerView.d.ts +0 -7
  141. package/dist/src/view/containerView.d.ts.map +1 -1
  142. package/dist/src/view/containerView.js +0 -10
  143. package/dist/src/view/facetView.d.ts.map +1 -1
  144. package/dist/src/view/facetView.js +0 -15
  145. package/dist/src/view/flowBuilder.d.ts +5 -3
  146. package/dist/src/view/flowBuilder.d.ts.map +1 -1
  147. package/dist/src/view/flowBuilder.js +69 -6
  148. package/dist/src/view/gridView/gridChild.d.ts +11 -0
  149. package/dist/src/view/gridView/gridChild.d.ts.map +1 -1
  150. package/dist/src/view/gridView/gridChild.js +32 -6
  151. package/dist/src/view/gridView/gridView.d.ts +39 -1
  152. package/dist/src/view/gridView/gridView.d.ts.map +1 -1
  153. package/dist/src/view/gridView/gridView.js +106 -48
  154. package/dist/src/view/gridView/gridView.test.d.ts +2 -0
  155. package/dist/src/view/gridView/gridView.test.d.ts.map +1 -0
  156. package/dist/src/view/gridView/scrollbar.d.ts +39 -8
  157. package/dist/src/view/gridView/scrollbar.d.ts.map +1 -1
  158. package/dist/src/view/gridView/scrollbar.js +184 -69
  159. package/dist/src/view/layerView.d.ts +14 -0
  160. package/dist/src/view/layerView.d.ts.map +1 -1
  161. package/dist/src/view/layerView.js +66 -0
  162. package/dist/src/view/layerView.test.d.ts +2 -0
  163. package/dist/src/view/layerView.test.d.ts.map +1 -0
  164. package/dist/src/view/testUtils.d.ts.map +1 -1
  165. package/dist/src/view/testUtils.js +7 -1
  166. package/dist/src/view/unitView.d.ts.map +1 -1
  167. package/dist/src/view/unitView.js +41 -36
  168. package/dist/src/view/view.d.ts +18 -6
  169. package/dist/src/view/view.d.ts.map +1 -1
  170. package/dist/src/view/view.js +30 -4
  171. package/package.json +2 -2
  172. package/dist/bundle/browser-txUcLy2H.js +0 -123
  173. package/dist/bundle/index-BQpbYrv4.js +0 -1712
  174. package/dist/bundle/index-BhtHKLUo.js +0 -73
  175. package/dist/bundle/index-CCe8rnZz.js +0 -716
  176. package/dist/bundle/index-DhcU-Gk-.js +0 -1487
  177. package/dist/src/data/collector.test.js +0 -138
  178. package/dist/src/data/dataFlow.test.js +0 -38
  179. package/dist/src/data/flow.test.js +0 -81
  180. package/dist/src/data/flowInit.test.js +0 -413
  181. package/dist/src/data/flowNode.test.js +0 -50
  182. package/dist/src/data/flowOptimizer.test.js +0 -209
  183. package/dist/src/data/formats/fasta.test.js +0 -27
  184. package/dist/src/data/sources/inlineSource.test.js +0 -63
  185. package/dist/src/data/sources/sequenceSource.test.js +0 -81
  186. package/dist/src/data/transforms/aggregate.test.js +0 -134
  187. package/dist/src/data/transforms/clone.test.js +0 -11
  188. package/dist/src/data/transforms/coverage.test.js +0 -238
  189. package/dist/src/data/transforms/filter.test.js +0 -20
  190. package/dist/src/data/transforms/flatten.test.js +0 -96
  191. package/dist/src/data/transforms/flattenDelimited.test.js +0 -90
  192. package/dist/src/data/transforms/flattenSequence.test.js +0 -34
  193. package/dist/src/data/transforms/formula.test.js +0 -25
  194. package/dist/src/data/transforms/identifier.test.js +0 -92
  195. package/dist/src/data/transforms/pileup.test.js +0 -70
  196. package/dist/src/data/transforms/project.test.js +0 -32
  197. package/dist/src/data/transforms/regexExtract.test.js +0 -70
  198. package/dist/src/data/transforms/regexFold.test.js +0 -201
  199. package/dist/src/data/transforms/sample.test.js +0 -38
  200. package/dist/src/data/transforms/stack.test.js +0 -91
  201. package/dist/src/encoder/accessor.test.js +0 -162
  202. package/dist/src/encoder/encoder.test.js +0 -105
  203. package/dist/src/genome/genome.test.js +0 -268
  204. package/dist/src/genome/genomes.test.js +0 -8
  205. package/dist/src/genome/scaleIndex.test.js +0 -78
  206. package/dist/src/genome/scaleLocus.test.js +0 -4
  207. package/dist/src/scale/scale.test.js +0 -326
  208. package/dist/src/scale/ticks.test.js +0 -46
  209. package/dist/src/selection/selection.test.js +0 -14
  210. package/dist/src/utils/addBaseUrl.test.js +0 -30
  211. package/dist/src/utils/binnedIndex.test.js +0 -201
  212. package/dist/src/utils/cloner.test.js +0 -35
  213. package/dist/src/utils/coalesce.test.js +0 -16
  214. package/dist/src/utils/concatIterables.test.js +0 -8
  215. package/dist/src/utils/domainArray.test.js +0 -130
  216. package/dist/src/utils/indexer.test.js +0 -49
  217. package/dist/src/utils/interactionEvent.test.js +0 -35
  218. package/dist/src/utils/iterateNestedMaps.test.js +0 -33
  219. package/dist/src/utils/kWayMerge.test.js +0 -30
  220. package/dist/src/utils/mergeObjects.test.js +0 -42
  221. package/dist/src/utils/numberExtractor.test.js +0 -6
  222. package/dist/src/utils/propertyCacher.test.js +0 -89
  223. package/dist/src/utils/propertyCoalescer.test.js +0 -25
  224. package/dist/src/utils/radixSort.test.js +0 -51
  225. package/dist/src/utils/reservationMap.test.js +0 -20
  226. package/dist/src/utils/ringBuffer.test.js +0 -39
  227. package/dist/src/utils/topK.test.js +0 -54
  228. package/dist/src/utils/trees.test.js +0 -135
  229. package/dist/src/utils/url.test.js +0 -28
  230. package/dist/src/utils/variableTools.test.js +0 -13
  231. package/dist/src/view/axisResolution.d.ts.map +0 -1
  232. package/dist/src/view/axisResolution.test.d.ts.map +0 -1
  233. package/dist/src/view/axisResolution.test.js +0 -206
  234. package/dist/src/view/flowBuilder.test.js +0 -125
  235. package/dist/src/view/gridView/selectionRect.test.js +0 -87
  236. package/dist/src/view/layout/flexLayout.test.js +0 -323
  237. package/dist/src/view/layout/grid.test.js +0 -71
  238. package/dist/src/view/layout/rectangle.test.js +0 -192
  239. package/dist/src/view/paramMediator.test.js +0 -282
  240. package/dist/src/view/scaleResolution.d.ts.map +0 -1
  241. package/dist/src/view/scaleResolution.js +0 -1059
  242. package/dist/src/view/scaleResolution.test.d.ts.map +0 -1
  243. package/dist/src/view/scaleResolution.test.js +0 -645
  244. package/dist/src/view/view.test.js +0 -245
  245. package/dist/src/view/viewDispose.test.js +0 -110
  246. package/dist/src/view/viewFactory.test.js +0 -25
  247. package/dist/src/view/viewUtils.test.js +0 -87
  248. /package/dist/src/{view → scales}/axisResolution.test.d.ts +0 -0
  249. /package/dist/src/{view → scales}/scaleResolution.test.d.ts +0 -0
@@ -1,50 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import FlowNode from "./flowNode.js";
3
- import { validateLinks } from "./flowOptimizer.js";
4
-
5
- describe("Flow mutation", () => {
6
- test("Excise a terminal node", () => {
7
- const a = new FlowNode();
8
- const b = new FlowNode();
9
-
10
- a.addChild(b);
11
- b.excise();
12
-
13
- expect(a.children[0]).toBeUndefined();
14
- expect(b.parent).toBeUndefined();
15
-
16
- expect(validateLinks(a)).toBeTruthy();
17
- });
18
-
19
- test("Excise a node in the middle", () => {
20
- const a = new FlowNode();
21
- const b = new FlowNode();
22
- const c = new FlowNode();
23
-
24
- a.addChild(b);
25
- b.addChild(c);
26
- b.excise();
27
-
28
- expect(a.children[0]).toBe(c);
29
- expect(c.parent).toBe(a);
30
-
31
- expect(validateLinks(a)).toBeTruthy();
32
- });
33
-
34
- test("Insert as parent", () => {
35
- const a = new FlowNode();
36
- const b = new FlowNode();
37
- const c = new FlowNode();
38
- const d = new FlowNode();
39
-
40
- a.addChild(c);
41
- a.addChild(d);
42
- c.insertAsParent(b);
43
-
44
- expect(a.children[0]).toBe(b);
45
- expect(a.children[1]).toBe(d);
46
- expect(a.children[0].children[0]).toBe(c);
47
-
48
- expect(validateLinks(a)).toBeTruthy();
49
- });
50
- });
@@ -1,209 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import FlowNode, { BEHAVIOR_CLONES } from "./flowNode.js";
3
- import {
4
- removeRedundantCloneTransforms,
5
- validateLinks,
6
- } from "./flowOptimizer.js";
7
- import CloneTransform from "./transforms/clone.js";
8
- import Collector from "./collector.js";
9
- import DataFlow from "./dataFlow.js";
10
- import { combineIdenticalDataSources } from "./flowOptimizer.js";
11
- import InlineSource from "./sources/inlineSource.js";
12
- import UrlSource from "./sources/urlSource.js";
13
- import { makeParamMediatorProvider } from "./flowTestUtils.js";
14
-
15
- test("validateLinks() detects broken graph", () => {
16
- const root = new FlowNode();
17
- const a = new FlowNode();
18
- const b = new FlowNode();
19
- const c = new FlowNode();
20
-
21
- root.addChild(a);
22
- root.addChild(b);
23
- root.addChild(c);
24
-
25
- expect(validateLinks(root)).toBeTruthy();
26
-
27
- // Break it!
28
- b.parent = undefined;
29
-
30
- expect(validateLinks(root)).toBeFalsy();
31
-
32
- // Check handling of root
33
-
34
- const rootWithParent = new FlowNode();
35
- // Break it!
36
- rootWithParent.parent = new FlowNode();
37
-
38
- expect(validateLinks(rootWithParent)).toBeFalsy();
39
- });
40
-
41
- describe("removeRedundantCloneTransforms", () => {
42
- test("Removes redundancy from linear graph #1", () => {
43
- const a = new FlowNode();
44
- const b = new CloneTransform();
45
- const c = new FlowNode();
46
- const d = new CloneTransform();
47
- const e = new CloneTransform();
48
- const f = new FlowNode();
49
-
50
- a.addChild(b);
51
- b.addChild(c);
52
- c.addChild(d);
53
- d.addChild(e);
54
- e.addChild(f);
55
-
56
- removeRedundantCloneTransforms(a);
57
-
58
- expect(a.children[0]).toBe(c);
59
- expect(c.children[0]).toBe(f);
60
- });
61
-
62
- test("Removes redundancy from linear graph #2", () => {
63
- const a = new FlowNode();
64
- const b = new CloneTransform();
65
- const c = new FlowNode();
66
- const d = new CloneTransform();
67
- const e = new CloneTransform();
68
- const f = new FlowNode();
69
-
70
- a.addChild(b);
71
- b.addChild(c);
72
- c.addChild(d);
73
- d.addChild(e);
74
- e.addChild(f);
75
-
76
- // First CloneTransform should be retained
77
- removeRedundantCloneTransforms(a, true);
78
-
79
- expect(a.children[0]).toBe(b);
80
- expect(b.children[0]).toBe(c);
81
- expect(c.children[0]).toBe(f);
82
- });
83
-
84
- test("Node with cloning behavior satisfies cloning requirement", () => {
85
- class CloningFlowNode extends FlowNode {
86
- get behavior() {
87
- return BEHAVIOR_CLONES;
88
- }
89
- }
90
-
91
- const a = new FlowNode();
92
- const b = new CloningFlowNode();
93
- const c = new FlowNode();
94
- const d = new CloneTransform();
95
- const e = new FlowNode();
96
-
97
- a.addChild(b);
98
- b.addChild(c);
99
- c.addChild(d);
100
- d.addChild(e);
101
-
102
- removeRedundantCloneTransforms(a, true);
103
-
104
- expect(a.children[0]).toBe(b);
105
- expect(b.children[0]).toBe(c);
106
- expect(c.children[0]).toBe(e);
107
- });
108
-
109
- test("Removes redundancy from a branching graph", () => {
110
- const root = new FlowNode();
111
- const branching = new FlowNode();
112
- const a = new CloneTransform();
113
- const al = new FlowNode();
114
- const b = new CloneTransform();
115
- const bl = new FlowNode();
116
- const c = new CloneTransform();
117
- const cl = new FlowNode();
118
-
119
- root.addChild(branching);
120
- branching.addChild(a);
121
- branching.addChild(b);
122
- branching.addChild(c);
123
- a.addChild(al);
124
- b.addChild(bl);
125
- c.addChild(cl);
126
-
127
- removeRedundantCloneTransforms(root);
128
-
129
- // All but the last branch needs cloning
130
- expect(branching.children[0]).toBe(a);
131
- expect(branching.children[1]).toBe(b);
132
- expect(branching.children[2]).toBe(c);
133
- });
134
- });
135
-
136
- /** @type {import("../view/view.js").default} */
137
- const viewStub = /** @type {any} */ (
138
- Object.assign(makeParamMediatorProvider(), {
139
- getBaseUrl: () => "",
140
- })
141
- );
142
-
143
- describe("Merge indentical data sources", () => {
144
- test("Merges correctly", () => {
145
- /** @type {DataFlow} */
146
- const dataFlow = new DataFlow();
147
-
148
- const a = new UrlSource({ url: "http://genomespy.app/" }, viewStub);
149
- const ac = new Collector();
150
- a.addChild(ac);
151
-
152
- const b = new UrlSource({ url: "http://genomespy.app/" }, viewStub);
153
- const bc = new Collector();
154
- b.addChild(bc);
155
-
156
- const c = new UrlSource({ url: "http://helsinki.fi/" }, viewStub);
157
- const cc = new Collector();
158
- c.addChild(cc);
159
-
160
- dataFlow.addDataSource(a);
161
- dataFlow.addDataSource(b);
162
- dataFlow.addDataSource(c);
163
-
164
- dataFlow.addCollector(ac);
165
- dataFlow.addCollector(bc);
166
- dataFlow.addCollector(cc);
167
-
168
- combineIdenticalDataSources(dataFlow);
169
-
170
- expect(dataFlow.dataSources.length).toEqual(2);
171
-
172
- const entries = dataFlow.dataSources;
173
- const sharedIdentifier = a.identifier;
174
- expect(entries).toContain(a);
175
- expect(entries).toContain(c);
176
- expect(
177
- entries.filter((source) => source.identifier == sharedIdentifier)
178
- ).toEqual([a]);
179
-
180
- expect(new Set(a.children)).toEqual(new Set([ac, bc]));
181
- expect(c.children[0]).toBe(cc);
182
-
183
- for (const dataSource of dataFlow.dataSources) {
184
- // Cheat that we loaded something
185
- dataSource.complete();
186
- }
187
-
188
- expect(ac.completed).toBeTruthy();
189
- expect(bc.completed).toBeTruthy();
190
- expect(cc.completed).toBeTruthy();
191
- });
192
-
193
- test("Does not merge those with undefined identifier", () => {
194
- /** @type {DataFlow} */
195
- const dataFlow = new DataFlow();
196
-
197
- const a = new InlineSource({ values: [1, 2, 3] }, viewStub);
198
- const b = new InlineSource({ values: [1, 2, 3] }, viewStub);
199
-
200
- dataFlow.addDataSource(a);
201
- dataFlow.addDataSource(b);
202
-
203
- combineIdenticalDataSources(dataFlow);
204
-
205
- const entries = dataFlow.dataSources;
206
- expect(entries).toContain(a);
207
- expect(entries).toContain(b);
208
- });
209
- });
@@ -1,27 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import fasta from "./fasta.js";
3
-
4
- test("fasta", () => {
5
- const fileContent = `>A stuff
6
- --------------------------AGAGTTTGATCCTGGCTCAGGGTGAACGCTGGCG
7
- GCGTGC----TTAAGACATGCAAGTCGAACGG-CCT------TCTTCG-G-AAGGC-AGT
8
- ---------------------------------
9
- >B other stuff
10
- --------------------------AGAGTTTGATCATGGCTCAGGGTGAACGCTGGCG
11
- GCGTGC----TTAAGACATGCAAGTCGGACGA-TCG------GCTTCG---GCCGGTAGT
12
- ---------------------------------
13
- `;
14
-
15
- expect(fasta(fileContent)).toEqual([
16
- {
17
- identifier: "A",
18
- sequence:
19
- "--------------------------AGAGTTTGATCCTGGCTCAGGGTGAACGCTGGCGGCGTGC----TTAAGACATGCAAGTCGAACGG-CCT------TCTTCG-G-AAGGC-AGT---------------------------------",
20
- },
21
- {
22
- identifier: "B",
23
- sequence:
24
- "--------------------------AGAGTTTGATCATGGCTCAGGGTGAACGCTGGCGGCGTGC----TTAAGACATGCAAGTCGGACGA-TCG------GCTTCG---GCCGGTAGT---------------------------------",
25
- },
26
- ]);
27
- });
@@ -1,63 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import Collector from "../collector.js";
3
- import InlineSource from "./inlineSource.js";
4
-
5
- /**
6
- * @param {InlineSource} source
7
- */
8
- async function collectSource(source) {
9
- const collector = new Collector();
10
- source.addChild(collector);
11
-
12
- await source.load();
13
-
14
- return [...collector.getData()];
15
- }
16
-
17
- test("InlineSource propagates an object", async () => {
18
- expect(
19
- await collectSource(new InlineSource({ values: { x: 1 } }, undefined))
20
- ).toEqual([{ x: 1 }]);
21
- });
22
-
23
- test("InlineSource propagates an array of objects", async () => {
24
- expect(
25
- await collectSource(
26
- new InlineSource({ values: [{ x: 1 }, { x: 2 }] }, undefined)
27
- )
28
- ).toEqual([{ x: 1 }, { x: 2 }]);
29
- });
30
-
31
- test("InlineSource wraps scalars to objects", async () => {
32
- expect(
33
- await collectSource(new InlineSource({ values: [1, 2] }, undefined))
34
- ).toEqual([{ data: 1 }, { data: 2 }]);
35
- });
36
-
37
- test("InlineSource parses a string", async () => {
38
- expect(
39
- await collectSource(
40
- new InlineSource(
41
- {
42
- values: "a\n1\n2\n3",
43
- format: {
44
- type: "csv",
45
- },
46
- },
47
- undefined
48
- )
49
- )
50
- ).toEqual([{ a: 1 }, { a: 2 }, { a: 3 }]);
51
- });
52
-
53
- test("InlineSource throws on a string and a missing format specifier", () => {
54
- expect(
55
- () =>
56
- new InlineSource(
57
- {
58
- values: "a\n1\n2\n3",
59
- },
60
- undefined
61
- )
62
- ).toThrow();
63
- });
@@ -1,81 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import Collector from "../collector.js";
3
- import SequenceSource from "./sequenceSource.js";
4
- import { makeParamMediatorProvider } from "../flowTestUtils.js";
5
-
6
- /**
7
- * @param {SequenceSource} source
8
- */
9
- async function collectSource(source) {
10
- const collector = new Collector();
11
- source.addChild(collector);
12
-
13
- await source.load();
14
-
15
- return [...collector.getData()];
16
- }
17
-
18
- describe("SequenceSource", () => {
19
- /** @type {import("../../view/view.js").default} */
20
- const viewStub = /** @type {any} */ (makeParamMediatorProvider());
21
-
22
- test("generates a sequence", () =>
23
- expect(
24
- collectSource(
25
- new SequenceSource(
26
- { sequence: { start: 0, stop: 3 } },
27
- viewStub
28
- )
29
- )
30
- ).resolves.toEqual([{ data: 0 }, { data: 1 }, { data: 2 }]));
31
-
32
- test("generates a sequence with a custom step", () =>
33
- expect(
34
- collectSource(
35
- new SequenceSource(
36
- { sequence: { start: 0, stop: 5, step: 2 } },
37
- viewStub
38
- )
39
- )
40
- ).resolves.toEqual([{ data: 0 }, { data: 2 }, { data: 4 }]));
41
-
42
- test("generates a sequence with a custom field name", () =>
43
- expect(
44
- collectSource(
45
- new SequenceSource(
46
- { sequence: { start: 0, stop: 3, as: "x" } },
47
- viewStub
48
- )
49
- )
50
- ).resolves.toEqual([{ x: 0 }, { x: 1 }, { x: 2 }]));
51
-
52
- test("accepts ExprRef parameters", async () =>
53
- expect(
54
- collectSource(
55
- new SequenceSource(
56
- {
57
- sequence: {
58
- start: { expr: "0" },
59
- stop: { expr: "1 + 2" },
60
- step: { expr: "1" },
61
- as: "x",
62
- },
63
- },
64
- viewStub
65
- )
66
- )
67
- // TODO: Test that the sequence is regenerated when the parameters change
68
- ).resolves.toEqual([{ x: 0 }, { x: 1 }, { x: 2 }]));
69
-
70
- test("throws on missing 'start' parameter", () =>
71
- expect(
72
- // @ts-expect-error
73
- () => new SequenceSource({ sequence: { stop: 3 } }, viewStub)
74
- ).toThrow());
75
-
76
- test("throws on missing 'stop' parameter", () =>
77
- expect(
78
- // @ts-expect-error
79
- () => new SequenceSource({ sequence: { start: 0 } }, viewStub)
80
- ).toThrow());
81
- });
@@ -1,134 +0,0 @@
1
- import { describe, expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
- import AggregateTransform from "./aggregate.js";
4
-
5
- /**
6
- * @param {import("../../spec/transform.js").AggregateParams} params
7
- * @param {any[]} data
8
- */
9
- function transform(params, data) {
10
- return processData(new AggregateTransform(params), data);
11
- }
12
-
13
- describe("Aggregate transform", () => {
14
- test("Default to count when no data fields or group-by fields are specified", () => {
15
- const input = [
16
- { name: "alpha", data: 123 },
17
- { name: "beta", data: 456 },
18
- { name: "beta", data: 789 },
19
- ];
20
-
21
- expect(transform({ type: "aggregate" }, input)).toEqual([{ count: 3 }]);
22
- });
23
-
24
- test("Default to count when no data fields fields are specified", () => {
25
- const input = [
26
- { name: "alpha", data: 123 },
27
- { name: "beta", data: 456 },
28
- { name: "beta", data: 789 },
29
- ];
30
-
31
- expect(
32
- transform({ type: "aggregate", groupby: ["name"] }, input)
33
- ).toEqual([
34
- { name: "alpha", count: 1 },
35
- { name: "beta", count: 2 },
36
- ]);
37
- });
38
-
39
- test("Compute count, sum, min, max, and mean for groups. Use default output field names.", () => {
40
- const input = [
41
- { name: "alpha", data: 123 },
42
- { name: "beta", data: 456 },
43
- { name: "beta", data: 789 },
44
- ];
45
-
46
- expect(
47
- transform(
48
- {
49
- type: "aggregate",
50
- groupby: ["name"],
51
- fields: ["data", "data", "data", "data", "data"],
52
- ops: ["count", "sum", "min", "max", "mean"],
53
- },
54
- input
55
- )
56
- ).toEqual([
57
- {
58
- name: "alpha",
59
- count_data: 1,
60
- sum_data: 123,
61
- min_data: 123,
62
- max_data: 123,
63
- mean_data: 123,
64
- },
65
- {
66
- name: "beta",
67
- count_data: 2,
68
- sum_data: 1245,
69
- min_data: 456,
70
- max_data: 789,
71
- mean_data: 622.5,
72
- },
73
- ]);
74
- });
75
-
76
- test("Allow custom output field names", () => {
77
- const input = [
78
- { name: "alpha", data: 123 },
79
- { name: "beta", data: 456 },
80
- { name: "beta", data: 789 },
81
- ];
82
-
83
- expect(
84
- transform(
85
- {
86
- type: "aggregate",
87
- fields: ["data", "data", "data", "data", "data"],
88
- ops: ["count", "sum", "min", "max", "mean"],
89
- as: ["count", "total", "min", "max", "average"],
90
- },
91
- input
92
- )
93
- ).toEqual([
94
- {
95
- count: 3,
96
- total: 1368,
97
- min: 123,
98
- max: 789,
99
- average: 456,
100
- },
101
- ]);
102
- });
103
-
104
- test("Throw if the length of fields and ops does not match", () => {
105
- const input = [{ name: "beta", data: 789 }];
106
-
107
- expect(() =>
108
- transform(
109
- {
110
- type: "aggregate",
111
- fields: ["data", "data", "data", "data"],
112
- ops: ["count", "sum", "min", "max", "mean"],
113
- },
114
- input
115
- )
116
- ).toThrow();
117
- });
118
-
119
- test("Throw if the length of fields and as does not match", () => {
120
- const input = [{ name: "beta", data: 789 }];
121
-
122
- expect(() =>
123
- transform(
124
- {
125
- type: "aggregate",
126
- fields: ["data"],
127
- ops: ["count"],
128
- as: ["count", "total"],
129
- },
130
- input
131
- )
132
- ).toThrow();
133
- });
134
- });
@@ -1,11 +0,0 @@
1
- import { expect, test } from "vitest";
2
- import { processData } from "../flowTestUtils.js";
3
- import CloneTransform from "./clone.js";
4
-
5
- test("CloneTransform clones the data objects", () => {
6
- const data = [{ x: 1 }, { x: 2 }];
7
- const clonedData = processData(new CloneTransform(), data);
8
-
9
- expect(clonedData).toEqual(data);
10
- expect(clonedData[0]).not.toBe(data[0]);
11
- });