@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,259 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
getPedigreeSamples,
|
|
4
|
+
getSampleAffectedStatusLabel,
|
|
5
|
+
getSampleLabel,
|
|
6
|
+
getSampleSexLabel,
|
|
7
|
+
isSampleFather,
|
|
8
|
+
isSampleMother,
|
|
9
|
+
} from "../../src/utils/sample.ts";
|
|
10
|
+
import { Item, Sample } from "@molgenis/vip-report-api";
|
|
11
|
+
import { SampleContainer } from "../../src/utils/api.ts";
|
|
12
|
+
|
|
13
|
+
describe("sample utilities", () => {
|
|
14
|
+
test("getSampleLabel", () => {
|
|
15
|
+
const individualId = "sample_label";
|
|
16
|
+
const sample: Item<Sample> = {
|
|
17
|
+
data: {
|
|
18
|
+
person: {
|
|
19
|
+
individualId: individualId,
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
} as Item<Sample>;
|
|
23
|
+
expect(getSampleLabel(sample)).toStrictEqual(individualId);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("getSampleSexLabel", () => {
|
|
27
|
+
test("FEMALE", () => {
|
|
28
|
+
const sample: Item<Sample> = {
|
|
29
|
+
data: {
|
|
30
|
+
person: {
|
|
31
|
+
sex: "FEMALE",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as Item<Sample>;
|
|
35
|
+
expect(getSampleSexLabel(sample)).toStrictEqual("female");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test("MALE", () => {
|
|
39
|
+
const sample: Item<Sample> = {
|
|
40
|
+
data: {
|
|
41
|
+
person: {
|
|
42
|
+
sex: "MALE",
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
} as Item<Sample>;
|
|
46
|
+
expect(getSampleSexLabel(sample)).toStrictEqual("male");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
test("OTHER_SEX", () => {
|
|
50
|
+
const sample: Item<Sample> = {
|
|
51
|
+
data: {
|
|
52
|
+
person: {
|
|
53
|
+
sex: "OTHER_SEX",
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
} as Item<Sample>;
|
|
57
|
+
expect(getSampleSexLabel(sample)).toStrictEqual("?");
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test("UNKNOWN_SEX", () => {
|
|
61
|
+
const sample: Item<Sample> = {
|
|
62
|
+
data: {
|
|
63
|
+
person: {
|
|
64
|
+
sex: "UNKNOWN_SEX",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
} as Item<Sample>;
|
|
68
|
+
expect(getSampleSexLabel(sample)).toStrictEqual("?");
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
describe("getSampleAffectedStatusLabel", () => {
|
|
73
|
+
test("AFFECTED", () => {
|
|
74
|
+
const sample: Item<Sample> = {
|
|
75
|
+
data: {
|
|
76
|
+
person: {
|
|
77
|
+
affectedStatus: "AFFECTED",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
} as Item<Sample>;
|
|
81
|
+
expect(getSampleAffectedStatusLabel(sample)).toStrictEqual("affected");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
test("UNAFFECTED", () => {
|
|
85
|
+
const sample: Item<Sample> = {
|
|
86
|
+
data: {
|
|
87
|
+
person: {
|
|
88
|
+
affectedStatus: "UNAFFECTED",
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
} as Item<Sample>;
|
|
92
|
+
expect(getSampleAffectedStatusLabel(sample)).toStrictEqual("unaffected");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
test("MISSING", () => {
|
|
96
|
+
const sample: Item<Sample> = {
|
|
97
|
+
data: {
|
|
98
|
+
person: {
|
|
99
|
+
affectedStatus: "MISSING",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
} as Item<Sample>;
|
|
103
|
+
expect(getSampleAffectedStatusLabel(sample)).toStrictEqual("?");
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
describe("isSampleMother", () => {
|
|
108
|
+
test("true", () => {
|
|
109
|
+
const sample: Sample = {
|
|
110
|
+
person: {
|
|
111
|
+
maternalId: "mother0",
|
|
112
|
+
familyId: "fam0",
|
|
113
|
+
},
|
|
114
|
+
} as Sample;
|
|
115
|
+
const sampleMaternal: Sample = {
|
|
116
|
+
person: {
|
|
117
|
+
individualId: "mother0",
|
|
118
|
+
familyId: "fam0",
|
|
119
|
+
},
|
|
120
|
+
} as Sample;
|
|
121
|
+
expect(isSampleMother(sample, sampleMaternal)).toStrictEqual(true);
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test("false, mother unknown", () => {
|
|
125
|
+
const sample: Sample = {
|
|
126
|
+
person: {
|
|
127
|
+
familyId: "fam0",
|
|
128
|
+
},
|
|
129
|
+
} as Sample;
|
|
130
|
+
const sampleMaternal: Sample = {
|
|
131
|
+
person: {
|
|
132
|
+
individualId: "mother0",
|
|
133
|
+
familyId: "fam0",
|
|
134
|
+
},
|
|
135
|
+
} as Sample;
|
|
136
|
+
expect(isSampleMother(sample, sampleMaternal)).toStrictEqual(false);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
test("false, different family", () => {
|
|
140
|
+
const sample: Sample = {
|
|
141
|
+
person: {
|
|
142
|
+
maternalId: "mother0",
|
|
143
|
+
familyId: "fam0",
|
|
144
|
+
},
|
|
145
|
+
} as Sample;
|
|
146
|
+
const sampleMaternal: Sample = {
|
|
147
|
+
person: {
|
|
148
|
+
individualId: "mother0",
|
|
149
|
+
familyId: "fam1",
|
|
150
|
+
},
|
|
151
|
+
} as Sample;
|
|
152
|
+
expect(isSampleMother(sample, sampleMaternal)).toStrictEqual(false);
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
test("false, different individual id", () => {
|
|
156
|
+
const sample: Sample = {
|
|
157
|
+
person: {
|
|
158
|
+
maternalId: "mother0",
|
|
159
|
+
familyId: "fam0",
|
|
160
|
+
},
|
|
161
|
+
} as Sample;
|
|
162
|
+
const sampleMaternal: Sample = {
|
|
163
|
+
person: {
|
|
164
|
+
individualId: "individual0",
|
|
165
|
+
familyId: "fam1",
|
|
166
|
+
},
|
|
167
|
+
} as Sample;
|
|
168
|
+
expect(isSampleMother(sample, sampleMaternal)).toStrictEqual(false);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
describe("isSampleFather", () => {
|
|
173
|
+
test("true", () => {
|
|
174
|
+
const sample: Sample = {
|
|
175
|
+
person: {
|
|
176
|
+
paternalId: "father0",
|
|
177
|
+
familyId: "fam0",
|
|
178
|
+
},
|
|
179
|
+
} as Sample;
|
|
180
|
+
const sampleMaternal: Sample = {
|
|
181
|
+
person: {
|
|
182
|
+
individualId: "father0",
|
|
183
|
+
familyId: "fam0",
|
|
184
|
+
},
|
|
185
|
+
} as Sample;
|
|
186
|
+
expect(isSampleFather(sample, sampleMaternal)).toStrictEqual(true);
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
test("false, mother unknown", () => {
|
|
190
|
+
const sample: Sample = {
|
|
191
|
+
person: {
|
|
192
|
+
familyId: "fam0",
|
|
193
|
+
},
|
|
194
|
+
} as Sample;
|
|
195
|
+
const sampleMaternal: Sample = {
|
|
196
|
+
person: {
|
|
197
|
+
individualId: "father0",
|
|
198
|
+
familyId: "fam0",
|
|
199
|
+
},
|
|
200
|
+
} as Sample;
|
|
201
|
+
expect(isSampleFather(sample, sampleMaternal)).toStrictEqual(false);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
test("false, different family", () => {
|
|
205
|
+
const sample: Sample = {
|
|
206
|
+
person: {
|
|
207
|
+
paternalId: "father0",
|
|
208
|
+
familyId: "fam0",
|
|
209
|
+
},
|
|
210
|
+
} as Sample;
|
|
211
|
+
const sampleMaternal: Sample = {
|
|
212
|
+
person: {
|
|
213
|
+
individualId: "father0",
|
|
214
|
+
familyId: "fam1",
|
|
215
|
+
},
|
|
216
|
+
} as Sample;
|
|
217
|
+
expect(isSampleFather(sample, sampleMaternal)).toStrictEqual(false);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
test("false, different individual id", () => {
|
|
221
|
+
const sample: Sample = {
|
|
222
|
+
person: {
|
|
223
|
+
paternalId: "father0",
|
|
224
|
+
familyId: "fam0",
|
|
225
|
+
},
|
|
226
|
+
} as Sample;
|
|
227
|
+
const sampleMaternal: Sample = {
|
|
228
|
+
person: {
|
|
229
|
+
individualId: "individual0",
|
|
230
|
+
familyId: "fam1",
|
|
231
|
+
},
|
|
232
|
+
} as Sample;
|
|
233
|
+
expect(isSampleFather(sample, sampleMaternal)).toStrictEqual(false);
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
describe("getPedigreeSamples", () => {
|
|
237
|
+
test("get", () => {
|
|
238
|
+
const sample = {
|
|
239
|
+
item: { id: 0 },
|
|
240
|
+
maternalSample: { id: 1 },
|
|
241
|
+
paternalSample: { id: 2 },
|
|
242
|
+
otherPedigreeSamples: [{ id: 3 }, { id: 4 }],
|
|
243
|
+
} as SampleContainer;
|
|
244
|
+
|
|
245
|
+
expect(getPedigreeSamples(sample)).toStrictEqual([{ id: 0 }, { id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
test("get, no father/mother/other", () => {
|
|
249
|
+
const sample = {
|
|
250
|
+
item: { id: 0 },
|
|
251
|
+
maternalSample: null,
|
|
252
|
+
paternalSample: null,
|
|
253
|
+
otherPedigreeSamples: [] as Item<Sample>[],
|
|
254
|
+
} as SampleContainer;
|
|
255
|
+
|
|
256
|
+
expect(getPedigreeSamples(sample)).toStrictEqual([{ id: 0 }]);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { Item } from "@molgenis/vip-report-api";
|
|
3
|
+
import { VcfRecord } from "@molgenis/vip-report-vcf";
|
|
4
|
+
import {
|
|
5
|
+
abbreviateHeader,
|
|
6
|
+
getRecordLabel,
|
|
7
|
+
href,
|
|
8
|
+
isPositiveInteger,
|
|
9
|
+
parseId,
|
|
10
|
+
validateIntervalInput,
|
|
11
|
+
} from "../../src/utils/utils.ts";
|
|
12
|
+
|
|
13
|
+
describe("utils", () => {
|
|
14
|
+
describe("getRecordLabel", () => {
|
|
15
|
+
const recordBase = {
|
|
16
|
+
data: {
|
|
17
|
+
c: "chr1",
|
|
18
|
+
p: 123,
|
|
19
|
+
r: "A",
|
|
20
|
+
a: [],
|
|
21
|
+
},
|
|
22
|
+
} as Partial<Item<Partial<VcfRecord>>> as Item<VcfRecord>;
|
|
23
|
+
|
|
24
|
+
test("single allelic", () => {
|
|
25
|
+
const record = { ...recordBase, data: { ...recordBase.data, a: ["C"] } };
|
|
26
|
+
expect(getRecordLabel(record)).toStrictEqual("chr1:123 A>C");
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("multi allelic", () => {
|
|
30
|
+
const record = { ...recordBase, data: { ...recordBase.data, a: ["C", "T"] } };
|
|
31
|
+
expect(getRecordLabel(record)).toStrictEqual("chr1:123 A>C / A>T");
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test("long ref or alt", () => {
|
|
35
|
+
const record = { ...recordBase, data: { ...recordBase.data, r: "GTCAGTCA", a: ["ACTGACTG"] } };
|
|
36
|
+
expect(getRecordLabel(record)).toStrictEqual("chr1:123 GT…A>AC…G");
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test("missing alt", () => {
|
|
40
|
+
const record = { ...recordBase, data: { ...recordBase.data, a: [null] } };
|
|
41
|
+
expect(getRecordLabel(record)).toStrictEqual("chr1:123 A>.");
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
test("href", () => {
|
|
46
|
+
expect(href(["x", "/", "y"])).toStrictEqual("/x/%2F/y");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe("isPositiveInteger", () => {
|
|
50
|
+
test("2", () => {
|
|
51
|
+
expect(isPositiveInteger(2)).toStrictEqual(true);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test("-2", () => {
|
|
55
|
+
expect(isPositiveInteger(-2)).toStrictEqual(false);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test("1.23", () => {
|
|
59
|
+
expect(isPositiveInteger(1.23)).toStrictEqual(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("NaN", () => {
|
|
63
|
+
expect(isPositiveInteger(NaN)).toStrictEqual(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("parseId", () => {
|
|
68
|
+
test("0", () => {
|
|
69
|
+
expect(parseId("0")).toStrictEqual(0);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
test("123", () => {
|
|
73
|
+
expect(parseId("123")).toStrictEqual(123);
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
test("undefined", () => {
|
|
77
|
+
expect(() => parseId(undefined)).toThrow();
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
describe("abbreviateHeader", () => {
|
|
82
|
+
test("abbreviate yes", () => {
|
|
83
|
+
expect(abbreviateHeader("foo bar foo bar foo bar")).toStrictEqual("foo bar foo\u2026");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("abbreviate no", () => {
|
|
87
|
+
expect(abbreviateHeader("foo bar")).toStrictEqual("foo bar");
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe("validateIntervalInput", () => {
|
|
92
|
+
test("interval [1,]", () => {
|
|
93
|
+
expect(validateIntervalInput("x", "1", undefined)).toStrictEqual(undefined);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
test("interval [,1]", () => {
|
|
97
|
+
expect(validateIntervalInput("x", "", "1")).toStrictEqual(undefined);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test("interval [1,1]", () => {
|
|
101
|
+
expect(validateIntervalInput("x", "1", "1")).toStrictEqual(undefined);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
test("interval [2,1]", () => {
|
|
105
|
+
expect(validateIntervalInput("x", "2", "1")).toStrictEqual(
|
|
106
|
+
"Input 'to' (1) for filter 'x' should have a higher value than the 'from' input (2).",
|
|
107
|
+
);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("interval [1.23,]", () => {
|
|
111
|
+
expect(validateIntervalInput("x", "1.23", "")).toStrictEqual(undefined);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test("interval [,abc]", () => {
|
|
115
|
+
expect(validateIntervalInput("x", "", "abc")).toStrictEqual(
|
|
116
|
+
"Input 'to' (abc) for filter 'x' should be a number.",
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, test } from "vitest";
|
|
2
|
+
import { getVariantTypes, mapSvTypeToVariantTypeId, parseVariantType } from "../../src/utils/variantType.ts";
|
|
3
|
+
|
|
4
|
+
describe("variantType", () => {
|
|
5
|
+
test("getVariantTypes", () => {
|
|
6
|
+
expect(getVariantTypes(new Set(["all", "snv"]))).toStrictEqual([
|
|
7
|
+
{
|
|
8
|
+
id: "all",
|
|
9
|
+
label: "All",
|
|
10
|
+
description: "All variants",
|
|
11
|
+
},
|
|
12
|
+
{ id: "snv", label: "SNV", description: "Single nucleotide variants and Indels < 50 bases" },
|
|
13
|
+
]);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
describe("parseVariantType", () => {
|
|
17
|
+
test("parse valid", () => {
|
|
18
|
+
expect(parseVariantType("snv")).toStrictEqual({
|
|
19
|
+
id: "snv",
|
|
20
|
+
label: "SNV",
|
|
21
|
+
description: "Single nucleotide variants and Indels < 50 bases",
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("parse invalid", () => {
|
|
26
|
+
expect(() => parseVariantType("invalid")).toThrow();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("parse undefined", () => {
|
|
30
|
+
expect(() => parseVariantType(undefined)).toThrow();
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
describe("mapSvTypeToVariantTypeId", () => {
|
|
35
|
+
test("SVTYPE=null", () => {
|
|
36
|
+
expect(mapSvTypeToVariantTypeId(null)).toStrictEqual("snv");
|
|
37
|
+
});
|
|
38
|
+
test("SVTYPE=undefined", () => {
|
|
39
|
+
expect(mapSvTypeToVariantTypeId(undefined)).toStrictEqual("snv");
|
|
40
|
+
});
|
|
41
|
+
test("SVTYPE=STR", () => {
|
|
42
|
+
expect(mapSvTypeToVariantTypeId("STR")).toStrictEqual("str");
|
|
43
|
+
});
|
|
44
|
+
test("SVTYPE something else", () => {
|
|
45
|
+
expect(mapSvTypeToVariantTypeId("foo")).toStrictEqual("sv");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
});
|