@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,1163 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test, vi } from "vitest";
|
|
2
|
+
import { initConfigCellComposed } from "../../../src/utils/config/configCellsComposed.ts";
|
|
3
|
+
import { MetadataContainer, SampleContainer } from "../../../src/utils/api.ts";
|
|
4
|
+
import { VariantType } from "../../../src/utils/variantType.ts";
|
|
5
|
+
import { ConfigJsonFieldComposed } from "../../../src/types/config";
|
|
6
|
+
import { ConfigCellCustom } from "../../../src/types/configCells";
|
|
7
|
+
import { CellValueCustom } from "../../../src/types/configCellComposed";
|
|
8
|
+
import {
|
|
9
|
+
FieldMetadataWrapper,
|
|
10
|
+
getInfoFields,
|
|
11
|
+
getInfoNestedField,
|
|
12
|
+
getInfoNestedFields,
|
|
13
|
+
getInfoValue,
|
|
14
|
+
getInfoValueCount,
|
|
15
|
+
getInfoValues,
|
|
16
|
+
getSampleField,
|
|
17
|
+
getSampleFields,
|
|
18
|
+
getSampleValue,
|
|
19
|
+
getSampleValues,
|
|
20
|
+
} from "../../../src/utils/vcf.ts";
|
|
21
|
+
import { Item, Sample } from "@molgenis/vip-report-api";
|
|
22
|
+
import { VcfRecord } from "@molgenis/vip-report-vcf";
|
|
23
|
+
|
|
24
|
+
describe("config cells composed", () => {
|
|
25
|
+
vi.mock(import("../../../src/utils/vcf.ts"));
|
|
26
|
+
|
|
27
|
+
afterEach(() => {
|
|
28
|
+
vi.resetAllMocks();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
describe("initConfigCellComposed", () => {
|
|
32
|
+
const variantType = { id: "snv" } as VariantType;
|
|
33
|
+
const vcfMetadata = {};
|
|
34
|
+
const metadata = { records: vcfMetadata } as MetadataContainer;
|
|
35
|
+
const record = { id: 0, data: { c: "chr1", p: 123, r: "A", a: ["C", "T"] } } as Item<VcfRecord>;
|
|
36
|
+
|
|
37
|
+
describe("clinVar", () => {
|
|
38
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
39
|
+
type: "composed",
|
|
40
|
+
name: "clinVar",
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
test("clinVar with required fields", () => {
|
|
44
|
+
const fieldClinSig = { id: "CSQ/clinVar_CLNSIG" };
|
|
45
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([fieldClinSig as FieldMetadataWrapper, undefined, undefined]);
|
|
46
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
47
|
+
vi.mocked(getInfoValues).mockReturnValue([0, undefined, undefined]);
|
|
48
|
+
|
|
49
|
+
const cell = initConfigCellComposed(
|
|
50
|
+
configBase,
|
|
51
|
+
variantType,
|
|
52
|
+
metadata,
|
|
53
|
+
null,
|
|
54
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
55
|
+
expect(cell.type).toStrictEqual("composed");
|
|
56
|
+
expect(cell.id).toStrictEqual("clinVar");
|
|
57
|
+
expect(cell.label()).toStrictEqual("ClinVar");
|
|
58
|
+
expect(cell.description()).toStrictEqual(null);
|
|
59
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
60
|
+
expect(cell.value(record, 1)).toStrictEqual({ clnSigs: 0, clnIds: undefined, clnRevStats: undefined });
|
|
61
|
+
|
|
62
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
63
|
+
vcfMetadata,
|
|
64
|
+
"CSQ",
|
|
65
|
+
"clinVar_CLNSIG",
|
|
66
|
+
"clinVar_CLNID",
|
|
67
|
+
"clinVar_CLNREVSTAT",
|
|
68
|
+
);
|
|
69
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldClinSig);
|
|
70
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldClinSig, undefined, undefined);
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test("clinVar with required and optional fields", () => {
|
|
74
|
+
const config: ConfigJsonFieldComposed = {
|
|
75
|
+
...configBase,
|
|
76
|
+
label: "my_label",
|
|
77
|
+
description: "my_description",
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const fieldClinSig = { id: "CSQ/clinVar_CLNSIG" };
|
|
81
|
+
const fieldClnId = { id: "CSQ/clinVar_CLNID" };
|
|
82
|
+
const fieldClnRevStat = { id: "CSQ/clinVar_CLNREVSTAT" };
|
|
83
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
84
|
+
fieldClinSig,
|
|
85
|
+
fieldClnId,
|
|
86
|
+
fieldClnRevStat,
|
|
87
|
+
] as FieldMetadataWrapper[]);
|
|
88
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
89
|
+
vi.mocked(getInfoValues).mockReturnValue([0, 1, 2]);
|
|
90
|
+
|
|
91
|
+
const cell = initConfigCellComposed(config, variantType, metadata, null) as ConfigCellCustom<CellValueCustom>;
|
|
92
|
+
expect(cell.type).toStrictEqual("composed");
|
|
93
|
+
expect(cell.id).toStrictEqual("clinVar");
|
|
94
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
95
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
96
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
97
|
+
expect(cell.value(record, 1)).toStrictEqual({ clnSigs: 0, clnIds: 1, clnRevStats: 2 });
|
|
98
|
+
|
|
99
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
100
|
+
vcfMetadata,
|
|
101
|
+
"CSQ",
|
|
102
|
+
"clinVar_CLNSIG",
|
|
103
|
+
"clinVar_CLNID",
|
|
104
|
+
"clinVar_CLNREVSTAT",
|
|
105
|
+
);
|
|
106
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldClinSig);
|
|
107
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldClinSig, fieldClnId, fieldClnRevStat);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test("clinVar without required fields", () => {
|
|
111
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([undefined, undefined, undefined]);
|
|
112
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
113
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
114
|
+
vcfMetadata,
|
|
115
|
+
"CSQ",
|
|
116
|
+
"clinVar_CLNSIG",
|
|
117
|
+
"clinVar_CLNID",
|
|
118
|
+
"clinVar_CLNREVSTAT",
|
|
119
|
+
);
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
describe("gene", () => {
|
|
124
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
125
|
+
type: "composed",
|
|
126
|
+
name: "gene",
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
test("gene with required fields", () => {
|
|
130
|
+
const fieldSymbol = { id: "CSQ/SYMBOL" };
|
|
131
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
132
|
+
fieldSymbol as FieldMetadataWrapper,
|
|
133
|
+
undefined,
|
|
134
|
+
undefined,
|
|
135
|
+
undefined,
|
|
136
|
+
]);
|
|
137
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
138
|
+
vi.mocked(getInfoValues).mockReturnValue(["my_symbol", undefined, undefined, undefined]);
|
|
139
|
+
|
|
140
|
+
const cell = initConfigCellComposed(
|
|
141
|
+
configBase,
|
|
142
|
+
variantType,
|
|
143
|
+
metadata,
|
|
144
|
+
null,
|
|
145
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
146
|
+
expect(cell.type).toStrictEqual("composed");
|
|
147
|
+
expect(cell.id).toStrictEqual("gene");
|
|
148
|
+
expect(cell.label()).toStrictEqual("Gene");
|
|
149
|
+
expect(cell.description()).toStrictEqual(null);
|
|
150
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
151
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
152
|
+
symbol: "my_symbol",
|
|
153
|
+
geneIdentifier: undefined,
|
|
154
|
+
incompletePenetrance: undefined,
|
|
155
|
+
symbolSource: undefined,
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
159
|
+
vcfMetadata,
|
|
160
|
+
"CSQ",
|
|
161
|
+
"SYMBOL",
|
|
162
|
+
"Gene",
|
|
163
|
+
"IncompletePenetrance",
|
|
164
|
+
"SYMBOL_SOURCE",
|
|
165
|
+
);
|
|
166
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldSymbol);
|
|
167
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldSymbol, undefined, undefined, undefined);
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
test("gene with required and optional fields", () => {
|
|
171
|
+
const config: ConfigJsonFieldComposed = {
|
|
172
|
+
...configBase,
|
|
173
|
+
label: "my_label",
|
|
174
|
+
description: "my_description",
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const fieldSymbol = { id: "CSQ/SYMBOL" };
|
|
178
|
+
const fieldGene = { id: "CSQ/Gene" };
|
|
179
|
+
const fieldIncPen = { id: "CSQ/IncompletePenetrance" };
|
|
180
|
+
const fieldSymbolSource = { id: "CSQ/SYMBOL_SOURCE" };
|
|
181
|
+
|
|
182
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
183
|
+
fieldSymbol,
|
|
184
|
+
fieldGene,
|
|
185
|
+
fieldIncPen,
|
|
186
|
+
fieldSymbolSource,
|
|
187
|
+
] as FieldMetadataWrapper[]);
|
|
188
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
189
|
+
vi.mocked(getInfoValues).mockReturnValue(["my_symbol", "my_gene", true, "my_symbol_source"]);
|
|
190
|
+
|
|
191
|
+
const cell = initConfigCellComposed(config, variantType, metadata, null) as ConfigCellCustom<CellValueCustom>;
|
|
192
|
+
expect(cell.type).toStrictEqual("composed");
|
|
193
|
+
expect(cell.id).toStrictEqual("gene");
|
|
194
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
195
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
196
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
197
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
198
|
+
symbol: "my_symbol",
|
|
199
|
+
geneIdentifier: "my_gene",
|
|
200
|
+
incompletePenetrance: true,
|
|
201
|
+
symbolSource: "my_symbol_source",
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
205
|
+
vcfMetadata,
|
|
206
|
+
"CSQ",
|
|
207
|
+
"SYMBOL",
|
|
208
|
+
"Gene",
|
|
209
|
+
"IncompletePenetrance",
|
|
210
|
+
"SYMBOL_SOURCE",
|
|
211
|
+
);
|
|
212
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldSymbol);
|
|
213
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldSymbol, fieldGene, fieldIncPen, fieldSymbolSource);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
test("gene without required fields", () => {
|
|
217
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
218
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
219
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
220
|
+
vcfMetadata,
|
|
221
|
+
"CSQ",
|
|
222
|
+
"SYMBOL",
|
|
223
|
+
"Gene",
|
|
224
|
+
"IncompletePenetrance",
|
|
225
|
+
"SYMBOL_SOURCE",
|
|
226
|
+
);
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
describe("genotype", () => {
|
|
231
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
232
|
+
type: "composed",
|
|
233
|
+
name: "genotype",
|
|
234
|
+
};
|
|
235
|
+
const sample = { item: { id: 2, data: { person: { individualId: "sample2" } } } } as SampleContainer;
|
|
236
|
+
|
|
237
|
+
test("genotype with required and optional fields", () => {
|
|
238
|
+
const config: ConfigJsonFieldComposed = {
|
|
239
|
+
...configBase,
|
|
240
|
+
label: "my_label",
|
|
241
|
+
description: "my_description",
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
const fieldGt = { id: "FORMAT/GT" };
|
|
245
|
+
const fieldRepCn = { id: "FORMAT/REPCN" };
|
|
246
|
+
const fieldViab = { id: "FORMAT/VIAB" };
|
|
247
|
+
const fieldSvType = { id: "INFO/SVTYPE" };
|
|
248
|
+
const fieldRu = { id: "INFO/RU" };
|
|
249
|
+
const fieldRuMatch = { id: "INFO/RUMATCH" };
|
|
250
|
+
const fieldDisplayRu = { id: "INFO/DisplayRU" };
|
|
251
|
+
vi.mocked(getSampleFields).mockReturnValue([fieldGt, fieldRepCn, fieldViab] as FieldMetadataWrapper[]);
|
|
252
|
+
vi.mocked(getInfoFields).mockReturnValue([
|
|
253
|
+
fieldSvType,
|
|
254
|
+
fieldRu,
|
|
255
|
+
fieldRuMatch,
|
|
256
|
+
fieldDisplayRu,
|
|
257
|
+
] as FieldMetadataWrapper[]);
|
|
258
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
259
|
+
vi.mocked(getSampleValues).mockReturnValue([0, 1, 2]);
|
|
260
|
+
vi.mocked(getInfoValues).mockReturnValue([3, 4, 5, 6]);
|
|
261
|
+
|
|
262
|
+
const cell = initConfigCellComposed(config, variantType, metadata, sample) as ConfigCellCustom<CellValueCustom>;
|
|
263
|
+
expect(cell.type).toStrictEqual("composed");
|
|
264
|
+
expect(cell.id).toStrictEqual("genotype");
|
|
265
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
266
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
267
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
268
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
269
|
+
altAlleles: ["C", "T"],
|
|
270
|
+
displayRepeatUnit: 6,
|
|
271
|
+
genotype: 0,
|
|
272
|
+
refAllele: "A",
|
|
273
|
+
repeatCount: 1,
|
|
274
|
+
repeatUnitMatch: 5,
|
|
275
|
+
repeatUnitValue: 4,
|
|
276
|
+
svType: 3,
|
|
277
|
+
viab: 2,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "GT", "REPCN", "VIAB");
|
|
281
|
+
expect(getInfoFields).toHaveBeenCalledWith(vcfMetadata, "SVTYPE", "RU", "RUMATCH", "DisplayRU");
|
|
282
|
+
expect(getSampleValues).toHaveBeenCalledWith(sample, record, 1, fieldGt, fieldRepCn, fieldViab);
|
|
283
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldSvType, fieldRu, fieldRuMatch, fieldDisplayRu);
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
test("genotype with required fields", () => {
|
|
287
|
+
const fieldGt = { id: "FORMAT/GT" };
|
|
288
|
+
vi.mocked(getSampleFields).mockReturnValue([fieldGt, undefined, undefined] as FieldMetadataWrapper[]);
|
|
289
|
+
vi.mocked(getInfoFields).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
290
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
291
|
+
vi.mocked(getSampleValues).mockReturnValue([0, undefined, undefined]);
|
|
292
|
+
vi.mocked(getInfoValues).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
293
|
+
|
|
294
|
+
const cell = initConfigCellComposed(
|
|
295
|
+
configBase,
|
|
296
|
+
variantType,
|
|
297
|
+
metadata,
|
|
298
|
+
sample,
|
|
299
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
300
|
+
expect(cell.type).toStrictEqual("composed");
|
|
301
|
+
expect(cell.id).toStrictEqual("genotype");
|
|
302
|
+
expect(cell.label()).toStrictEqual("sample2");
|
|
303
|
+
expect(cell.description()).toStrictEqual(null);
|
|
304
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
305
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
306
|
+
altAlleles: ["C", "T"],
|
|
307
|
+
displayRepeatUnit: undefined,
|
|
308
|
+
genotype: 0,
|
|
309
|
+
refAllele: "A",
|
|
310
|
+
repeatCount: undefined,
|
|
311
|
+
repeatUnitMatch: undefined,
|
|
312
|
+
repeatUnitValue: undefined,
|
|
313
|
+
svType: undefined,
|
|
314
|
+
viab: undefined,
|
|
315
|
+
});
|
|
316
|
+
|
|
317
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "GT", "REPCN", "VIAB");
|
|
318
|
+
expect(getInfoFields).toHaveBeenCalledWith(vcfMetadata, "SVTYPE", "RU", "RUMATCH", "DisplayRU");
|
|
319
|
+
expect(getSampleValues).toHaveBeenCalledWith(sample, record, 1, fieldGt, undefined, undefined);
|
|
320
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, undefined, undefined, undefined, undefined);
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
test("genotype without required fields", () => {
|
|
324
|
+
vi.mocked(getSampleFields).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
325
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, sample)).toStrictEqual(null);
|
|
326
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "GT", "REPCN", "VIAB");
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
test("genotype without sample", () => {
|
|
330
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
331
|
+
});
|
|
332
|
+
});
|
|
333
|
+
|
|
334
|
+
describe("genotype_maternal", () => {
|
|
335
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
336
|
+
type: "composed",
|
|
337
|
+
name: "genotype_maternal",
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
test("genotype_maternal with required fields", () => {
|
|
341
|
+
const sampleMaternal = { id: 2, data: { person: { individualId: "sample2_maternal" } } } as Item<Sample>;
|
|
342
|
+
const sample = {
|
|
343
|
+
item: { id: 2, data: { person: { individualId: "sample2" } } },
|
|
344
|
+
maternalSample: sampleMaternal,
|
|
345
|
+
} as SampleContainer;
|
|
346
|
+
|
|
347
|
+
const fieldGt = { id: "FORMAT/GT" };
|
|
348
|
+
vi.mocked(getSampleFields).mockReturnValue([fieldGt, undefined, undefined] as FieldMetadataWrapper[]);
|
|
349
|
+
vi.mocked(getInfoFields).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
350
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
351
|
+
vi.mocked(getSampleValues).mockReturnValue([0, undefined, undefined]);
|
|
352
|
+
vi.mocked(getInfoValues).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
353
|
+
|
|
354
|
+
const cell = initConfigCellComposed(
|
|
355
|
+
configBase,
|
|
356
|
+
variantType,
|
|
357
|
+
metadata,
|
|
358
|
+
sample,
|
|
359
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
360
|
+
expect(cell.type).toStrictEqual("composed");
|
|
361
|
+
expect(cell.id).toStrictEqual("genotype");
|
|
362
|
+
expect(cell.label()).toStrictEqual("sample2_maternal");
|
|
363
|
+
expect(cell.description()).toStrictEqual(null);
|
|
364
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
365
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
366
|
+
altAlleles: ["C", "T"],
|
|
367
|
+
displayRepeatUnit: undefined,
|
|
368
|
+
genotype: 0,
|
|
369
|
+
refAllele: "A",
|
|
370
|
+
repeatCount: undefined,
|
|
371
|
+
repeatUnitMatch: undefined,
|
|
372
|
+
repeatUnitValue: undefined,
|
|
373
|
+
svType: undefined,
|
|
374
|
+
viab: undefined,
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "GT", "REPCN", "VIAB");
|
|
378
|
+
expect(getInfoFields).toHaveBeenCalledWith(vcfMetadata, "SVTYPE", "RU", "RUMATCH", "DisplayRU");
|
|
379
|
+
expect(getSampleValues).toHaveBeenCalledWith(
|
|
380
|
+
{
|
|
381
|
+
item: {
|
|
382
|
+
data: { person: { individualId: "sample2_maternal" } },
|
|
383
|
+
id: 2,
|
|
384
|
+
},
|
|
385
|
+
maternalSample: null,
|
|
386
|
+
otherPedigreeSamples: [],
|
|
387
|
+
paternalSample: null,
|
|
388
|
+
phenotypes: [],
|
|
389
|
+
variantTypeIds: new Set(),
|
|
390
|
+
},
|
|
391
|
+
record,
|
|
392
|
+
1,
|
|
393
|
+
fieldGt,
|
|
394
|
+
undefined,
|
|
395
|
+
undefined,
|
|
396
|
+
);
|
|
397
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, undefined, undefined, undefined, undefined);
|
|
398
|
+
});
|
|
399
|
+
|
|
400
|
+
test("genotype_maternal no sample", () => {
|
|
401
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
test("genotype_maternal no mother", () => {
|
|
405
|
+
const sample = {
|
|
406
|
+
item: { id: 2, data: { person: { individualId: "sample2" } } },
|
|
407
|
+
maternalSample: null,
|
|
408
|
+
} as SampleContainer;
|
|
409
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, sample)).toStrictEqual(null);
|
|
410
|
+
});
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
describe("genotype_paternal", () => {
|
|
414
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
415
|
+
type: "composed",
|
|
416
|
+
name: "genotype_paternal",
|
|
417
|
+
};
|
|
418
|
+
|
|
419
|
+
test("genotype_paternal with required fields", () => {
|
|
420
|
+
const samplePaternal = { id: 2, data: { person: { individualId: "sample2_paternal" } } } as Item<Sample>;
|
|
421
|
+
const sample = {
|
|
422
|
+
item: { id: 2, data: { person: { individualId: "sample2" } } },
|
|
423
|
+
paternalSample: samplePaternal,
|
|
424
|
+
} as SampleContainer;
|
|
425
|
+
|
|
426
|
+
const fieldGt = { id: "FORMAT/GT" };
|
|
427
|
+
vi.mocked(getSampleFields).mockReturnValue([fieldGt, undefined, undefined] as FieldMetadataWrapper[]);
|
|
428
|
+
vi.mocked(getInfoFields).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
429
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
430
|
+
vi.mocked(getSampleValues).mockReturnValue([0, undefined, undefined]);
|
|
431
|
+
vi.mocked(getInfoValues).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
432
|
+
|
|
433
|
+
const cell = initConfigCellComposed(
|
|
434
|
+
configBase,
|
|
435
|
+
variantType,
|
|
436
|
+
metadata,
|
|
437
|
+
sample,
|
|
438
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
439
|
+
expect(cell.type).toStrictEqual("composed");
|
|
440
|
+
expect(cell.id).toStrictEqual("genotype");
|
|
441
|
+
expect(cell.label()).toStrictEqual("sample2_paternal");
|
|
442
|
+
expect(cell.description()).toStrictEqual(null);
|
|
443
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
444
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
445
|
+
altAlleles: ["C", "T"],
|
|
446
|
+
displayRepeatUnit: undefined,
|
|
447
|
+
genotype: 0,
|
|
448
|
+
refAllele: "A",
|
|
449
|
+
repeatCount: undefined,
|
|
450
|
+
repeatUnitMatch: undefined,
|
|
451
|
+
repeatUnitValue: undefined,
|
|
452
|
+
svType: undefined,
|
|
453
|
+
viab: undefined,
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "GT", "REPCN", "VIAB");
|
|
457
|
+
expect(getInfoFields).toHaveBeenCalledWith(vcfMetadata, "SVTYPE", "RU", "RUMATCH", "DisplayRU");
|
|
458
|
+
expect(getSampleValues).toHaveBeenCalledWith(
|
|
459
|
+
{
|
|
460
|
+
item: {
|
|
461
|
+
data: { person: { individualId: "sample2_paternal" } },
|
|
462
|
+
id: 2,
|
|
463
|
+
},
|
|
464
|
+
maternalSample: null,
|
|
465
|
+
otherPedigreeSamples: [],
|
|
466
|
+
paternalSample: null,
|
|
467
|
+
phenotypes: [],
|
|
468
|
+
variantTypeIds: new Set(),
|
|
469
|
+
},
|
|
470
|
+
record,
|
|
471
|
+
1,
|
|
472
|
+
fieldGt,
|
|
473
|
+
undefined,
|
|
474
|
+
undefined,
|
|
475
|
+
);
|
|
476
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, undefined, undefined, undefined, undefined);
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
test("genotype_paternal no sample", () => {
|
|
480
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
test("genotype_paternal no father", () => {
|
|
484
|
+
const sample = {
|
|
485
|
+
item: { id: 2, data: { person: { individualId: "sample2" } } },
|
|
486
|
+
paternalSample: null,
|
|
487
|
+
} as SampleContainer;
|
|
488
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, sample)).toStrictEqual(null);
|
|
489
|
+
});
|
|
490
|
+
});
|
|
491
|
+
|
|
492
|
+
describe("gnomAdAf", () => {
|
|
493
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
494
|
+
type: "composed",
|
|
495
|
+
name: "gnomAdAf",
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
test("gnomAdAf with required and optional fields", () => {
|
|
499
|
+
const config: ConfigJsonFieldComposed = {
|
|
500
|
+
...configBase,
|
|
501
|
+
label: "my_label",
|
|
502
|
+
description: "my_description",
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
const fieldGnomAdAf = { id: "gnomAD_AF" };
|
|
506
|
+
const fieldGnomAdCov = { id: "gnomAD_COV" };
|
|
507
|
+
const fieldGnomAdQc = { id: "gnomAD_QC" };
|
|
508
|
+
const fieldAlleleNum = { id: "ALLELE_NUM" };
|
|
509
|
+
|
|
510
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
511
|
+
fieldGnomAdAf,
|
|
512
|
+
fieldGnomAdCov,
|
|
513
|
+
fieldGnomAdQc,
|
|
514
|
+
fieldAlleleNum,
|
|
515
|
+
] as FieldMetadataWrapper[]);
|
|
516
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
517
|
+
vi.mocked(getInfoValues).mockReturnValue([0.12, 0.23, ["qc"], 0]);
|
|
518
|
+
|
|
519
|
+
const cell = initConfigCellComposed(config, variantType, metadata, null) as ConfigCellCustom<CellValueCustom>;
|
|
520
|
+
expect(cell.type).toStrictEqual("composed");
|
|
521
|
+
expect(cell.id).toStrictEqual("gnomAdAf");
|
|
522
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
523
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
524
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
525
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
526
|
+
c: "chr1",
|
|
527
|
+
p: 123,
|
|
528
|
+
r: "A",
|
|
529
|
+
a: ["C", "T"],
|
|
530
|
+
gnomAdAf: 0.12,
|
|
531
|
+
gnomAdCov: 0.23,
|
|
532
|
+
gnomAdQcs: ["qc"],
|
|
533
|
+
alleleNum: 0,
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
537
|
+
vcfMetadata,
|
|
538
|
+
"CSQ",
|
|
539
|
+
"gnomAD_AF",
|
|
540
|
+
"gnomAD_COV",
|
|
541
|
+
"gnomAD_QC",
|
|
542
|
+
"ALLELE_NUM",
|
|
543
|
+
);
|
|
544
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldGnomAdAf);
|
|
545
|
+
expect(getInfoValues).toHaveBeenCalledWith(
|
|
546
|
+
record,
|
|
547
|
+
1,
|
|
548
|
+
fieldGnomAdAf,
|
|
549
|
+
fieldGnomAdCov,
|
|
550
|
+
fieldGnomAdQc,
|
|
551
|
+
fieldAlleleNum,
|
|
552
|
+
);
|
|
553
|
+
});
|
|
554
|
+
|
|
555
|
+
test("gnomAdAf with required fields", () => {
|
|
556
|
+
const fieldGnomAdAf = { id: "gnomAD_AF" };
|
|
557
|
+
|
|
558
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
559
|
+
fieldGnomAdAf,
|
|
560
|
+
undefined,
|
|
561
|
+
undefined,
|
|
562
|
+
undefined,
|
|
563
|
+
] as FieldMetadataWrapper[]);
|
|
564
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
565
|
+
vi.mocked(getInfoValues).mockReturnValue([0.12, undefined, undefined, undefined]);
|
|
566
|
+
|
|
567
|
+
const cell = initConfigCellComposed(
|
|
568
|
+
configBase,
|
|
569
|
+
variantType,
|
|
570
|
+
metadata,
|
|
571
|
+
null,
|
|
572
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
573
|
+
expect(cell.type).toStrictEqual("composed");
|
|
574
|
+
expect(cell.id).toStrictEqual("gnomAdAf");
|
|
575
|
+
expect(cell.label()).toStrictEqual("gnomAD AF");
|
|
576
|
+
expect(cell.description()).toStrictEqual("gnomAD allele frequency");
|
|
577
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
578
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
579
|
+
c: "chr1",
|
|
580
|
+
p: 123,
|
|
581
|
+
r: "A",
|
|
582
|
+
a: ["C", "T"],
|
|
583
|
+
gnomAdAf: 0.12,
|
|
584
|
+
gnomAdCov: undefined,
|
|
585
|
+
gnomAdQcs: undefined,
|
|
586
|
+
alleleNum: undefined,
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
590
|
+
vcfMetadata,
|
|
591
|
+
"CSQ",
|
|
592
|
+
"gnomAD_AF",
|
|
593
|
+
"gnomAD_COV",
|
|
594
|
+
"gnomAD_QC",
|
|
595
|
+
"ALLELE_NUM",
|
|
596
|
+
);
|
|
597
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldGnomAdAf);
|
|
598
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldGnomAdAf, undefined, undefined, undefined);
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
test("gnomAdAf without required fields", () => {
|
|
602
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([undefined, undefined, undefined, undefined]);
|
|
603
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
604
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
605
|
+
vcfMetadata,
|
|
606
|
+
"CSQ",
|
|
607
|
+
"gnomAD_AF",
|
|
608
|
+
"gnomAD_COV",
|
|
609
|
+
"gnomAD_QC",
|
|
610
|
+
"ALLELE_NUM",
|
|
611
|
+
);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
describe("hpo", () => {
|
|
616
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
617
|
+
type: "composed",
|
|
618
|
+
name: "hpo",
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
test("hpo with required fields", () => {
|
|
622
|
+
const fieldHpo = { id: "CSQ/HPO" };
|
|
623
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([fieldHpo, undefined] as FieldMetadataWrapper[]);
|
|
624
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
625
|
+
vi.mocked(getInfoValues).mockReturnValue([["HP:0000951"], undefined]);
|
|
626
|
+
|
|
627
|
+
const cell = initConfigCellComposed(
|
|
628
|
+
configBase,
|
|
629
|
+
variantType,
|
|
630
|
+
metadata,
|
|
631
|
+
null,
|
|
632
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
633
|
+
expect(cell.type).toStrictEqual("composed");
|
|
634
|
+
expect(cell.id).toStrictEqual("hpo");
|
|
635
|
+
expect(cell.label()).toStrictEqual("HPO");
|
|
636
|
+
expect(cell.description()).toStrictEqual("Human phenotype ontology matches");
|
|
637
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
638
|
+
expect(cell.value(record, 1)).toStrictEqual({ hpos: ["HP:0000951"], gadoPd: undefined });
|
|
639
|
+
|
|
640
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(vcfMetadata, "CSQ", "HPO", "GADO_PD");
|
|
641
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldHpo);
|
|
642
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldHpo, undefined);
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
test("hpo with required and optional fields", () => {
|
|
646
|
+
const config: ConfigJsonFieldComposed = {
|
|
647
|
+
...configBase,
|
|
648
|
+
label: "my_label",
|
|
649
|
+
description: "my_description",
|
|
650
|
+
};
|
|
651
|
+
|
|
652
|
+
const fieldHpo = { id: "CSQ/HPO" };
|
|
653
|
+
const fieldGadoPd = { id: "CSQ/GADO_PD" };
|
|
654
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([fieldHpo, fieldGadoPd] as FieldMetadataWrapper[]);
|
|
655
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
656
|
+
vi.mocked(getInfoValues).mockReturnValue([["HP:0000951"], "HC"]);
|
|
657
|
+
|
|
658
|
+
const cell = initConfigCellComposed(config, variantType, metadata, null) as ConfigCellCustom<CellValueCustom>;
|
|
659
|
+
expect(cell.type).toStrictEqual("composed");
|
|
660
|
+
expect(cell.id).toStrictEqual("hpo");
|
|
661
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
662
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
663
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
664
|
+
expect(cell.value(record, 1)).toStrictEqual({ hpos: ["HP:0000951"], gadoPd: "HC" });
|
|
665
|
+
|
|
666
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(vcfMetadata, "CSQ", "HPO", "GADO_PD");
|
|
667
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldHpo);
|
|
668
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldHpo, fieldGadoPd);
|
|
669
|
+
});
|
|
670
|
+
|
|
671
|
+
test("hpo without required fields", () => {
|
|
672
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([undefined, undefined]);
|
|
673
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
674
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(vcfMetadata, "CSQ", "HPO", "GADO_PD");
|
|
675
|
+
});
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
describe("inheritancePattern", () => {
|
|
679
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
680
|
+
type: "composed",
|
|
681
|
+
name: "inheritancePattern",
|
|
682
|
+
};
|
|
683
|
+
const sample = { item: { id: 2 } } as SampleContainer;
|
|
684
|
+
|
|
685
|
+
test("inheritancePattern with required and optional fields, with sample", () => {
|
|
686
|
+
const config: ConfigJsonFieldComposed = {
|
|
687
|
+
...configBase,
|
|
688
|
+
label: "my_label",
|
|
689
|
+
description: "my_description",
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
const fieldInhModesGene = { id: "CSQ/InheritanceModesGene" };
|
|
693
|
+
const fieldVic = { id: "FORMAT/VIC" };
|
|
694
|
+
vi.mocked(getInfoNestedField).mockReturnValue(fieldInhModesGene as FieldMetadataWrapper);
|
|
695
|
+
vi.mocked(getSampleField).mockReturnValue(fieldVic as FieldMetadataWrapper);
|
|
696
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
697
|
+
vi.mocked(getInfoValue).mockReturnValue(0);
|
|
698
|
+
vi.mocked(getSampleValue).mockReturnValue(1);
|
|
699
|
+
|
|
700
|
+
const cell = initConfigCellComposed(config, variantType, metadata, sample) as ConfigCellCustom<CellValueCustom>;
|
|
701
|
+
expect(cell.type).toStrictEqual("composed");
|
|
702
|
+
expect(cell.id).toStrictEqual("inheritancePattern");
|
|
703
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
704
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
705
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
706
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
707
|
+
fieldInheritanceModesGene: fieldInhModesGene,
|
|
708
|
+
inheritanceModesGene: 0,
|
|
709
|
+
isPossibleCompound: 1,
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
expect(getInfoNestedField).toHaveBeenCalledWith(vcfMetadata, "CSQ", "InheritanceModesGene");
|
|
713
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "VIC");
|
|
714
|
+
expect(getInfoValue).toHaveBeenCalledWith(record, 1, fieldInhModesGene);
|
|
715
|
+
expect(getSampleValue).toHaveBeenCalledWith(sample, record, 1, fieldVic);
|
|
716
|
+
});
|
|
717
|
+
|
|
718
|
+
test("inheritancePattern with required and optional fields, without sample", () => {
|
|
719
|
+
const fieldInhModesGene = { id: "CSQ/InheritanceModesGene" };
|
|
720
|
+
vi.mocked(getInfoNestedField).mockReturnValue(fieldInhModesGene as FieldMetadataWrapper);
|
|
721
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
722
|
+
vi.mocked(getInfoValue).mockReturnValue(0);
|
|
723
|
+
|
|
724
|
+
const cell = initConfigCellComposed(
|
|
725
|
+
configBase,
|
|
726
|
+
variantType,
|
|
727
|
+
metadata,
|
|
728
|
+
sample,
|
|
729
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
730
|
+
expect(cell.type).toStrictEqual("composed");
|
|
731
|
+
expect(cell.id).toStrictEqual("inheritancePattern");
|
|
732
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
733
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
734
|
+
fieldInheritanceModesGene: fieldInhModesGene,
|
|
735
|
+
inheritanceModesGene: 0,
|
|
736
|
+
isPossibleCompound: undefined,
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
expect(getInfoNestedField).toHaveBeenCalledWith(vcfMetadata, "CSQ", "InheritanceModesGene");
|
|
740
|
+
expect(getInfoValue).toHaveBeenCalledWith(record, 1, fieldInhModesGene);
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
test("inheritancePattern with required fields, with sample", () => {
|
|
744
|
+
const fieldInhModesGene = { id: "CSQ/InheritanceModesGene" };
|
|
745
|
+
vi.mocked(getInfoNestedField).mockReturnValue(fieldInhModesGene as FieldMetadataWrapper);
|
|
746
|
+
vi.mocked(getSampleField).mockReturnValue(undefined);
|
|
747
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
748
|
+
vi.mocked(getInfoValue).mockReturnValue(0);
|
|
749
|
+
vi.mocked(getSampleValue).mockReturnValue(undefined);
|
|
750
|
+
|
|
751
|
+
const cell = initConfigCellComposed(
|
|
752
|
+
configBase,
|
|
753
|
+
variantType,
|
|
754
|
+
metadata,
|
|
755
|
+
sample,
|
|
756
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
757
|
+
expect(cell.type).toStrictEqual("composed");
|
|
758
|
+
expect(cell.id).toStrictEqual("inheritancePattern");
|
|
759
|
+
expect(cell.label()).toStrictEqual("Inh.Pat.");
|
|
760
|
+
expect(cell.description()).toStrictEqual("Inheritance pattern");
|
|
761
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
762
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
763
|
+
fieldInheritanceModesGene: fieldInhModesGene,
|
|
764
|
+
inheritanceModesGene: 0,
|
|
765
|
+
isPossibleCompound: undefined,
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
expect(getInfoNestedField).toHaveBeenCalledWith(vcfMetadata, "CSQ", "InheritanceModesGene");
|
|
769
|
+
expect(getSampleField).toHaveBeenCalledWith(vcfMetadata, "VIC");
|
|
770
|
+
expect(getInfoValue).toHaveBeenCalledWith(record, 1, fieldInhModesGene);
|
|
771
|
+
expect(getSampleValue).toHaveBeenCalledWith(sample, record, 1, undefined);
|
|
772
|
+
});
|
|
773
|
+
|
|
774
|
+
test("inheritancePattern without required fields", () => {
|
|
775
|
+
vi.mocked(getInfoNestedField).mockReturnValue(undefined);
|
|
776
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, sample)).toStrictEqual(null);
|
|
777
|
+
expect(getInfoNestedField).toHaveBeenCalledWith(vcfMetadata, "CSQ", "InheritanceModesGene");
|
|
778
|
+
});
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
describe("locus", () => {
|
|
782
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
783
|
+
type: "composed",
|
|
784
|
+
name: "locus",
|
|
785
|
+
};
|
|
786
|
+
|
|
787
|
+
test("locus with sample", () => {
|
|
788
|
+
const config = {
|
|
789
|
+
...configBase,
|
|
790
|
+
label: "my_label",
|
|
791
|
+
description: "my_description",
|
|
792
|
+
};
|
|
793
|
+
const sample = { item: { id: 2 } } as SampleContainer;
|
|
794
|
+
const cell = initConfigCellComposed(config, variantType, metadata, sample) as ConfigCellCustom<CellValueCustom>;
|
|
795
|
+
expect(cell.type).toStrictEqual("composed");
|
|
796
|
+
expect(cell.id).toStrictEqual("locus");
|
|
797
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
798
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
799
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
800
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
801
|
+
c: "chr1",
|
|
802
|
+
href: "/samples/2/variants/snv/variant/0",
|
|
803
|
+
p: 123,
|
|
804
|
+
});
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
test("locus without sample", () => {
|
|
808
|
+
const cell = initConfigCellComposed(
|
|
809
|
+
configBase,
|
|
810
|
+
variantType,
|
|
811
|
+
metadata,
|
|
812
|
+
null,
|
|
813
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
814
|
+
expect(cell.type).toStrictEqual("composed");
|
|
815
|
+
expect(cell.id).toStrictEqual("locus");
|
|
816
|
+
expect(cell.label()).toStrictEqual("Position");
|
|
817
|
+
expect(cell.description()).toStrictEqual(null);
|
|
818
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
819
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
820
|
+
c: "chr1",
|
|
821
|
+
href: "/variants/snv/variant/0",
|
|
822
|
+
p: 123,
|
|
823
|
+
});
|
|
824
|
+
});
|
|
825
|
+
});
|
|
826
|
+
|
|
827
|
+
describe("vipC", () => {
|
|
828
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
829
|
+
type: "composed",
|
|
830
|
+
name: "vipC",
|
|
831
|
+
};
|
|
832
|
+
|
|
833
|
+
test("vipC with required fields, without sample", () => {
|
|
834
|
+
const fieldVipC = { id: "CSQ/VIPC" };
|
|
835
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([fieldVipC, undefined] as FieldMetadataWrapper[]);
|
|
836
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
837
|
+
vi.mocked(getInfoValues).mockReturnValue(["LP", undefined]);
|
|
838
|
+
|
|
839
|
+
const cell = initConfigCellComposed(
|
|
840
|
+
configBase,
|
|
841
|
+
variantType,
|
|
842
|
+
metadata,
|
|
843
|
+
null,
|
|
844
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
845
|
+
expect(cell.type).toStrictEqual("composed");
|
|
846
|
+
expect(cell.id).toStrictEqual("vipC");
|
|
847
|
+
expect(cell.label()).toStrictEqual("VIP");
|
|
848
|
+
expect(cell.description()).toStrictEqual("VIP classification");
|
|
849
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
850
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
851
|
+
href: "/variants/snv/variant/0/consequences/1",
|
|
852
|
+
vipC: "LP",
|
|
853
|
+
vipP: undefined,
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(vcfMetadata, "CSQ", "VIPC", "VIPP");
|
|
857
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldVipC);
|
|
858
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldVipC, undefined);
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
test("vipC with required and optional fields, with sample", () => {
|
|
862
|
+
const config: ConfigJsonFieldComposed = {
|
|
863
|
+
...configBase,
|
|
864
|
+
label: "my_label",
|
|
865
|
+
description: "my_description",
|
|
866
|
+
};
|
|
867
|
+
const sample = { item: { id: 2 } } as SampleContainer;
|
|
868
|
+
const fieldVipC = { id: "CSQ/VIPC" };
|
|
869
|
+
const fieldVipP = { id: "CSQ/VIPP" };
|
|
870
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([fieldVipC, fieldVipP] as FieldMetadataWrapper[]);
|
|
871
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
872
|
+
vi.mocked(getInfoValues).mockReturnValue(["LP", ["x", "y"]]);
|
|
873
|
+
|
|
874
|
+
const cell = initConfigCellComposed(config, variantType, metadata, sample) as ConfigCellCustom<CellValueCustom>;
|
|
875
|
+
expect(cell.type).toStrictEqual("composed");
|
|
876
|
+
expect(cell.id).toStrictEqual("vipC");
|
|
877
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
878
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
879
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
880
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
881
|
+
href: "/samples/2/variants/snv/variant/0/consequences/1",
|
|
882
|
+
vipC: "LP",
|
|
883
|
+
vipP: ["x", "y"],
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(vcfMetadata, "CSQ", "VIPC", "VIPP");
|
|
887
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldVipC);
|
|
888
|
+
expect(getInfoValues).toHaveBeenCalledWith(record, 1, fieldVipC, fieldVipP);
|
|
889
|
+
});
|
|
890
|
+
|
|
891
|
+
test("vipC without required fields", () => {
|
|
892
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([undefined, undefined]);
|
|
893
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
894
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(vcfMetadata, "CSQ", "VIPC", "VIPP");
|
|
895
|
+
});
|
|
896
|
+
});
|
|
897
|
+
|
|
898
|
+
describe("vipCS", () => {
|
|
899
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
900
|
+
type: "composed",
|
|
901
|
+
name: "vipCS",
|
|
902
|
+
};
|
|
903
|
+
const sample = { item: { id: 2 } } as SampleContainer;
|
|
904
|
+
|
|
905
|
+
test("vipCS with required fields", () => {
|
|
906
|
+
const fieldVipCS = { id: "FORMAT/VIPC_S" };
|
|
907
|
+
vi.mocked(getSampleFields).mockReturnValue([fieldVipCS, undefined] as FieldMetadataWrapper[]);
|
|
908
|
+
vi.mocked(getSampleValue).mockReturnValue(["1", "2"]);
|
|
909
|
+
vi.mocked(getSampleValues).mockReturnValue([
|
|
910
|
+
[
|
|
911
|
+
{ value: "U1", label: "U1 label" },
|
|
912
|
+
{ value: "U2", label: "U2 label" },
|
|
913
|
+
],
|
|
914
|
+
undefined,
|
|
915
|
+
]);
|
|
916
|
+
|
|
917
|
+
const cell = initConfigCellComposed(
|
|
918
|
+
configBase,
|
|
919
|
+
variantType,
|
|
920
|
+
metadata,
|
|
921
|
+
sample,
|
|
922
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
923
|
+
expect(cell.type).toStrictEqual("composed");
|
|
924
|
+
expect(cell.id).toStrictEqual("vipCS");
|
|
925
|
+
expect(cell.label()).toStrictEqual("VIP sample");
|
|
926
|
+
expect(cell.description()).toStrictEqual("VIP sample classification");
|
|
927
|
+
expect(cell.valueCount(record)).toStrictEqual(2);
|
|
928
|
+
expect(cell.value(record, 1)).toStrictEqual({ vipCS: { value: "U2", label: "U2 label" }, vipPS: undefined });
|
|
929
|
+
|
|
930
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "VIPC_S", "VIPP_S");
|
|
931
|
+
expect(getSampleValue).toHaveBeenCalledWith(sample, record, 0, fieldVipCS);
|
|
932
|
+
expect(getSampleValues).toHaveBeenCalledWith(sample, record, 0, fieldVipCS, undefined);
|
|
933
|
+
});
|
|
934
|
+
|
|
935
|
+
test("vipCS with required and optional fields", () => {
|
|
936
|
+
const fieldVipCS = { id: "FORMAT/VIPC_S" };
|
|
937
|
+
const fieldVipPS = { id: "FORMAT/VIPP_S" };
|
|
938
|
+
vi.mocked(getSampleFields).mockReturnValue([fieldVipCS, fieldVipPS] as FieldMetadataWrapper[]);
|
|
939
|
+
vi.mocked(getSampleValue).mockReturnValue(["x"]);
|
|
940
|
+
vi.mocked(getSampleValues).mockReturnValue([[{ value: "U1", label: "U1 label" }], ["a&b&c"]]);
|
|
941
|
+
|
|
942
|
+
const cell = initConfigCellComposed(
|
|
943
|
+
configBase,
|
|
944
|
+
variantType,
|
|
945
|
+
metadata,
|
|
946
|
+
sample,
|
|
947
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
948
|
+
expect(cell.type).toStrictEqual("composed");
|
|
949
|
+
expect(cell.id).toStrictEqual("vipCS");
|
|
950
|
+
expect(cell.label()).toStrictEqual("VIP sample");
|
|
951
|
+
expect(cell.description()).toStrictEqual("VIP sample classification");
|
|
952
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
953
|
+
expect(cell.value(record, 0)).toStrictEqual({
|
|
954
|
+
vipCS: { value: "U1", label: "U1 label" },
|
|
955
|
+
vipPS: ["a", "b", "c"],
|
|
956
|
+
});
|
|
957
|
+
|
|
958
|
+
expect(getSampleFields).toHaveBeenCalledWith(vcfMetadata, "VIPC_S", "VIPP_S");
|
|
959
|
+
expect(getSampleValue).toHaveBeenCalledWith(sample, record, 0, fieldVipCS);
|
|
960
|
+
expect(getSampleValues).toHaveBeenCalledWith(sample, record, 0, fieldVipCS, fieldVipPS);
|
|
961
|
+
});
|
|
962
|
+
|
|
963
|
+
test("vipCS without sample", () => {
|
|
964
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
965
|
+
});
|
|
966
|
+
|
|
967
|
+
test("vipCS without required metadata", () => {
|
|
968
|
+
vi.mocked(getSampleFields).mockReturnValue([undefined, undefined]);
|
|
969
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, sample)).toStrictEqual(null);
|
|
970
|
+
});
|
|
971
|
+
});
|
|
972
|
+
|
|
973
|
+
describe("vkgl", () => {
|
|
974
|
+
const configBase: ConfigJsonFieldComposed = {
|
|
975
|
+
type: "composed",
|
|
976
|
+
name: "vkgl",
|
|
977
|
+
};
|
|
978
|
+
|
|
979
|
+
test("vkgl with required fields", () => {
|
|
980
|
+
const fieldVkglCl = { id: "CSQ/VKGL_CL" };
|
|
981
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
982
|
+
fieldVkglCl,
|
|
983
|
+
undefined,
|
|
984
|
+
undefined,
|
|
985
|
+
undefined,
|
|
986
|
+
undefined,
|
|
987
|
+
undefined,
|
|
988
|
+
undefined,
|
|
989
|
+
undefined,
|
|
990
|
+
undefined,
|
|
991
|
+
] as FieldMetadataWrapper[]);
|
|
992
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
993
|
+
vi.mocked(getInfoValues).mockReturnValue([
|
|
994
|
+
"B",
|
|
995
|
+
undefined,
|
|
996
|
+
undefined,
|
|
997
|
+
undefined,
|
|
998
|
+
undefined,
|
|
999
|
+
undefined,
|
|
1000
|
+
undefined,
|
|
1001
|
+
undefined,
|
|
1002
|
+
undefined,
|
|
1003
|
+
]);
|
|
1004
|
+
|
|
1005
|
+
const cell = initConfigCellComposed(
|
|
1006
|
+
configBase,
|
|
1007
|
+
variantType,
|
|
1008
|
+
metadata,
|
|
1009
|
+
null,
|
|
1010
|
+
) as ConfigCellCustom<CellValueCustom>;
|
|
1011
|
+
expect(cell.type).toStrictEqual("composed");
|
|
1012
|
+
expect(cell.id).toStrictEqual("vkgl");
|
|
1013
|
+
expect(cell.label()).toStrictEqual("VKGL");
|
|
1014
|
+
expect(cell.description()).toStrictEqual("VKGL consensus classification");
|
|
1015
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
1016
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
1017
|
+
vkglCl: "B",
|
|
1018
|
+
vkglAmc: undefined,
|
|
1019
|
+
vkglErasmus: undefined,
|
|
1020
|
+
vkglLumc: undefined,
|
|
1021
|
+
vkglNki: undefined,
|
|
1022
|
+
vkglRadboudMumc: undefined,
|
|
1023
|
+
vkglUmcg: undefined,
|
|
1024
|
+
vkglUmcu: undefined,
|
|
1025
|
+
vkglVumc: undefined,
|
|
1026
|
+
});
|
|
1027
|
+
|
|
1028
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
1029
|
+
vcfMetadata,
|
|
1030
|
+
"CSQ",
|
|
1031
|
+
"VKGL_CL",
|
|
1032
|
+
"VKGL_AMC",
|
|
1033
|
+
"VKGL_ERASMUS",
|
|
1034
|
+
"VKGL_LUMC",
|
|
1035
|
+
"VKGL_NKI",
|
|
1036
|
+
"VKGL_RADBOUD_MUMC",
|
|
1037
|
+
"VKGL_UMCG",
|
|
1038
|
+
"VKGL_UMCU",
|
|
1039
|
+
"VKGL_VUMC",
|
|
1040
|
+
);
|
|
1041
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldVkglCl);
|
|
1042
|
+
expect(getInfoValues).toHaveBeenCalledWith(
|
|
1043
|
+
record,
|
|
1044
|
+
1,
|
|
1045
|
+
fieldVkglCl,
|
|
1046
|
+
undefined,
|
|
1047
|
+
undefined,
|
|
1048
|
+
undefined,
|
|
1049
|
+
undefined,
|
|
1050
|
+
undefined,
|
|
1051
|
+
undefined,
|
|
1052
|
+
undefined,
|
|
1053
|
+
undefined,
|
|
1054
|
+
);
|
|
1055
|
+
});
|
|
1056
|
+
|
|
1057
|
+
test("vkgl with required and optional fields", () => {
|
|
1058
|
+
const config: ConfigJsonFieldComposed = {
|
|
1059
|
+
...configBase,
|
|
1060
|
+
label: "my_label",
|
|
1061
|
+
description: "my_description",
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
const fieldVkglCl = { id: "CSQ/VKGL_CL" };
|
|
1065
|
+
const fieldVkglAmc = { id: "CSQ/VKGL_AMC" };
|
|
1066
|
+
const fieldVkglErasmus = { id: "CSQ/VKGL_ERASMUS" };
|
|
1067
|
+
const fieldVkglLumc = { id: "CSQ/VKGL_LUMC" };
|
|
1068
|
+
const fieldVkglNki = { id: "CSQ/VKGL_NKI" };
|
|
1069
|
+
const fieldVkglRadboud = { id: "CSQ/VKGL_RADBOUD_MUMC" };
|
|
1070
|
+
const fieldVkglUmcg = { id: "CSQ/VKGL_UMCG" };
|
|
1071
|
+
const fieldVkglUmcu = { id: "CSQ/VKGL_UMCU" };
|
|
1072
|
+
const fieldVkglVumc = { id: "CSQ/VKGL_VUMC" };
|
|
1073
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
1074
|
+
fieldVkglCl,
|
|
1075
|
+
fieldVkglAmc,
|
|
1076
|
+
fieldVkglErasmus,
|
|
1077
|
+
fieldVkglLumc,
|
|
1078
|
+
fieldVkglNki,
|
|
1079
|
+
fieldVkglRadboud,
|
|
1080
|
+
fieldVkglUmcg,
|
|
1081
|
+
fieldVkglUmcu,
|
|
1082
|
+
fieldVkglVumc,
|
|
1083
|
+
] as FieldMetadataWrapper[]);
|
|
1084
|
+
vi.mocked(getInfoValueCount).mockReturnValue(1);
|
|
1085
|
+
vi.mocked(getInfoValues).mockReturnValue(["B", "LB", "VUS", "LP", "P", "LP", "VUS", "LB", "B"]);
|
|
1086
|
+
|
|
1087
|
+
const cell = initConfigCellComposed(config, variantType, metadata, null) as ConfigCellCustom<CellValueCustom>;
|
|
1088
|
+
expect(cell.type).toStrictEqual("composed");
|
|
1089
|
+
expect(cell.id).toStrictEqual("vkgl");
|
|
1090
|
+
expect(cell.label()).toStrictEqual("my_label");
|
|
1091
|
+
expect(cell.description()).toStrictEqual("my_description");
|
|
1092
|
+
expect(cell.valueCount(record)).toStrictEqual(1);
|
|
1093
|
+
expect(cell.value(record, 1)).toStrictEqual({
|
|
1094
|
+
vkglCl: "B",
|
|
1095
|
+
vkglAmc: "LB",
|
|
1096
|
+
vkglErasmus: "VUS",
|
|
1097
|
+
vkglLumc: "LP",
|
|
1098
|
+
vkglNki: "P",
|
|
1099
|
+
vkglRadboudMumc: "LP",
|
|
1100
|
+
vkglUmcg: "VUS",
|
|
1101
|
+
vkglUmcu: "LB",
|
|
1102
|
+
vkglVumc: "B",
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
1106
|
+
vcfMetadata,
|
|
1107
|
+
"CSQ",
|
|
1108
|
+
"VKGL_CL",
|
|
1109
|
+
"VKGL_AMC",
|
|
1110
|
+
"VKGL_ERASMUS",
|
|
1111
|
+
"VKGL_LUMC",
|
|
1112
|
+
"VKGL_NKI",
|
|
1113
|
+
"VKGL_RADBOUD_MUMC",
|
|
1114
|
+
"VKGL_UMCG",
|
|
1115
|
+
"VKGL_UMCU",
|
|
1116
|
+
"VKGL_VUMC",
|
|
1117
|
+
);
|
|
1118
|
+
expect(getInfoValueCount).toHaveBeenCalledWith(record, fieldVkglCl);
|
|
1119
|
+
expect(getInfoValues).toHaveBeenCalledWith(
|
|
1120
|
+
record,
|
|
1121
|
+
1,
|
|
1122
|
+
fieldVkglCl,
|
|
1123
|
+
fieldVkglAmc,
|
|
1124
|
+
fieldVkglErasmus,
|
|
1125
|
+
fieldVkglLumc,
|
|
1126
|
+
fieldVkglNki,
|
|
1127
|
+
fieldVkglRadboud,
|
|
1128
|
+
fieldVkglUmcg,
|
|
1129
|
+
fieldVkglUmcu,
|
|
1130
|
+
fieldVkglVumc,
|
|
1131
|
+
);
|
|
1132
|
+
});
|
|
1133
|
+
|
|
1134
|
+
test("vkgl without required fields", () => {
|
|
1135
|
+
vi.mocked(getInfoNestedFields).mockReturnValue([
|
|
1136
|
+
undefined,
|
|
1137
|
+
undefined,
|
|
1138
|
+
undefined,
|
|
1139
|
+
undefined,
|
|
1140
|
+
undefined,
|
|
1141
|
+
undefined,
|
|
1142
|
+
undefined,
|
|
1143
|
+
undefined,
|
|
1144
|
+
undefined,
|
|
1145
|
+
]);
|
|
1146
|
+
expect(initConfigCellComposed(configBase, variantType, metadata, null)).toStrictEqual(null);
|
|
1147
|
+
expect(getInfoNestedFields).toHaveBeenCalledWith(
|
|
1148
|
+
vcfMetadata,
|
|
1149
|
+
"CSQ",
|
|
1150
|
+
"VKGL_CL",
|
|
1151
|
+
"VKGL_AMC",
|
|
1152
|
+
"VKGL_ERASMUS",
|
|
1153
|
+
"VKGL_LUMC",
|
|
1154
|
+
"VKGL_NKI",
|
|
1155
|
+
"VKGL_RADBOUD_MUMC",
|
|
1156
|
+
"VKGL_UMCG",
|
|
1157
|
+
"VKGL_UMCU",
|
|
1158
|
+
"VKGL_VUMC",
|
|
1159
|
+
);
|
|
1160
|
+
});
|
|
1161
|
+
});
|
|
1162
|
+
});
|
|
1163
|
+
});
|