@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.
- package/.nvmrc +1 -1
- package/.travis.yml +9 -11
- package/README.md +411 -1
- package/eslint.config.mjs +11 -0
- package/package.json +40 -35
- package/scripts/deploy_npm_registry.sh +5 -0
- package/src/App.tsx +35 -29
- package/src/assets/sass/main.scss +12 -4
- package/src/components/Allele.tsx +95 -0
- package/src/components/Anchor.tsx +1 -1
- package/src/components/Breadcrumb.tsx +8 -5
- package/src/components/DatasetDropdown.tsx +10 -23
- package/src/components/ErrorNotification.tsx +9 -0
- package/src/components/GenomeBrowser.tsx +40 -23
- package/src/components/HpoTerm.tsx +1 -1
- package/src/components/{record/Pager.tsx → Pager.tsx} +21 -14
- package/src/components/RecordsPerPage.tsx +9 -7
- package/src/components/RecordsTable.tsx +130 -0
- package/src/components/SampleTable.tsx +70 -98
- package/src/components/SearchBox.tsx +8 -2
- package/src/components/Sort.tsx +28 -25
- package/src/components/Table.tsx +16 -0
- package/src/components/Tooltip.tsx +20 -0
- package/src/components/VariantBreadcrumb.tsx +54 -0
- package/src/components/VariantConsequenceContainer.tsx +100 -0
- package/src/components/VariantConsequenceTable.tsx +58 -0
- package/src/components/VariantContainer.tsx +71 -0
- package/src/components/VariantFilters.tsx +27 -0
- package/src/components/VariantGenotypeTable.tsx +44 -0
- package/src/components/VariantInfoTable.tsx +24 -33
- package/src/components/VariantResults.tsx +103 -0
- package/src/components/VariantTable.tsx +62 -66
- package/src/components/VariantTypeSelect.tsx +34 -0
- package/src/components/VariantsContainer.tsx +150 -0
- package/src/components/VariantsContainerHeader.tsx +70 -0
- package/src/components/field/Field.tsx +80 -0
- package/src/components/field/FieldAlt.tsx +19 -0
- package/src/components/field/FieldChrom.tsx +6 -0
- package/src/components/{record/Id.tsx → field/FieldFilter.tsx} +2 -1
- package/src/components/field/FieldFormat.tsx +10 -0
- package/src/components/{record/Filter.tsx → field/FieldId.tsx} +1 -1
- package/src/components/field/FieldPos.tsx +6 -0
- package/src/components/field/FieldQual.tsx +6 -0
- package/src/components/field/FieldRef.tsx +8 -0
- package/src/components/field/composed/FieldClinVar.tsx +72 -0
- package/src/components/field/composed/FieldComposed.tsx +68 -0
- package/src/components/field/composed/FieldGene.tsx +39 -0
- package/src/components/field/composed/FieldGenotype.tsx +35 -0
- package/src/components/{record/format/GenotypeField.tsx → field/composed/FieldGenotypeSnvSv.tsx} +20 -16
- package/src/components/field/composed/FieldGenotypeStr.tsx +31 -0
- package/src/components/field/composed/FieldGnomAd.tsx +58 -0
- package/src/components/field/composed/FieldHpo.tsx +50 -0
- package/src/components/field/composed/FieldInheritanceModes.tsx +32 -0
- package/src/components/field/composed/FieldLocus.tsx +18 -0
- package/src/components/field/composed/FieldVipC.tsx +25 -0
- package/src/components/field/composed/FieldVipCS.tsx +15 -0
- package/src/components/field/composed/FieldVkgl.tsx +37 -0
- package/src/components/field/genotype/FieldGenotype.tsx +19 -0
- package/src/components/field/genotype/FieldGenotypeType.tsx +9 -0
- package/src/components/field/info/FieldConsequence.tsx +15 -0
- package/src/components/{record/info/Hgvs.tsx → field/info/FieldHgvs.tsx} +4 -6
- package/src/components/field/info/FieldInfo.tsx +27 -0
- package/src/components/{record/info/PubMed.tsx → field/info/FieldPubMed.tsx} +4 -7
- package/src/components/field/typed/FieldCategorical.tsx +17 -0
- package/src/components/{record/field/FieldValueCharacter.tsx → field/typed/FieldCharacter.tsx} +3 -2
- package/src/components/{record/field/FieldValueFlag.tsx → field/typed/FieldFlag.tsx} +3 -2
- package/src/components/{record/field/FieldValueFloat.tsx → field/typed/FieldFloat.tsx} +3 -2
- package/src/components/{record/field/FieldValueInteger.tsx → field/typed/FieldInteger.tsx} +3 -2
- package/src/components/{record/field/FieldValueString.tsx → field/typed/FieldString.tsx} +3 -2
- package/src/components/field/typed/FieldTyped.tsx +20 -0
- package/src/components/field/typed/FieldTypedItem.tsx +49 -0
- package/src/components/field/typed/FieldTypedMultiple.tsx +21 -0
- package/src/components/filter/Filter.tsx +56 -48
- package/src/components/filter/FilterWrapper.scss +23 -0
- package/src/components/filter/FilterWrapper.tsx +63 -0
- package/src/components/filter/composed/FilterAllelicImbalance.tsx +26 -0
- package/src/components/filter/composed/FilterComposed.tsx +92 -0
- package/src/components/filter/composed/FilterDeNovo.tsx +35 -0
- package/src/components/filter/composed/FilterHpo.tsx +16 -0
- package/src/components/filter/composed/FilterInheritance.tsx +42 -0
- package/src/components/filter/composed/FilterLocus.tsx +75 -0
- package/src/components/filter/composed/FilterVipC.tsx +16 -0
- package/src/components/filter/composed/FilterVipCS.tsx +16 -0
- package/src/components/filter/fixed/FilterAlt.tsx +20 -0
- package/src/components/filter/fixed/FilterChrom.tsx +22 -0
- package/src/components/filter/fixed/FilterFilter.tsx +20 -0
- package/src/components/filter/fixed/FilterFixed.tsx +96 -0
- package/src/components/filter/fixed/FilterId.tsx +20 -0
- package/src/components/filter/fixed/FilterPos.tsx +22 -0
- package/src/components/filter/fixed/FilterQual.tsx +21 -0
- package/src/components/filter/fixed/FilterRef.tsx +22 -0
- package/src/components/filter/typed/FilterCategorical.tsx +119 -0
- package/src/components/filter/typed/FilterFlag.tsx +23 -0
- package/src/components/filter/typed/FilterInterval.tsx +72 -0
- package/src/components/filter/typed/FilterString.tsx +43 -0
- package/src/components/filter/typed/FilterTyped.tsx +56 -0
- package/src/components/form/ButtonApply.tsx +11 -0
- package/src/components/form/ButtonDownload.tsx +11 -0
- package/src/components/form/ButtonReset.tsx +9 -0
- package/src/components/{Checkbox.tsx → form/Checkbox.tsx} +4 -9
- package/src/components/form/Input.tsx +19 -0
- package/src/components/form/Select.scss +7 -0
- package/src/components/form/Select.tsx +34 -0
- package/src/components/tree/DecisionTreeBoolMultiQuery.tsx +1 -1
- package/src/components/tree/DecisionTreeBoolQuery.tsx +1 -1
- package/src/components/tree/DecisionTreeNode.tsx +41 -39
- package/src/components/tree/DecisionTreeNodeBool.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeBoolMulti.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeCategorical.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeExists.tsx +1 -1
- package/src/components/tree/DecisionTreeNodeLeaf.tsx +1 -1
- package/src/components/tree/DecisionTreeOutcomeNode.tsx +1 -1
- package/src/components/tree/DecisionTreePath.tsx +1 -1
- package/src/igv.d.ts +2 -1
- package/src/index.tsx +48 -19
- package/src/mocks/GRCh37/decisionTree.json +23 -22
- package/src/mocks/GRCh37/field_metadata.json +435 -95
- package/src/mocks/GRCh37/sampleTree.json +143 -0
- package/src/mocks/GRCh37/static.ts +63 -133
- package/src/mocks/GRCh37/vcf/family.vcf.blob +37 -31
- package/src/mocks/GRCh38/decisionTree.json +52 -33
- package/src/mocks/GRCh38/decisionTreeStr.json +572 -0
- package/src/mocks/GRCh38/fasta/chr1_149380406-149403321.fasta.gz.blob +0 -0
- package/src/mocks/GRCh38/field_metadata.json +435 -95
- package/src/mocks/GRCh38/sampleTree.json +175 -0
- package/src/mocks/GRCh38/static.ts +101 -42
- package/src/mocks/GRCh38/str.cram.blob +0 -0
- package/src/mocks/GRCh38/str.cram.crai.blob +0 -0
- package/src/mocks/GRCh38/vcf/family.vcf.blob +25 -24
- package/src/mocks/GRCh38/vcf/no_vep.vcf.blob +29 -28
- package/src/mocks/GRCh38/vcf/samples_0.vcf.blob +28 -27
- package/src/mocks/GRCh38/vcf/samples_1.vcf.blob +29 -28
- package/src/mocks/GRCh38/vcf/samples_100.vcf.blob +28 -27
- package/src/mocks/GRCh38/vcf/str.vcf.blob +321 -0
- package/src/mocks/MockApiClient.ts +341 -328
- package/src/mocks/config_cram.json +701 -0
- package/src/mocks/config_vcf.json +699 -0
- package/src/store/app.ts +30 -0
- package/src/store/index.tsx +3 -168
- package/src/store/variants.ts +182 -0
- package/src/types/config.d.ts +190 -0
- package/src/types/configCellComposed.d.ts +86 -0
- package/src/types/configCells.d.ts +129 -0
- package/src/types/configFilter.d.ts +80 -0
- package/src/types/configFilterComposed.d.ts +60 -0
- package/src/types/configSort.d.ts +13 -0
- package/src/types/filter.d.ts +17 -0
- package/src/types/store.d.ts +34 -0
- package/src/utils/api.ts +281 -0
- package/src/utils/config/config.ts +182 -0
- package/src/utils/config/configCells.ts +74 -0
- package/src/utils/config/configCellsComposed.ts +508 -0
- package/src/utils/config/configCellsField.ts +61 -0
- package/src/utils/config/configCellsFixed.ts +126 -0
- package/src/utils/config/configFilters.ts +46 -0
- package/src/utils/config/configFiltersComposed.ts +208 -0
- package/src/utils/config/configFiltersField.ts +49 -0
- package/src/utils/config/configFiltersFixed.ts +106 -0
- package/src/utils/config/configSorts.ts +44 -0
- package/src/utils/config/configValidator.ts +380 -0
- package/src/utils/config/configVip.ts +25 -0
- package/src/utils/csq.ts +115 -0
- package/src/utils/decisionTree.ts +45 -0
- package/src/utils/download.ts +30 -0
- package/src/utils/error.ts +69 -0
- package/src/utils/query/query.ts +55 -0
- package/src/utils/query/queryFilter.ts +132 -0
- package/src/utils/query/queryFilterComposed.ts +247 -0
- package/src/utils/query/queryFilterField.ts +75 -0
- package/src/utils/query/queryFilterFixed.ts +44 -0
- package/src/utils/query/querySample.ts +18 -0
- package/src/utils/query/queryVariantType.ts +76 -0
- package/src/utils/query/selector.ts +41 -0
- package/src/utils/{sortUtils.ts → query/sort.ts} +32 -11
- package/src/utils/sample.ts +19 -35
- package/src/utils/utils.ts +66 -2
- package/src/utils/variantType.ts +43 -0
- package/src/utils/vcf.ts +352 -0
- package/src/views/Help.tsx +109 -114
- package/src/views/Home.tsx +3 -2
- package/src/views/Sample.tsx +12 -7
- package/src/views/SampleVariant.tsx +23 -112
- package/src/views/SampleVariantConsequence.tsx +54 -114
- package/src/views/SampleVariants.tsx +33 -445
- package/src/views/SampleVariantsRedirect.tsx +20 -0
- package/src/views/Samples.tsx +7 -10
- package/src/views/Variant.tsx +31 -61
- package/src/views/VariantConsequence.tsx +42 -72
- package/src/views/Variants.tsx +29 -138
- package/src/views/VariantsRedirect.tsx +25 -0
- package/src/views/data/data.tsx +32 -6
- package/tests/store/variants.test.ts +122 -0
- package/tests/utils/config/config.test.ts +167 -0
- package/tests/utils/config/configCells.test.ts +86 -0
- package/tests/utils/config/configCellsComposed.test.ts +1163 -0
- package/tests/utils/config/configCellsField.test.ts +164 -0
- package/tests/utils/config/configCellsFixed.test.ts +99 -0
- package/tests/utils/config/configFilters.test.ts +80 -0
- package/tests/utils/config/configFiltersComposed.test.ts +504 -0
- package/tests/utils/config/configFiltersField.test.ts +140 -0
- package/tests/utils/config/configFiltersFixed.test.ts +81 -0
- package/tests/utils/config/configSorts.test.ts +55 -0
- package/tests/utils/config/configValidator.test.ts +56 -0
- package/tests/utils/config/configVip.test.ts +53 -0
- package/tests/utils/decisionTree.test.ts +71 -0
- package/tests/utils/download.test.ts +20 -0
- package/tests/utils/query/query.test.ts +84 -0
- package/tests/utils/query/queryFilter.test.ts +243 -0
- package/tests/utils/query/queryFilterComposed.test.ts +301 -0
- package/tests/utils/query/queryFilterField.test.ts +75 -0
- package/tests/utils/query/queryFilterFixed.test.ts +86 -0
- package/tests/utils/query/querySample.test.ts +45 -0
- package/tests/utils/query/queryVariantType.test.ts +56 -0
- package/{src/__tests__/sortUtils.test.ts → tests/utils/query/sort.test.ts} +3 -4
- package/tests/utils/sample.test.ts +259 -0
- package/tests/utils/utils.test.ts +120 -0
- package/tests/utils/variantType.test.ts +48 -0
- package/tests/utils/vcf.test.ts +649 -0
- package/tsconfig.json +6 -2
- package/vite.config.mts +20 -3
- package/.eslintignore +0 -4
- package/.eslintrc.js +0 -23
- package/src/Api.ts +0 -12
- package/src/__tests__/decisionTreeUtils.test.ts +0 -75
- package/src/__tests__/field.test.ts +0 -107
- package/src/__tests__/query.test.ts +0 -188
- package/src/__tests__/sample.test.ts +0 -184
- package/src/__tests__/utils.test.ts +0 -24
- package/src/__tests__/viewUtils.test.ts +0 -125
- package/src/components/ConsequenceTable.tsx +0 -45
- package/src/components/Error.tsx +0 -9
- package/src/components/FieldHeader.tsx +0 -26
- package/src/components/InfoCollapsablePane.tsx +0 -90
- package/src/components/VariantInfoNestedTable.tsx +0 -127
- package/src/components/VariantSampleTable.tsx +0 -58
- package/src/components/VariantsSampleTable.tsx +0 -183
- package/src/components/VariantsTable.tsx +0 -124
- package/src/components/filter/FilterAllelicBalance.tsx +0 -81
- package/src/components/filter/FilterCategorical.tsx +0 -81
- package/src/components/filter/FilterClinVar.tsx +0 -21
- package/src/components/filter/FilterGene.tsx +0 -34
- package/src/components/filter/FilterHpo.tsx +0 -161
- package/src/components/filter/FilterInheritance.tsx +0 -162
- package/src/components/filter/FilterIntegerGq.tsx +0 -47
- package/src/components/filter/FilterVI.tsx +0 -68
- package/src/components/filter/FilterVariantType.tsx +0 -146
- package/src/components/filter/Filters.tsx +0 -29
- package/src/components/filter/InfoFilter.tsx +0 -39
- package/src/components/filter/InfoFilters.tsx +0 -35
- package/src/components/filter/SampleFilters.tsx +0 -93
- package/src/components/filter/SamplesFilters.tsx +0 -33
- package/src/components/record/Allele.tsx +0 -38
- package/src/components/record/AlleleBreakend.tsx +0 -5
- package/src/components/record/AlleleMissing.tsx +0 -5
- package/src/components/record/AlleleNucs.tsx +0 -49
- package/src/components/record/AlleleSymbolic.tsx +0 -5
- package/src/components/record/Alt.tsx +0 -17
- package/src/components/record/Chrom.tsx +0 -5
- package/src/components/record/Format.tsx +0 -40
- package/src/components/record/Info.tsx +0 -55
- package/src/components/record/Pos.tsx +0 -5
- package/src/components/record/Qual.tsx +0 -5
- package/src/components/record/RecordDownload.tsx +0 -66
- package/src/components/record/Ref.tsx +0 -6
- package/src/components/record/field/Field.tsx +0 -36
- package/src/components/record/field/FieldMultipleValue.tsx +0 -22
- package/src/components/record/field/FieldSingleValue.tsx +0 -35
- package/src/components/record/info/ClinVar.tsx +0 -81
- package/src/components/record/info/Consequence.tsx +0 -18
- package/src/components/record/info/Gene.tsx +0 -56
- package/src/components/record/info/GnomAD.tsx +0 -54
- package/src/components/record/info/Hpo.tsx +0 -52
- package/src/components/record/info/InheritanceModes.tsx +0 -22
- package/src/components/record/info/VipC.tsx +0 -23
- package/src/components/record/info/Vkgl.tsx +0 -42
- package/src/mocks/GRCh37/vcf/no_vep.vcf.blob +0 -61
- package/src/mocks/GRCh37/vcf/samples_0.vcf.blob +0 -93
- package/src/mocks/GRCh37/vcf/samples_1.vcf.blob +0 -93
- package/src/mocks/GRCh37/vcf/samples_100.vcf.blob +0 -93
- package/src/utils/ApiUtils.ts +0 -259
- package/src/utils/csqUtils.ts +0 -27
- package/src/utils/decisionTreeUtils.ts +0 -14
- package/src/utils/field.ts +0 -49
- package/src/utils/query.ts +0 -154
- package/src/utils/viewUtils.ts +0 -32
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { SampleContainer, VcfMetadataContainer } from "../../../src/utils/api.ts";
|
|
3
|
+
import { Item } from "@molgenis/vip-report-api";
|
|
4
|
+
import { VcfRecord } from "@molgenis/vip-report-vcf";
|
|
5
|
+
import { initConfigCellGenotype, initConfigCellInfo } from "../../../src/utils/config/configCellsField.ts";
|
|
6
|
+
import {
|
|
7
|
+
FieldMetadataWrapper,
|
|
8
|
+
getInfoFieldsRegex,
|
|
9
|
+
getInfoValue,
|
|
10
|
+
getInfoValueCount,
|
|
11
|
+
getSampleFieldsRegex,
|
|
12
|
+
getSampleValue,
|
|
13
|
+
getSampleValueCount,
|
|
14
|
+
} from "../../../src/utils/vcf.ts";
|
|
15
|
+
import { ConfigJsonFieldGenotype, ConfigJsonFieldInfo } from "../../../src/types/config";
|
|
16
|
+
|
|
17
|
+
describe("config cells field", () => {
|
|
18
|
+
vi.mock(import("../../../src/utils/vcf.ts"));
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
vi.resetAllMocks();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("initConfigCellInfo", () => {
|
|
25
|
+
const metadata = {} as VcfMetadataContainer;
|
|
26
|
+
const record = { id: 0, data: { c: "chr1", p: 123, r: "A", a: ["C", "T"] } } as Item<VcfRecord>;
|
|
27
|
+
|
|
28
|
+
test("config matches one field", () => {
|
|
29
|
+
const config: ConfigJsonFieldInfo = {
|
|
30
|
+
type: "info",
|
|
31
|
+
name: "field",
|
|
32
|
+
label: "my_field_label",
|
|
33
|
+
description: "my_field_description",
|
|
34
|
+
};
|
|
35
|
+
const field = {
|
|
36
|
+
id: "INFO/field",
|
|
37
|
+
label: "field_label",
|
|
38
|
+
description: "field_description",
|
|
39
|
+
} as FieldMetadataWrapper;
|
|
40
|
+
vi.mocked(getInfoFieldsRegex).mockReturnValue([field]);
|
|
41
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
42
|
+
vi.mocked(getInfoValue).mockReturnValue(0);
|
|
43
|
+
|
|
44
|
+
const cells = initConfigCellInfo(config, metadata);
|
|
45
|
+
expect(cells.length).toStrictEqual(1);
|
|
46
|
+
const cell = cells[0]!;
|
|
47
|
+
expect(cell.type).toStrictEqual("info");
|
|
48
|
+
expect(cell.field).toStrictEqual(field);
|
|
49
|
+
expect(cell.label()).toStrictEqual("my_field_label");
|
|
50
|
+
expect(cell.description()).toStrictEqual("my_field_description");
|
|
51
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
52
|
+
expect(cell.value(record, 1)).toStrictEqual(0);
|
|
53
|
+
|
|
54
|
+
expect(getInfoFieldsRegex).toHaveBeenCalledWith(metadata, /^field$/);
|
|
55
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, field);
|
|
56
|
+
expect(getInfoValue).toHaveBeenCalledWith(record, 1, field);
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test("config matches multiple fields", () => {
|
|
60
|
+
const config: ConfigJsonFieldInfo = {
|
|
61
|
+
type: "info",
|
|
62
|
+
name: "VIP/.*",
|
|
63
|
+
};
|
|
64
|
+
const fieldVip = {
|
|
65
|
+
id: "INFO/VIP",
|
|
66
|
+
nested: {},
|
|
67
|
+
} as FieldMetadataWrapper;
|
|
68
|
+
const fieldVipField0 = {
|
|
69
|
+
id: "INFO/VIP/field0",
|
|
70
|
+
} as FieldMetadataWrapper;
|
|
71
|
+
const fieldVipField1 = {
|
|
72
|
+
id: "INFO/VIP/field1",
|
|
73
|
+
} as FieldMetadataWrapper;
|
|
74
|
+
vi.mocked(getInfoFieldsRegex).mockReturnValue([fieldVip, fieldVipField0, fieldVipField1]);
|
|
75
|
+
|
|
76
|
+
const cells = initConfigCellInfo(config, metadata);
|
|
77
|
+
expect(cells.length).toStrictEqual(2); // drop nested fields
|
|
78
|
+
expect(getInfoFieldsRegex).toHaveBeenCalledWith(metadata, /^VIP\/.*$/);
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
test("config matches zero fields", () => {
|
|
82
|
+
const config: ConfigJsonFieldInfo = {
|
|
83
|
+
type: "info",
|
|
84
|
+
name: "field_not_in_my_vcf",
|
|
85
|
+
};
|
|
86
|
+
vi.mocked(getInfoFieldsRegex).mockReturnValue([]);
|
|
87
|
+
|
|
88
|
+
const cells = initConfigCellInfo(config, metadata);
|
|
89
|
+
expect(cells.length).toStrictEqual(0);
|
|
90
|
+
expect(getInfoFieldsRegex).toHaveBeenCalledWith(metadata, /^field_not_in_my_vcf$/);
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
describe("initConfigCellGenotype", () => {
|
|
95
|
+
const metadata = {} as VcfMetadataContainer;
|
|
96
|
+
const sample = { item: { id: 2 } } as SampleContainer;
|
|
97
|
+
const record = { id: 0, data: { c: "chr1", p: 123, r: "A", a: ["C", "T"] } } as Item<VcfRecord>;
|
|
98
|
+
|
|
99
|
+
test("config matches one field", () => {
|
|
100
|
+
const config: ConfigJsonFieldGenotype = {
|
|
101
|
+
type: "genotype",
|
|
102
|
+
name: "field",
|
|
103
|
+
label: "my_field_label",
|
|
104
|
+
description: "my_field_description",
|
|
105
|
+
};
|
|
106
|
+
const field = {
|
|
107
|
+
id: "FORMAT/field",
|
|
108
|
+
label: "field_label",
|
|
109
|
+
description: "field_description",
|
|
110
|
+
} as FieldMetadataWrapper;
|
|
111
|
+
vi.mocked(getSampleFieldsRegex).mockReturnValue([field]);
|
|
112
|
+
vi.mocked(getSampleValueCount).mockReturnValue(1);
|
|
113
|
+
vi.mocked(getSampleValue).mockReturnValue(0);
|
|
114
|
+
|
|
115
|
+
const cells = initConfigCellGenotype(config, metadata, sample);
|
|
116
|
+
expect(cells.length).toStrictEqual(1);
|
|
117
|
+
const cell = cells[0]!;
|
|
118
|
+
expect(cell.type).toStrictEqual("genotype");
|
|
119
|
+
expect(cell.field).toStrictEqual(field);
|
|
120
|
+
expect(cell.label()).toStrictEqual("my_field_label");
|
|
121
|
+
expect(cell.description()).toStrictEqual("my_field_description");
|
|
122
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
123
|
+
expect(cell.value(record, 1)).toStrictEqual(0);
|
|
124
|
+
|
|
125
|
+
expect(getSampleFieldsRegex).toHaveBeenCalledWith(metadata, /^field$/);
|
|
126
|
+
expect(getSampleValueCount).toHaveBeenCalledWith(sample, record, field);
|
|
127
|
+
expect(getSampleValue).toHaveBeenCalledWith(sample, record, 1, field);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("config matches multiple fields", () => {
|
|
131
|
+
const config: ConfigJsonFieldGenotype = {
|
|
132
|
+
type: "genotype",
|
|
133
|
+
name: "VIP/.*",
|
|
134
|
+
};
|
|
135
|
+
const fieldVip = {
|
|
136
|
+
id: "FORMAT/VIP",
|
|
137
|
+
nested: {},
|
|
138
|
+
} as FieldMetadataWrapper;
|
|
139
|
+
const fieldVipField0 = {
|
|
140
|
+
id: "FORMAT/VIP/field0",
|
|
141
|
+
} as FieldMetadataWrapper;
|
|
142
|
+
const fieldVipField1 = {
|
|
143
|
+
id: "FORMAT/VIP/field1",
|
|
144
|
+
} as FieldMetadataWrapper;
|
|
145
|
+
vi.mocked(getSampleFieldsRegex).mockReturnValue([fieldVip, fieldVipField0, fieldVipField1]);
|
|
146
|
+
|
|
147
|
+
const cells = initConfigCellGenotype(config, metadata, sample);
|
|
148
|
+
expect(cells.length).toStrictEqual(2); // drop nested fields
|
|
149
|
+
expect(getSampleFieldsRegex).toHaveBeenCalledWith(metadata, /^VIP\/.*$/);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test("config matches zero fields", () => {
|
|
153
|
+
const config: ConfigJsonFieldGenotype = {
|
|
154
|
+
type: "genotype",
|
|
155
|
+
name: "field_not_in_my_vcf",
|
|
156
|
+
};
|
|
157
|
+
vi.mocked(getSampleFieldsRegex).mockReturnValue([]);
|
|
158
|
+
|
|
159
|
+
const cells = initConfigCellGenotype(config, metadata, sample);
|
|
160
|
+
expect(cells.length).toStrictEqual(0);
|
|
161
|
+
expect(getSampleFieldsRegex).toHaveBeenCalledWith(metadata, /^field_not_in_my_vcf$/);
|
|
162
|
+
});
|
|
163
|
+
});
|
|
164
|
+
});
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { initConfigCellFixed } from "../../../src/utils/config/configCellsFixed.ts";
|
|
3
|
+
import { Item } from "@molgenis/vip-report-api";
|
|
4
|
+
import { VcfRecord } from "@molgenis/vip-report-vcf";
|
|
5
|
+
|
|
6
|
+
describe("config cells fixed", () => {
|
|
7
|
+
describe("initConfigCellFixed", () => {
|
|
8
|
+
test("chrom", () => {
|
|
9
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "chrom" });
|
|
10
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { c: "chr1" } };
|
|
11
|
+
|
|
12
|
+
expect(cell.type).toStrictEqual("chrom");
|
|
13
|
+
expect(cell.label()).toStrictEqual("Chromosome");
|
|
14
|
+
expect(cell.description()).toStrictEqual(null);
|
|
15
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual("chr1");
|
|
16
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
test("pos", () => {
|
|
20
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "pos" });
|
|
21
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { p: 1 } };
|
|
22
|
+
|
|
23
|
+
expect(cell.type).toStrictEqual("pos");
|
|
24
|
+
expect(cell.label()).toStrictEqual("Position");
|
|
25
|
+
expect(cell.description()).toStrictEqual(null);
|
|
26
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual(1);
|
|
27
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test("id", () => {
|
|
31
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "id" });
|
|
32
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { i: ["id0", "id1"] } };
|
|
33
|
+
|
|
34
|
+
expect(cell.type).toStrictEqual("id");
|
|
35
|
+
expect(cell.label()).toStrictEqual("Ids");
|
|
36
|
+
expect(cell.description()).toStrictEqual(null);
|
|
37
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual(["id0", "id1"]);
|
|
38
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("ref", () => {
|
|
42
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "ref" });
|
|
43
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { r: "A" } };
|
|
44
|
+
|
|
45
|
+
expect(cell.type).toStrictEqual("ref");
|
|
46
|
+
expect(cell.label()).toStrictEqual("Reference");
|
|
47
|
+
expect(cell.description()).toStrictEqual("Reference base(s)");
|
|
48
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual("A");
|
|
49
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("alt", () => {
|
|
53
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "alt" });
|
|
54
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { a: ["C", "T"] } };
|
|
55
|
+
|
|
56
|
+
expect(cell.type).toStrictEqual("alt");
|
|
57
|
+
expect(cell.label()).toStrictEqual("Alternate(s)");
|
|
58
|
+
expect(cell.description()).toStrictEqual("Alternate base(s): list of alternate non-reference alleles");
|
|
59
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual(["C", "T"]);
|
|
60
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("qual", () => {
|
|
64
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "qual" });
|
|
65
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { q: 123 } };
|
|
66
|
+
|
|
67
|
+
expect(cell.type).toStrictEqual("qual");
|
|
68
|
+
expect(cell.label()).toStrictEqual("Qual");
|
|
69
|
+
expect(cell.description()).toStrictEqual("Quality: phred-scaled quality score for the 'Alt' assertions");
|
|
70
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual(123);
|
|
71
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
test("filter", () => {
|
|
75
|
+
const cell = initConfigCellFixed({ type: "fixed", name: "filter" });
|
|
76
|
+
const record: Partial<Item<Partial<VcfRecord>>> = { data: { f: ["PASS"] } };
|
|
77
|
+
|
|
78
|
+
expect(cell.type).toStrictEqual("filter");
|
|
79
|
+
expect(cell.label()).toStrictEqual("Filters");
|
|
80
|
+
expect(cell.description()).toStrictEqual(
|
|
81
|
+
"Filter status: PASS if this position has passed all filter, otherwise a list of codes for filters that fail",
|
|
82
|
+
);
|
|
83
|
+
expect(cell.value(record as Item<VcfRecord>, 0)).toStrictEqual(["PASS"]);
|
|
84
|
+
expect(cell.valueCount(record as Item<VcfRecord>)).toStrictEqual(1);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test("cell with custom label and description", () => {
|
|
88
|
+
const cell = initConfigCellFixed({
|
|
89
|
+
type: "fixed",
|
|
90
|
+
name: "chrom",
|
|
91
|
+
label: "custom_label",
|
|
92
|
+
description: "custom_description",
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
expect(cell.label()).toStrictEqual("custom_label");
|
|
96
|
+
expect(cell.description()).toStrictEqual("custom_description");
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
});
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { initConfigFilters } from "../../../src/utils/config/configFilters.ts";
|
|
3
|
+
import { ConfigJsonFilter, ConfigVip } from "../../../src/types/config";
|
|
4
|
+
import { MetadataContainer, SampleContainer, VcfMetadataContainer } from "../../../src/utils/api.ts";
|
|
5
|
+
import { initConfigFilterFixed } from "../../../src/utils/config/configFiltersFixed.ts";
|
|
6
|
+
import { ConfigFilterField, ConfigFilterFixed, ConfigFilterFormat } from "../../../src/types/configFilter";
|
|
7
|
+
import { initConfigFilterComposed } from "../../../src/utils/config/configFiltersComposed.ts";
|
|
8
|
+
import { initConfigFiltersGenotype, initConfigFiltersInfo } from "../../../src/utils/config/configFiltersField.ts";
|
|
9
|
+
import { ConfigFilterComposed } from "../../../src/types/configFilterComposed";
|
|
10
|
+
|
|
11
|
+
describe("config filters", () => {
|
|
12
|
+
vi.mock(import("../../../src/utils/config/configFiltersComposed.ts"));
|
|
13
|
+
vi.mock(import("../../../src/utils/config/configFiltersField.ts"));
|
|
14
|
+
vi.mock(import("../../../src/utils/config/configFiltersFixed.ts"));
|
|
15
|
+
|
|
16
|
+
afterEach(() => {
|
|
17
|
+
vi.resetAllMocks();
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const metadata: Partial<MetadataContainer> = { records: {} as VcfMetadataContainer };
|
|
21
|
+
const sample: Partial<SampleContainer> | null = {};
|
|
22
|
+
|
|
23
|
+
describe("initConfigFilters", () => {
|
|
24
|
+
const configVip = {} as ConfigVip;
|
|
25
|
+
|
|
26
|
+
test("regular filters config", () => {
|
|
27
|
+
vi.mocked(initConfigFilterFixed).mockReturnValue({ type: "fixed", id: "chrom" } as ConfigFilterFixed);
|
|
28
|
+
vi.mocked(initConfigFiltersInfo).mockReturnValue([
|
|
29
|
+
{
|
|
30
|
+
type: "info",
|
|
31
|
+
id: "my_info",
|
|
32
|
+
} as Partial<ConfigFilterField> as ConfigFilterField,
|
|
33
|
+
]);
|
|
34
|
+
vi.mocked(initConfigFiltersGenotype).mockReturnValue([
|
|
35
|
+
{
|
|
36
|
+
type: "genotype",
|
|
37
|
+
id: "my_genotype",
|
|
38
|
+
} as Partial<ConfigFilterFormat> as ConfigFilterFormat,
|
|
39
|
+
]);
|
|
40
|
+
vi.mocked(initConfigFilterComposed).mockReturnValue({
|
|
41
|
+
type: "composed",
|
|
42
|
+
id: "locus",
|
|
43
|
+
} as Partial<ConfigFilterComposed> as ConfigFilterComposed);
|
|
44
|
+
|
|
45
|
+
const config: ConfigJsonFilter[] = [
|
|
46
|
+
{ type: "fixed", name: "chrom" },
|
|
47
|
+
{ type: "info", name: "my_info" },
|
|
48
|
+
{ type: "genotype", name: "my_genotype" },
|
|
49
|
+
{ type: "composed", name: "locus" },
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
expect(
|
|
53
|
+
initConfigFilters(config, configVip, metadata as MetadataContainer, sample as SampleContainer | null),
|
|
54
|
+
).toStrictEqual([
|
|
55
|
+
{ type: "fixed", id: "fixed/chrom" },
|
|
56
|
+
{ type: "info", id: "info/my_info" },
|
|
57
|
+
{
|
|
58
|
+
type: "genotype",
|
|
59
|
+
id: "genotype/my_genotype",
|
|
60
|
+
},
|
|
61
|
+
{ type: "composed", id: "composed/locus" },
|
|
62
|
+
]);
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
test("exclude filters that are not applicable", () => {
|
|
66
|
+
vi.mocked(initConfigFiltersInfo).mockReturnValue([]);
|
|
67
|
+
vi.mocked(initConfigFiltersGenotype).mockReturnValue([]);
|
|
68
|
+
vi.mocked(initConfigFilterComposed).mockReturnValue(null);
|
|
69
|
+
|
|
70
|
+
const config: ConfigJsonFilter[] = [
|
|
71
|
+
{ type: "info", name: "unknown_info" },
|
|
72
|
+
{ type: "genotype", name: "unknown_genotype" },
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
expect(
|
|
76
|
+
initConfigFilters(config, configVip, metadata as MetadataContainer, sample as SampleContainer | null),
|
|
77
|
+
).toStrictEqual([]);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|