@molgenis/vip-report-template 6.1.1 → 7.0.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 (285) hide show
  1. package/.nvmrc +1 -1
  2. package/.travis.yml +9 -11
  3. package/README.md +411 -1
  4. package/eslint.config.mjs +11 -0
  5. package/package.json +40 -35
  6. package/scripts/deploy_npm_registry.sh +5 -0
  7. package/src/App.tsx +35 -29
  8. package/src/assets/sass/main.scss +12 -4
  9. package/src/components/Allele.tsx +95 -0
  10. package/src/components/Anchor.tsx +1 -1
  11. package/src/components/Breadcrumb.tsx +8 -5
  12. package/src/components/DatasetDropdown.tsx +10 -23
  13. package/src/components/ErrorNotification.tsx +9 -0
  14. package/src/components/GenomeBrowser.tsx +40 -23
  15. package/src/components/HpoTerm.tsx +1 -1
  16. package/src/components/{record/Pager.tsx → Pager.tsx} +21 -14
  17. package/src/components/RecordsPerPage.tsx +9 -7
  18. package/src/components/RecordsTable.tsx +130 -0
  19. package/src/components/SampleTable.tsx +70 -98
  20. package/src/components/SearchBox.tsx +8 -2
  21. package/src/components/Sort.tsx +28 -25
  22. package/src/components/Table.tsx +16 -0
  23. package/src/components/Tooltip.tsx +20 -0
  24. package/src/components/VariantBreadcrumb.tsx +54 -0
  25. package/src/components/VariantConsequenceContainer.tsx +100 -0
  26. package/src/components/VariantConsequenceTable.tsx +58 -0
  27. package/src/components/VariantContainer.tsx +71 -0
  28. package/src/components/VariantFilters.tsx +27 -0
  29. package/src/components/VariantGenotypeTable.tsx +44 -0
  30. package/src/components/VariantInfoTable.tsx +24 -33
  31. package/src/components/VariantResults.tsx +103 -0
  32. package/src/components/VariantTable.tsx +62 -66
  33. package/src/components/VariantTypeSelect.tsx +34 -0
  34. package/src/components/VariantsContainer.tsx +150 -0
  35. package/src/components/VariantsContainerHeader.tsx +70 -0
  36. package/src/components/field/Field.tsx +80 -0
  37. package/src/components/field/FieldAlt.tsx +19 -0
  38. package/src/components/field/FieldChrom.tsx +6 -0
  39. package/src/components/{record/Id.tsx → field/FieldFilter.tsx} +2 -1
  40. package/src/components/field/FieldFormat.tsx +10 -0
  41. package/src/components/{record/Filter.tsx → field/FieldId.tsx} +1 -1
  42. package/src/components/field/FieldPos.tsx +6 -0
  43. package/src/components/field/FieldQual.tsx +6 -0
  44. package/src/components/field/FieldRef.tsx +8 -0
  45. package/src/components/field/composed/FieldClinVar.tsx +72 -0
  46. package/src/components/field/composed/FieldComposed.tsx +68 -0
  47. package/src/components/field/composed/FieldGene.tsx +39 -0
  48. package/src/components/field/composed/FieldGenotype.tsx +35 -0
  49. package/src/components/{record/format/GenotypeField.tsx → field/composed/FieldGenotypeSnvSv.tsx} +20 -16
  50. package/src/components/field/composed/FieldGenotypeStr.tsx +31 -0
  51. package/src/components/field/composed/FieldGnomAd.tsx +58 -0
  52. package/src/components/field/composed/FieldHpo.tsx +50 -0
  53. package/src/components/field/composed/FieldInheritanceModes.tsx +32 -0
  54. package/src/components/field/composed/FieldLocus.tsx +18 -0
  55. package/src/components/field/composed/FieldVipC.tsx +25 -0
  56. package/src/components/field/composed/FieldVipCS.tsx +15 -0
  57. package/src/components/field/composed/FieldVkgl.tsx +37 -0
  58. package/src/components/field/genotype/FieldGenotype.tsx +19 -0
  59. package/src/components/field/genotype/FieldGenotypeType.tsx +9 -0
  60. package/src/components/field/info/FieldConsequence.tsx +15 -0
  61. package/src/components/{record/info/Hgvs.tsx → field/info/FieldHgvs.tsx} +4 -6
  62. package/src/components/field/info/FieldInfo.tsx +27 -0
  63. package/src/components/{record/info/PubMed.tsx → field/info/FieldPubMed.tsx} +4 -7
  64. package/src/components/field/typed/FieldCategorical.tsx +17 -0
  65. package/src/components/{record/field/FieldValueCharacter.tsx → field/typed/FieldCharacter.tsx} +3 -2
  66. package/src/components/{record/field/FieldValueFlag.tsx → field/typed/FieldFlag.tsx} +3 -2
  67. package/src/components/{record/field/FieldValueFloat.tsx → field/typed/FieldFloat.tsx} +3 -2
  68. package/src/components/{record/field/FieldValueInteger.tsx → field/typed/FieldInteger.tsx} +3 -2
  69. package/src/components/{record/field/FieldValueString.tsx → field/typed/FieldString.tsx} +3 -2
  70. package/src/components/field/typed/FieldTyped.tsx +20 -0
  71. package/src/components/field/typed/FieldTypedItem.tsx +49 -0
  72. package/src/components/field/typed/FieldTypedMultiple.tsx +21 -0
  73. package/src/components/filter/Filter.tsx +56 -48
  74. package/src/components/filter/FilterWrapper.scss +23 -0
  75. package/src/components/filter/FilterWrapper.tsx +63 -0
  76. package/src/components/filter/composed/FilterAllelicImbalance.tsx +26 -0
  77. package/src/components/filter/composed/FilterComposed.tsx +92 -0
  78. package/src/components/filter/composed/FilterDeNovo.tsx +35 -0
  79. package/src/components/filter/composed/FilterHpo.tsx +16 -0
  80. package/src/components/filter/composed/FilterInheritance.tsx +42 -0
  81. package/src/components/filter/composed/FilterLocus.tsx +75 -0
  82. package/src/components/filter/composed/FilterVipC.tsx +16 -0
  83. package/src/components/filter/composed/FilterVipCS.tsx +16 -0
  84. package/src/components/filter/fixed/FilterAlt.tsx +20 -0
  85. package/src/components/filter/fixed/FilterChrom.tsx +22 -0
  86. package/src/components/filter/fixed/FilterFilter.tsx +20 -0
  87. package/src/components/filter/fixed/FilterFixed.tsx +96 -0
  88. package/src/components/filter/fixed/FilterId.tsx +20 -0
  89. package/src/components/filter/fixed/FilterPos.tsx +22 -0
  90. package/src/components/filter/fixed/FilterQual.tsx +21 -0
  91. package/src/components/filter/fixed/FilterRef.tsx +22 -0
  92. package/src/components/filter/typed/FilterCategorical.tsx +119 -0
  93. package/src/components/filter/typed/FilterFlag.tsx +23 -0
  94. package/src/components/filter/typed/FilterInterval.tsx +72 -0
  95. package/src/components/filter/typed/FilterString.tsx +43 -0
  96. package/src/components/filter/typed/FilterTyped.tsx +56 -0
  97. package/src/components/form/ButtonApply.tsx +11 -0
  98. package/src/components/form/ButtonDownload.tsx +11 -0
  99. package/src/components/form/ButtonReset.tsx +9 -0
  100. package/src/components/{Checkbox.tsx → form/Checkbox.tsx} +4 -9
  101. package/src/components/form/Input.tsx +19 -0
  102. package/src/components/form/Select.scss +7 -0
  103. package/src/components/form/Select.tsx +34 -0
  104. package/src/components/tree/DecisionTreeBoolMultiQuery.tsx +1 -1
  105. package/src/components/tree/DecisionTreeBoolQuery.tsx +1 -1
  106. package/src/components/tree/DecisionTreeNode.tsx +41 -39
  107. package/src/components/tree/DecisionTreeNodeBool.tsx +1 -1
  108. package/src/components/tree/DecisionTreeNodeBoolMulti.tsx +1 -1
  109. package/src/components/tree/DecisionTreeNodeCategorical.tsx +1 -1
  110. package/src/components/tree/DecisionTreeNodeExists.tsx +1 -1
  111. package/src/components/tree/DecisionTreeNodeLeaf.tsx +1 -1
  112. package/src/components/tree/DecisionTreeOutcomeNode.tsx +1 -1
  113. package/src/components/tree/DecisionTreePath.tsx +1 -1
  114. package/src/igv.d.ts +2 -1
  115. package/src/index.tsx +48 -19
  116. package/src/mocks/GRCh37/decisionTree.json +23 -22
  117. package/src/mocks/GRCh37/field_metadata.json +435 -95
  118. package/src/mocks/GRCh37/sampleTree.json +143 -0
  119. package/src/mocks/GRCh37/static.ts +63 -133
  120. package/src/mocks/GRCh37/vcf/family.vcf.blob +37 -31
  121. package/src/mocks/GRCh38/decisionTree.json +52 -33
  122. package/src/mocks/GRCh38/decisionTreeStr.json +572 -0
  123. package/src/mocks/GRCh38/fasta/chr1_149380406-149403321.fasta.gz.blob +0 -0
  124. package/src/mocks/GRCh38/field_metadata.json +435 -95
  125. package/src/mocks/GRCh38/sampleTree.json +175 -0
  126. package/src/mocks/GRCh38/static.ts +101 -42
  127. package/src/mocks/GRCh38/str.cram.blob +0 -0
  128. package/src/mocks/GRCh38/str.cram.crai.blob +0 -0
  129. package/src/mocks/GRCh38/vcf/family.vcf.blob +25 -24
  130. package/src/mocks/GRCh38/vcf/no_vep.vcf.blob +29 -28
  131. package/src/mocks/GRCh38/vcf/samples_0.vcf.blob +28 -27
  132. package/src/mocks/GRCh38/vcf/samples_1.vcf.blob +29 -28
  133. package/src/mocks/GRCh38/vcf/samples_100.vcf.blob +28 -27
  134. package/src/mocks/GRCh38/vcf/str.vcf.blob +321 -0
  135. package/src/mocks/MockApiClient.ts +341 -328
  136. package/src/mocks/config_cram.json +701 -0
  137. package/src/mocks/config_vcf.json +699 -0
  138. package/src/store/app.ts +30 -0
  139. package/src/store/index.tsx +3 -168
  140. package/src/store/variants.ts +182 -0
  141. package/src/types/config.d.ts +190 -0
  142. package/src/types/configCellComposed.d.ts +86 -0
  143. package/src/types/configCells.d.ts +129 -0
  144. package/src/types/configFilter.d.ts +80 -0
  145. package/src/types/configFilterComposed.d.ts +60 -0
  146. package/src/types/configSort.d.ts +13 -0
  147. package/src/types/filter.d.ts +17 -0
  148. package/src/types/store.d.ts +34 -0
  149. package/src/utils/api.ts +281 -0
  150. package/src/utils/config/config.ts +182 -0
  151. package/src/utils/config/configCells.ts +74 -0
  152. package/src/utils/config/configCellsComposed.ts +508 -0
  153. package/src/utils/config/configCellsField.ts +61 -0
  154. package/src/utils/config/configCellsFixed.ts +126 -0
  155. package/src/utils/config/configFilters.ts +46 -0
  156. package/src/utils/config/configFiltersComposed.ts +208 -0
  157. package/src/utils/config/configFiltersField.ts +49 -0
  158. package/src/utils/config/configFiltersFixed.ts +106 -0
  159. package/src/utils/config/configSorts.ts +44 -0
  160. package/src/utils/config/configValidator.ts +380 -0
  161. package/src/utils/config/configVip.ts +25 -0
  162. package/src/utils/csq.ts +115 -0
  163. package/src/utils/decisionTree.ts +45 -0
  164. package/src/utils/download.ts +30 -0
  165. package/src/utils/error.ts +69 -0
  166. package/src/utils/query/query.ts +55 -0
  167. package/src/utils/query/queryFilter.ts +132 -0
  168. package/src/utils/query/queryFilterComposed.ts +247 -0
  169. package/src/utils/query/queryFilterField.ts +75 -0
  170. package/src/utils/query/queryFilterFixed.ts +44 -0
  171. package/src/utils/query/querySample.ts +18 -0
  172. package/src/utils/query/queryVariantType.ts +76 -0
  173. package/src/utils/query/selector.ts +41 -0
  174. package/src/utils/{sortUtils.ts → query/sort.ts} +32 -11
  175. package/src/utils/sample.ts +19 -35
  176. package/src/utils/utils.ts +66 -2
  177. package/src/utils/variantType.ts +43 -0
  178. package/src/utils/vcf.ts +352 -0
  179. package/src/views/Help.tsx +109 -114
  180. package/src/views/Home.tsx +3 -2
  181. package/src/views/Sample.tsx +12 -7
  182. package/src/views/SampleVariant.tsx +23 -112
  183. package/src/views/SampleVariantConsequence.tsx +54 -114
  184. package/src/views/SampleVariants.tsx +33 -445
  185. package/src/views/SampleVariantsRedirect.tsx +20 -0
  186. package/src/views/Samples.tsx +7 -10
  187. package/src/views/Variant.tsx +31 -61
  188. package/src/views/VariantConsequence.tsx +42 -72
  189. package/src/views/Variants.tsx +29 -138
  190. package/src/views/VariantsRedirect.tsx +25 -0
  191. package/src/views/data/data.tsx +32 -6
  192. package/tests/store/variants.test.ts +122 -0
  193. package/tests/utils/config/config.test.ts +167 -0
  194. package/tests/utils/config/configCells.test.ts +86 -0
  195. package/tests/utils/config/configCellsComposed.test.ts +1163 -0
  196. package/tests/utils/config/configCellsField.test.ts +164 -0
  197. package/tests/utils/config/configCellsFixed.test.ts +99 -0
  198. package/tests/utils/config/configFilters.test.ts +80 -0
  199. package/tests/utils/config/configFiltersComposed.test.ts +504 -0
  200. package/tests/utils/config/configFiltersField.test.ts +140 -0
  201. package/tests/utils/config/configFiltersFixed.test.ts +81 -0
  202. package/tests/utils/config/configSorts.test.ts +55 -0
  203. package/tests/utils/config/configValidator.test.ts +56 -0
  204. package/tests/utils/config/configVip.test.ts +53 -0
  205. package/tests/utils/decisionTree.test.ts +71 -0
  206. package/tests/utils/download.test.ts +20 -0
  207. package/tests/utils/query/query.test.ts +84 -0
  208. package/tests/utils/query/queryFilter.test.ts +243 -0
  209. package/tests/utils/query/queryFilterComposed.test.ts +301 -0
  210. package/tests/utils/query/queryFilterField.test.ts +75 -0
  211. package/tests/utils/query/queryFilterFixed.test.ts +86 -0
  212. package/tests/utils/query/querySample.test.ts +45 -0
  213. package/tests/utils/query/queryVariantType.test.ts +56 -0
  214. package/{src/__tests__/sortUtils.test.ts → tests/utils/query/sort.test.ts} +3 -4
  215. package/tests/utils/sample.test.ts +259 -0
  216. package/tests/utils/utils.test.ts +120 -0
  217. package/tests/utils/variantType.test.ts +48 -0
  218. package/tests/utils/vcf.test.ts +649 -0
  219. package/tsconfig.json +6 -2
  220. package/vite.config.mts +20 -3
  221. package/.eslintignore +0 -4
  222. package/.eslintrc.js +0 -23
  223. package/src/Api.ts +0 -12
  224. package/src/__tests__/decisionTreeUtils.test.ts +0 -75
  225. package/src/__tests__/field.test.ts +0 -107
  226. package/src/__tests__/query.test.ts +0 -188
  227. package/src/__tests__/sample.test.ts +0 -184
  228. package/src/__tests__/utils.test.ts +0 -24
  229. package/src/__tests__/viewUtils.test.ts +0 -125
  230. package/src/components/ConsequenceTable.tsx +0 -45
  231. package/src/components/Error.tsx +0 -9
  232. package/src/components/FieldHeader.tsx +0 -26
  233. package/src/components/InfoCollapsablePane.tsx +0 -90
  234. package/src/components/VariantInfoNestedTable.tsx +0 -127
  235. package/src/components/VariantSampleTable.tsx +0 -58
  236. package/src/components/VariantsSampleTable.tsx +0 -183
  237. package/src/components/VariantsTable.tsx +0 -124
  238. package/src/components/filter/FilterAllelicBalance.tsx +0 -81
  239. package/src/components/filter/FilterCategorical.tsx +0 -81
  240. package/src/components/filter/FilterClinVar.tsx +0 -21
  241. package/src/components/filter/FilterGene.tsx +0 -34
  242. package/src/components/filter/FilterHpo.tsx +0 -161
  243. package/src/components/filter/FilterInheritance.tsx +0 -162
  244. package/src/components/filter/FilterIntegerGq.tsx +0 -47
  245. package/src/components/filter/FilterVI.tsx +0 -68
  246. package/src/components/filter/FilterVariantType.tsx +0 -146
  247. package/src/components/filter/Filters.tsx +0 -29
  248. package/src/components/filter/InfoFilter.tsx +0 -39
  249. package/src/components/filter/InfoFilters.tsx +0 -35
  250. package/src/components/filter/SampleFilters.tsx +0 -93
  251. package/src/components/filter/SamplesFilters.tsx +0 -33
  252. package/src/components/record/Allele.tsx +0 -38
  253. package/src/components/record/AlleleBreakend.tsx +0 -5
  254. package/src/components/record/AlleleMissing.tsx +0 -5
  255. package/src/components/record/AlleleNucs.tsx +0 -49
  256. package/src/components/record/AlleleSymbolic.tsx +0 -5
  257. package/src/components/record/Alt.tsx +0 -17
  258. package/src/components/record/Chrom.tsx +0 -5
  259. package/src/components/record/Format.tsx +0 -40
  260. package/src/components/record/Info.tsx +0 -55
  261. package/src/components/record/Pos.tsx +0 -5
  262. package/src/components/record/Qual.tsx +0 -5
  263. package/src/components/record/RecordDownload.tsx +0 -66
  264. package/src/components/record/Ref.tsx +0 -6
  265. package/src/components/record/field/Field.tsx +0 -36
  266. package/src/components/record/field/FieldMultipleValue.tsx +0 -22
  267. package/src/components/record/field/FieldSingleValue.tsx +0 -35
  268. package/src/components/record/info/ClinVar.tsx +0 -81
  269. package/src/components/record/info/Consequence.tsx +0 -18
  270. package/src/components/record/info/Gene.tsx +0 -56
  271. package/src/components/record/info/GnomAD.tsx +0 -54
  272. package/src/components/record/info/Hpo.tsx +0 -52
  273. package/src/components/record/info/InheritanceModes.tsx +0 -22
  274. package/src/components/record/info/VipC.tsx +0 -23
  275. package/src/components/record/info/Vkgl.tsx +0 -42
  276. package/src/mocks/GRCh37/vcf/no_vep.vcf.blob +0 -61
  277. package/src/mocks/GRCh37/vcf/samples_0.vcf.blob +0 -93
  278. package/src/mocks/GRCh37/vcf/samples_1.vcf.blob +0 -93
  279. package/src/mocks/GRCh37/vcf/samples_100.vcf.blob +0 -93
  280. package/src/utils/ApiUtils.ts +0 -259
  281. package/src/utils/csqUtils.ts +0 -27
  282. package/src/utils/decisionTreeUtils.ts +0 -14
  283. package/src/utils/field.ts +0 -49
  284. package/src/utils/query.ts +0 -154
  285. package/src/utils/viewUtils.ts +0 -32
@@ -0,0 +1,301 @@
1
+ import { afterEach, describe, expect, test, vi } from "vitest";
2
+ import { createQueryFilterComposed } from "../../../src/utils/query/queryFilterComposed.ts";
3
+ import {
4
+ ConfigFilterAllelicImbalance,
5
+ ConfigFilterComposed,
6
+ ConfigFilterDeNovo,
7
+ ConfigFilterHpo,
8
+ ConfigFilterInheritanceMatch,
9
+ ConfigFilterLocus,
10
+ ConfigFilterVipC,
11
+ ConfigFilterVipCS,
12
+ FilterValueHpo,
13
+ FilterValueLocus,
14
+ FilterValueVipC,
15
+ FilterValueVipCS,
16
+ } from "../../../src/types/configFilterComposed";
17
+ import { Query } from "@molgenis/vip-report-api";
18
+ import {
19
+ createQueryFilterClosedInterval,
20
+ createQueryFilterClosedIntervalOutside,
21
+ createQueryFilterString,
22
+ } from "../../../src/utils/query/queryFilter.ts";
23
+ import { SampleContainer } from "../../../src/utils/api.ts";
24
+ import { createQueryFilterFieldCategorical } from "../../../src/utils/query/queryFilterField.ts";
25
+
26
+ describe("query composed filters", () => {
27
+ vi.mock(import("../../../src/utils/query/queryFilter.ts"));
28
+ vi.mock(import("../../../src/utils/query/queryFilterField.ts"));
29
+
30
+ afterEach(() => {
31
+ vi.resetAllMocks();
32
+ });
33
+
34
+ describe("createQueryFilterComposed", () => {
35
+ const query: Query = { selector: "x", operator: "==", args: "y" };
36
+
37
+ test("hpo", () => {
38
+ const field = { id: "f", number: {}, categories: {} };
39
+ const config = { type: "composed", id: "composed/hpo", field: field } as ConfigFilterHpo;
40
+ const value = ["chr1"] as FilterValueHpo;
41
+ vi.mocked(createQueryFilterFieldCategorical).mockReturnValue(query);
42
+ expect(createQueryFilterComposed(config, value)).toStrictEqual(query);
43
+ expect(createQueryFilterFieldCategorical).toHaveBeenCalledWith(["n", "f"], field, value);
44
+ });
45
+
46
+ describe("locus", () => {
47
+ const query: Query = { selector: "c", operator: "==", args: "chr1" };
48
+
49
+ test("locus chr+start+end", () => {
50
+ const queryPos: Query = { selector: "z", operator: "==", args: "y" };
51
+
52
+ const config = { type: "composed", id: "composed/locus" } as ConfigFilterLocus;
53
+ const value = { chromosome: "chr1", start: 1, end: 2 } as FilterValueLocus;
54
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
55
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryPos);
56
+ expect(createQueryFilterComposed(config, value)).toStrictEqual({
57
+ args: [query, queryPos],
58
+ operator: "and",
59
+ });
60
+ expect(createQueryFilterString).toHaveBeenCalledWith(["c"], ["chr1"], false, false);
61
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["p"], { left: 1, right: 2 });
62
+ });
63
+
64
+ test("locus chr+start", () => {
65
+ const queryPos: Query = { selector: "z", operator: "==", args: "y" };
66
+
67
+ const config = { type: "composed", id: "composed/locus" } as ConfigFilterLocus;
68
+ const value = { chromosome: "chr1", start: 1 } as FilterValueLocus;
69
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
70
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryPos);
71
+ expect(createQueryFilterComposed(config, value)).toStrictEqual({
72
+ args: [query, queryPos],
73
+ operator: "and",
74
+ });
75
+ expect(createQueryFilterString).toHaveBeenCalledWith(["c"], ["chr1"], false, false);
76
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["p"], { left: 1, right: undefined });
77
+ });
78
+
79
+ test("locus chr+end", () => {
80
+ const queryPos: Query = { selector: "z", operator: "==", args: "y" };
81
+
82
+ const config = { type: "composed", id: "composed/locus" } as ConfigFilterLocus;
83
+ const value = { chromosome: "chr1", end: 2 } as FilterValueLocus;
84
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
85
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryPos);
86
+ expect(createQueryFilterComposed(config, value)).toStrictEqual({
87
+ args: [query, queryPos],
88
+ operator: "and",
89
+ });
90
+ expect(createQueryFilterString).toHaveBeenCalledWith(["c"], ["chr1"], false, false);
91
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["p"], { left: undefined, right: 2 });
92
+ });
93
+
94
+ test("locus chr", () => {
95
+ const config = { type: "composed", id: "composed/locus" } as ConfigFilterLocus;
96
+ const value = { chromosome: "chr1" } as FilterValueLocus;
97
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
98
+ expect(createQueryFilterComposed(config, value)).toStrictEqual(query);
99
+ expect(createQueryFilterString).toHaveBeenCalledWith(["c"], ["chr1"], false, false);
100
+ });
101
+ });
102
+
103
+ describe("allelicImbalance", () => {
104
+ const config = {
105
+ type: "composed",
106
+ id: "composed/allelicImbalance",
107
+ sample: { item: { data: { index: 1 } } } as SampleContainer,
108
+ viabField: { id: "VIAB" },
109
+ genotypeField: { id: "GT" },
110
+ } as ConfigFilterAllelicImbalance;
111
+ const queryInterval: Query = { selector: "viab", operator: "==", args: "inside" };
112
+ const queryIntervalClosed: Query = { selector: "viab", operator: "==", args: "outside" };
113
+
114
+ const expectedTrueQuery = {
115
+ args: [
116
+ {
117
+ args: [
118
+ { selector: ["s", 1, "GT", "t"], operator: "in", args: ["hom_a", "hom_r"] },
119
+ { selector: "viab", operator: "==", args: "inside" },
120
+ ],
121
+ operator: "and",
122
+ },
123
+ {
124
+ args: [
125
+ { selector: ["s", 1, "GT", "t"], operator: "==", args: "het" },
126
+ { selector: "viab", operator: "==", args: "outside" },
127
+ ],
128
+ operator: "and",
129
+ },
130
+ ],
131
+ operator: "or",
132
+ };
133
+
134
+ test("true", () => {
135
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryInterval);
136
+ vi.mocked(createQueryFilterClosedIntervalOutside).mockReturnValue(queryIntervalClosed);
137
+ expect(createQueryFilterComposed(config, ["true"])).toStrictEqual(expectedTrueQuery);
138
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["s", 1, "VIAB"], { left: 0.02, right: 0.98 });
139
+ expect(createQueryFilterClosedIntervalOutside).toHaveBeenCalledWith(["s", 1, "VIAB"], {
140
+ left: 0.2,
141
+ right: 0.8,
142
+ });
143
+ });
144
+
145
+ const expectedFalseQuery = {
146
+ args: [
147
+ {
148
+ args: [
149
+ { selector: ["s", 1, "GT", "t"], operator: "in", args: ["hom_a", "hom_r"] },
150
+ { selector: "viab", operator: "==", args: "outside" },
151
+ ],
152
+ operator: "and",
153
+ },
154
+ {
155
+ args: [
156
+ { selector: ["s", 1, "GT", "t"], operator: "==", args: "het" },
157
+ { selector: "viab", operator: "==", args: "inside" },
158
+ ],
159
+ operator: "and",
160
+ },
161
+ ],
162
+ operator: "or",
163
+ };
164
+
165
+ test("false", () => {
166
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryInterval);
167
+ vi.mocked(createQueryFilterClosedIntervalOutside).mockReturnValue(queryIntervalClosed);
168
+ expect(createQueryFilterComposed(config, ["false"])).toStrictEqual(expectedFalseQuery);
169
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["s", 1, "VIAB"], {
170
+ left: 0.2,
171
+ right: 0.8,
172
+ });
173
+ expect(createQueryFilterClosedIntervalOutside).toHaveBeenCalledWith(["s", 1, "VIAB"], {
174
+ left: 0.02,
175
+ right: 0.98,
176
+ });
177
+ });
178
+
179
+ const expectedNullQuery = {
180
+ args: [
181
+ { selector: ["s", 1, "VIAB"], operator: "==", args: null },
182
+ { selector: ["s", 1, "VIAB"], operator: "==", args: undefined },
183
+ ],
184
+ operator: "or",
185
+ };
186
+
187
+ test("__null", () => {
188
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryInterval);
189
+ vi.mocked(createQueryFilterClosedIntervalOutside).mockReturnValue(queryIntervalClosed);
190
+ expect(createQueryFilterComposed(config, ["__null"])).toStrictEqual(expectedNullQuery);
191
+ });
192
+
193
+ test("mixed", () => {
194
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(queryInterval);
195
+ vi.mocked(createQueryFilterClosedIntervalOutside).mockReturnValue(queryIntervalClosed);
196
+
197
+ expect(createQueryFilterComposed(config, ["true", "__null"])).toStrictEqual({
198
+ args: [expectedTrueQuery, expectedNullQuery],
199
+ operator: "or",
200
+ });
201
+ });
202
+ });
203
+
204
+ describe("inheritanceMatch", () => {
205
+ const config = {
206
+ type: "composed",
207
+ id: "composed/inheritanceMatch",
208
+ sample: { item: { data: { index: 1 } } } as SampleContainer,
209
+ vimField: { id: "VIM" },
210
+ } as ConfigFilterInheritanceMatch;
211
+
212
+ test("true", () => {
213
+ expect(createQueryFilterComposed(config, ["true"])).toStrictEqual({
214
+ selector: ["s", 1, "VIM"],
215
+ operator: "==",
216
+ args: 1,
217
+ });
218
+ });
219
+
220
+ test("false", () => {
221
+ expect(createQueryFilterComposed(config, ["false"])).toStrictEqual({
222
+ selector: ["s", 1, "VIM"],
223
+ operator: "==",
224
+ args: 0,
225
+ });
226
+ });
227
+
228
+ test("potential", () => {
229
+ expect(createQueryFilterComposed(config, ["potential"])).toStrictEqual({
230
+ args: [
231
+ { selector: ["s", 1, "VIM"], operator: "==", args: null },
232
+ { selector: ["s", 1, "VIM"], operator: "==", args: undefined },
233
+ ],
234
+ operator: "or",
235
+ });
236
+ });
237
+ });
238
+
239
+ describe("deNovo", () => {
240
+ const config = {
241
+ type: "composed",
242
+ id: "composed/deNovo",
243
+ sample: { item: { data: { index: 1 } } } as SampleContainer,
244
+ vidField: { id: "VID" },
245
+ } as ConfigFilterDeNovo;
246
+
247
+ test("true", () => {
248
+ expect(createQueryFilterComposed(config, ["true"])).toStrictEqual({
249
+ selector: ["s", 1, "VID"],
250
+ operator: "==",
251
+ args: 1,
252
+ });
253
+ });
254
+
255
+ test("false", () => {
256
+ expect(createQueryFilterComposed(config, ["false"])).toStrictEqual({
257
+ selector: ["s", 1, "VID"],
258
+ operator: "==",
259
+ args: 0,
260
+ });
261
+ });
262
+
263
+ test("potential", () => {
264
+ expect(createQueryFilterComposed(config, ["potential"])).toStrictEqual({
265
+ args: [
266
+ { selector: ["s", 1, "VID"], operator: "==", args: null },
267
+ { selector: ["s", 1, "VID"], operator: "==", args: undefined },
268
+ ],
269
+ operator: "or",
270
+ });
271
+ });
272
+ });
273
+
274
+ test("vipC", () => {
275
+ const field = { id: "f", number: {}, categories: {} };
276
+ const config = { type: "composed", id: "composed/vipC", field: field } as ConfigFilterVipC;
277
+ const value = ["chr1"] as FilterValueVipC;
278
+ vi.mocked(createQueryFilterFieldCategorical).mockReturnValue(query);
279
+ expect(createQueryFilterComposed(config, value)).toStrictEqual(query);
280
+ expect(createQueryFilterFieldCategorical).toHaveBeenCalledWith(["n", "f"], field, value);
281
+ });
282
+
283
+ test("vipCS", () => {
284
+ const sample = { item: { data: { index: 1 } } } as SampleContainer;
285
+ const field = { id: "f", number: {}, categories: {} };
286
+ const config = { type: "composed", id: "composed/vipCS", field, sample } as ConfigFilterVipCS;
287
+ const value = ["chr1"] as FilterValueVipCS;
288
+ vi.mocked(createQueryFilterFieldCategorical).mockReturnValue(query);
289
+ expect(createQueryFilterComposed(config, value)).toStrictEqual(query);
290
+ expect(createQueryFilterFieldCategorical).toHaveBeenCalledWith(["s", 1, "f"], field, value);
291
+ });
292
+
293
+ test("invalid", () => {
294
+ const config = {
295
+ type: "composed",
296
+ id: "invalid",
297
+ } as ConfigFilterComposed;
298
+ expect(() => createQueryFilterComposed(config, ["value"])).toThrow();
299
+ });
300
+ });
301
+ });
@@ -0,0 +1,75 @@
1
+ import { afterEach, describe, expect, test, vi } from "vitest";
2
+ import { Query } from "@molgenis/vip-report-api";
3
+ import { createQueryFilterClosedInterval, createQueryFilterString } from "../../../src/utils/query/queryFilter.ts";
4
+ import { createQueryFilterField } from "../../../src/utils/query/queryFilterField.ts";
5
+ import { ConfigFilterField, ConfigFilterFormat } from "../../../src/types/configFilter";
6
+ import { FieldMetadata } from "@molgenis/vip-report-vcf";
7
+ import { SampleContainer } from "../../../src/utils/api.ts";
8
+
9
+ describe("query filter fixed", () => {
10
+ vi.mock(import("../../../src/utils/query/queryFilter.ts"));
11
+
12
+ afterEach(() => {
13
+ vi.resetAllMocks();
14
+ });
15
+
16
+ describe("createQueryFilterFixed", () => {
17
+ const query: Query = { selector: "x", operator: "==", args: "y" };
18
+
19
+ test("CATEGORICAL count=1 info", () => {
20
+ const categories = { cat: { label: "my_label" } };
21
+ const field = { id: "f", type: "CATEGORICAL", number: { type: "NUMBER", count: 1 }, categories } as FieldMetadata;
22
+ const config = { type: "info", id: "filter", field } as ConfigFilterField;
23
+ const value = ["x"];
24
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
25
+ expect(createQueryFilterField(config, value)).toStrictEqual(query);
26
+ expect(createQueryFilterString).toHaveBeenCalledWith(["n", "f"], value, false, false);
27
+ });
28
+
29
+ test("CHARACTER count=1 info", () => {
30
+ const field = { id: "f", type: "CHARACTER", number: { type: "NUMBER", count: 1 } } as FieldMetadata;
31
+ const config = { type: "info", id: "filter", field } as ConfigFilterField;
32
+ const value = ["x"];
33
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
34
+ expect(createQueryFilterField(config, value)).toStrictEqual(query);
35
+ expect(createQueryFilterString).toHaveBeenCalledWith(["n", "f"], value, false, false);
36
+ });
37
+
38
+ test("STRING count=* info nested", () => {
39
+ const field = { id: "c", parent: { id: "p" }, type: "STRING", number: { type: "OTHER" } } as FieldMetadata;
40
+ const config = { type: "info", id: "filter", field } as ConfigFilterField;
41
+ const value = ["x"];
42
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
43
+ expect(createQueryFilterField(config, value)).toStrictEqual(query);
44
+ expect(createQueryFilterString).toHaveBeenCalledWith(["n", "p", "c"], value, true, true);
45
+ });
46
+
47
+ test("STRING count=* genotype", () => {
48
+ const field = { id: "f", type: "STRING", number: { type: "OTHER" } } as FieldMetadata;
49
+ const sample = { item: { data: { index: 1 } } } as SampleContainer;
50
+ const config = { type: "genotype", id: "filter", field, sample } as ConfigFilterFormat;
51
+ const value = ["x"];
52
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
53
+ expect(createQueryFilterField(config, value)).toStrictEqual(query);
54
+ expect(createQueryFilterString).toHaveBeenCalledWith(["s", 1, "f"], value, true, false);
55
+ });
56
+
57
+ test("FLOAT count=1 info", () => {
58
+ const field = { id: "f", type: "FLOAT", number: { type: "NUMBER", count: 1 } } as FieldMetadata;
59
+ const config = { type: "info", id: "filter", field } as ConfigFilterField;
60
+ const value = { left: 1.23, right: 3.45 };
61
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(query);
62
+ expect(createQueryFilterField(config, value)).toStrictEqual(query);
63
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["n", "f"], value);
64
+ });
65
+
66
+ test("INTEGER count=1 info", () => {
67
+ const field = { id: "f", type: "INTEGER", number: { type: "NUMBER", count: 1 } } as FieldMetadata;
68
+ const config = { type: "info", id: "filter", field } as ConfigFilterField;
69
+ const value = { left: 1, right: 3 };
70
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(query);
71
+ expect(createQueryFilterField(config, value)).toStrictEqual(query);
72
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["n", "f"], value);
73
+ });
74
+ });
75
+ });
@@ -0,0 +1,86 @@
1
+ import { afterEach, describe, expect, test, vi } from "vitest";
2
+ import { createQueryFilterFixed } from "../../../src/utils/query/queryFilterFixed.ts";
3
+ import {
4
+ ConfigFilterAlt,
5
+ ConfigFilterChrom,
6
+ ConfigFilterFilter,
7
+ ConfigFilterId,
8
+ ConfigFilterPos,
9
+ ConfigFilterQual,
10
+ ConfigFilterRef,
11
+ } from "../../../src/types/configFilter";
12
+ import { createQueryFilterClosedInterval, createQueryFilterString } from "../../../src/utils/query/queryFilter.ts";
13
+ import { Query } from "@molgenis/vip-report-api";
14
+
15
+ describe("query filter fixed", () => {
16
+ vi.mock(import("../../../src/utils/query/queryFilter.ts"));
17
+
18
+ afterEach(() => {
19
+ vi.resetAllMocks();
20
+ });
21
+
22
+ describe("createQueryFilterFixed", () => {
23
+ const query: Query = { selector: "x", operator: "==", args: "y" };
24
+
25
+ test("chrom", () => {
26
+ const config = { type: "fixed", id: "fixed/chrom" } as ConfigFilterChrom;
27
+ const value = ["chr1"];
28
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
29
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
30
+ expect(createQueryFilterString).toHaveBeenCalledWith(["c"], value, false, false);
31
+ });
32
+
33
+ test("pos", () => {
34
+ const config = { type: "fixed", id: "fixed/pos" } as ConfigFilterPos;
35
+ const value = { left: 1, right: 2 };
36
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(query);
37
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
38
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["p"], value);
39
+ });
40
+
41
+ test("id", () => {
42
+ const config = { type: "fixed", id: "fixed/id" } as ConfigFilterId;
43
+ const value = ["id0"];
44
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
45
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
46
+ expect(createQueryFilterString).toHaveBeenCalledWith(["i"], value, true, false);
47
+ });
48
+
49
+ test("ref", () => {
50
+ const config = { type: "fixed", id: "fixed/ref" } as ConfigFilterRef;
51
+ const value = ["C"];
52
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
53
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
54
+ expect(createQueryFilterString).toHaveBeenCalledWith(["r"], value, false, false);
55
+ });
56
+
57
+ test("alt", () => {
58
+ const config = { type: "fixed", id: "fixed/alt" } as ConfigFilterAlt;
59
+ const value = ["C"];
60
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
61
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
62
+ expect(createQueryFilterString).toHaveBeenCalledWith(["a"], value, true, false);
63
+ });
64
+
65
+ test("qual", () => {
66
+ const config = { type: "fixed", id: "fixed/qual" } as ConfigFilterQual;
67
+ const value = { left: 1, right: 2 };
68
+ vi.mocked(createQueryFilterClosedInterval).mockReturnValue(query);
69
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
70
+ expect(createQueryFilterClosedInterval).toHaveBeenCalledWith(["q"], value);
71
+ });
72
+
73
+ test("id", () => {
74
+ const config = { type: "fixed", id: "fixed/filter" } as ConfigFilterFilter;
75
+ const value = ["filter0"];
76
+ vi.mocked(createQueryFilterString).mockReturnValue(query);
77
+ expect(createQueryFilterFixed(config, value)).toStrictEqual(query);
78
+ expect(createQueryFilterString).toHaveBeenCalledWith(["f"], value, true, false);
79
+ });
80
+
81
+ test("invalid", () => {
82
+ const config = { type: "fixed", id: "fixed/invalid" } as ConfigFilterFilter;
83
+ expect(() => createQueryFilterFixed(config, ["value"])).toThrow();
84
+ });
85
+ });
86
+ });
@@ -0,0 +1,45 @@
1
+ import { afterEach, describe, expect, test, vi } from "vitest";
2
+ import { createQuerySample } from "../../../src/utils/query/querySample.ts";
3
+ import { ConfigVip } from "../../../src/types/config";
4
+ import { SampleContainer } from "../../../src/utils/api.ts";
5
+ import { FieldMetadata } from "@molgenis/vip-report-vcf";
6
+ import { createQueryFilterFieldCategorical } from "../../../src/utils/query/queryFilterField.ts";
7
+ import { createSelectorSample } from "../../../src/utils/query/selector.ts";
8
+ import { Query } from "@molgenis/vip-report-api";
9
+
10
+ describe("query sample", () => {
11
+ vi.mock(import("../../../src/utils/query/selector.ts"));
12
+ vi.mock(import("../../../src/utils/query/queryFilterField.ts"));
13
+
14
+ afterEach(() => {
15
+ vi.resetAllMocks();
16
+ });
17
+
18
+ describe("createQuerySample", () => {
19
+ test("create", () => {
20
+ const filter_field = {
21
+ id: "FORMAT/VIPC_S",
22
+ type: "CATEGORICAL",
23
+ number: { type: "NUMBER", count: 1 },
24
+ categories: {},
25
+ } as FieldMetadata;
26
+ const classes = "VUS,LP,P";
27
+ const config = { filter_field, params: { vcf: { filter_samples: { classes } } } } as ConfigVip;
28
+ const sample = { item: { data: { index: 1 } } } as SampleContainer;
29
+
30
+ const selector = ["x"];
31
+ const query: Query = { selector, operator: "==", args: "y" };
32
+ vi.mocked(createSelectorSample).mockReturnValue(selector);
33
+ vi.mocked(createQueryFilterFieldCategorical).mockReturnValue(query);
34
+
35
+ expect(createQuerySample(config, sample)).toStrictEqual(query);
36
+ expect(createSelectorSample).toHaveBeenCalledWith(sample, filter_field);
37
+ expect(createQueryFilterFieldCategorical).toHaveBeenCalledWith(selector, filter_field, [
38
+ "VUS",
39
+ "LP",
40
+ "P",
41
+ "__null",
42
+ ]);
43
+ });
44
+ });
45
+ });
@@ -0,0 +1,56 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import { createQueryVariantType } from "../../../src/utils/query/queryVariantType.ts";
3
+ import { VariantType } from "../../../src/utils/variantType.ts";
4
+
5
+ describe("query variant type", () => {
6
+ describe("createQueryVariantType", () => {
7
+ test("all", () => {
8
+ const variantType = { id: "all" } as VariantType;
9
+ expect(createQueryVariantType(variantType)).toStrictEqual(null);
10
+ });
11
+
12
+ test("snv", () => {
13
+ const variantType = { id: "snv" } as VariantType;
14
+ expect(createQueryVariantType(variantType)).toStrictEqual({
15
+ args: [
16
+ {
17
+ args: null,
18
+ operator: "==",
19
+ selector: ["n", "SVTYPE"],
20
+ },
21
+ { args: undefined, operator: "==", selector: ["n", "SVTYPE"] },
22
+ ],
23
+ operator: "or",
24
+ });
25
+ });
26
+
27
+ test("str", () => {
28
+ const variantType = { id: "str" } as VariantType;
29
+ expect(createQueryVariantType(variantType)).toStrictEqual({
30
+ args: "STR",
31
+ operator: "==",
32
+ selector: ["n", "SVTYPE"],
33
+ });
34
+ });
35
+
36
+ test("sv", () => {
37
+ const variantType = { id: "sv" } as VariantType;
38
+ expect(createQueryVariantType(variantType)).toStrictEqual({
39
+ args: [
40
+ {
41
+ args: "STR",
42
+ operator: "!=",
43
+ selector: ["n", "SVTYPE"],
44
+ },
45
+ { args: null, operator: "!=", selector: ["n", "SVTYPE"] },
46
+ {
47
+ args: undefined,
48
+ operator: "!=",
49
+ selector: ["n", "SVTYPE"],
50
+ },
51
+ ],
52
+ operator: "and",
53
+ });
54
+ });
55
+ });
56
+ });
@@ -1,7 +1,6 @@
1
1
  import { describe, expect, test } from "vitest";
2
- import { createRecordSort, DIRECTION_ASCENDING } from "../utils/sortUtils";
3
- import { FieldMetadata } from "@molgenis/vip-report-vcf/src/MetadataParser";
4
- import { Metadata } from "@molgenis/vip-report-vcf/src/Vcf";
2
+ import { createRecordSort, DIRECTION_ASCENDING } from "../../../src/utils/query/sort.ts";
3
+ import { FieldMetadata, VcfMetadata } from "@molgenis/vip-report-vcf";
5
4
 
6
5
  describe("sort utilities", () => {
7
6
  const nString0Meta: FieldMetadata = {
@@ -47,7 +46,7 @@ describe("sort utilities", () => {
47
46
  nString2Meta.parent = nObject0Meta;
48
47
  nObject0Meta.nested?.items.push(nString1Meta, nString2Meta);
49
48
 
50
- const metadata: Metadata = {
49
+ const metadata: VcfMetadata = {
51
50
  lines: [],
52
51
  info: { n_string0: nString0Meta, n_object0: nObject0Meta },
53
52
  format: {},