@molgenis/vip-report-template 6.2.0 → 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 +8 -8
- 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 +30 -24
- 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 +6 -4
- package/src/components/DatasetDropdown.tsx +12 -25
- 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 +21 -1
- package/src/mocks/GRCh37/static.ts +62 -134
- package/src/mocks/GRCh37/vcf/family.vcf.blob +9 -3
- 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 +339 -332
- 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 -144
- 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 -184
- package/src/components/VariantsTable.tsx +0 -125
- 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 -263
- package/src/utils/csqUtils.ts +0 -27
- package/src/utils/decisionTreeUtils.ts +0 -31
- package/src/utils/field.ts +0 -49
- package/src/utils/query.ts +0 -154
- package/src/utils/viewUtils.ts +0 -32
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ConfigFilters, ConfigJsonFilter, ConfigVip } from "../../types/config";
|
|
2
|
+
import { ConfigFilter } from "../../types/configFilter";
|
|
3
|
+
import { initConfigFilterComposed } from "./configFiltersComposed.ts";
|
|
4
|
+
import { MetadataContainer, SampleContainer } from "../api.ts";
|
|
5
|
+
import { initConfigFilterFixed } from "./configFiltersFixed.ts";
|
|
6
|
+
import { initConfigFiltersGenotype, initConfigFiltersInfo } from "./configFiltersField.ts";
|
|
7
|
+
|
|
8
|
+
export function initConfigFilters(
|
|
9
|
+
config: ConfigJsonFilter[],
|
|
10
|
+
configVip: ConfigVip,
|
|
11
|
+
metadata: MetadataContainer,
|
|
12
|
+
sample: SampleContainer | null,
|
|
13
|
+
): ConfigFilters {
|
|
14
|
+
return config.flatMap((config) => createConfigFilter(config, configVip, metadata, sample));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createConfigFilter(
|
|
18
|
+
config: ConfigJsonFilter,
|
|
19
|
+
configVip: ConfigVip,
|
|
20
|
+
metadata: MetadataContainer,
|
|
21
|
+
sample: SampleContainer | null,
|
|
22
|
+
): ConfigFilter[] {
|
|
23
|
+
let configFilters: (ConfigFilter | null)[];
|
|
24
|
+
switch (config.type) {
|
|
25
|
+
case "fixed":
|
|
26
|
+
configFilters = [initConfigFilterFixed(config)];
|
|
27
|
+
break;
|
|
28
|
+
case "info":
|
|
29
|
+
configFilters = initConfigFiltersInfo(config, metadata.records);
|
|
30
|
+
break;
|
|
31
|
+
case "format":
|
|
32
|
+
throw new Error(`unsupported config filter type '${config.type}'`); // not exposed by vip-report-api
|
|
33
|
+
case "genotype":
|
|
34
|
+
configFilters = sample ? initConfigFiltersGenotype(config, metadata.records, sample) : [];
|
|
35
|
+
break;
|
|
36
|
+
case "composed":
|
|
37
|
+
configFilters = [initConfigFilterComposed(config, configVip, metadata, sample)];
|
|
38
|
+
break;
|
|
39
|
+
}
|
|
40
|
+
return configFilters
|
|
41
|
+
.filter((configFilter) => configFilter !== null)
|
|
42
|
+
.map((config) => ({
|
|
43
|
+
...config,
|
|
44
|
+
id: `${config.type}/${config.id}`, // prevent naming collisions for generic config filters
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ConfigFilterAllelicImbalance,
|
|
3
|
+
ConfigFilterComposed,
|
|
4
|
+
ConfigFilterDeNovo,
|
|
5
|
+
ConfigFilterHpo,
|
|
6
|
+
ConfigFilterInheritanceMatch,
|
|
7
|
+
ConfigFilterLocus,
|
|
8
|
+
ConfigFilterVipC,
|
|
9
|
+
ConfigFilterVipCS,
|
|
10
|
+
} from "../../types/configFilterComposed";
|
|
11
|
+
import { MetadataContainer, SampleContainer, VcfMetadataContainer } from "../api.ts";
|
|
12
|
+
import { ConfigJsonFilterComposed, ConfigVip } from "../../types/config";
|
|
13
|
+
import { getDescription, getLabel } from "./config.ts";
|
|
14
|
+
import { getInfoNestedField, getSampleField, getSampleFields, parseContigIds } from "../vcf.ts";
|
|
15
|
+
import { ConfigInvalidError } from "../error.ts";
|
|
16
|
+
|
|
17
|
+
export function initConfigFilterComposed(
|
|
18
|
+
config: ConfigJsonFilterComposed,
|
|
19
|
+
configVip: ConfigVip,
|
|
20
|
+
metadata: MetadataContainer,
|
|
21
|
+
sample: SampleContainer | null,
|
|
22
|
+
): ConfigFilterComposed | null {
|
|
23
|
+
const id = config.name;
|
|
24
|
+
|
|
25
|
+
let filter: ConfigFilterComposed | null;
|
|
26
|
+
switch (id) {
|
|
27
|
+
case "allelicImbalance":
|
|
28
|
+
filter = createConfigFilterAllelicImbalance(config, metadata.records, sample);
|
|
29
|
+
break;
|
|
30
|
+
case "deNovo":
|
|
31
|
+
filter = createConfigFilterDeNovo(config, metadata.records, sample);
|
|
32
|
+
break;
|
|
33
|
+
case "hpo":
|
|
34
|
+
filter = createConfigFilterHpo(config, metadata.records, sample);
|
|
35
|
+
break;
|
|
36
|
+
case "inheritanceMatch":
|
|
37
|
+
filter = createConfigFilterInheritanceMatch(config, metadata.records, sample);
|
|
38
|
+
break;
|
|
39
|
+
case "locus":
|
|
40
|
+
filter = createConfigFilterLocus(config, metadata);
|
|
41
|
+
break;
|
|
42
|
+
case "vipC":
|
|
43
|
+
filter = createConfigFilterVipC(config, configVip, metadata.records);
|
|
44
|
+
break;
|
|
45
|
+
case "vipCS":
|
|
46
|
+
filter = createConfigFilterVipCS(config, configVip, metadata.records, sample);
|
|
47
|
+
break;
|
|
48
|
+
default:
|
|
49
|
+
throw new ConfigInvalidError(`unknown composed filter name '${id}'`);
|
|
50
|
+
}
|
|
51
|
+
return filter;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function createConfigFilterHpo(
|
|
55
|
+
configStatic: ConfigJsonFilterComposed,
|
|
56
|
+
metadata: VcfMetadataContainer,
|
|
57
|
+
sample: SampleContainer | null,
|
|
58
|
+
): ConfigFilterHpo | null {
|
|
59
|
+
if (sample === null || sample.phenotypes.length === 0) return null;
|
|
60
|
+
const fieldCsqHpo = getInfoNestedField(metadata, "CSQ", "HPO");
|
|
61
|
+
if (fieldCsqHpo === undefined) return null;
|
|
62
|
+
|
|
63
|
+
const filterField = {
|
|
64
|
+
// create field with categories based on the sample hpo terms
|
|
65
|
+
...fieldCsqHpo,
|
|
66
|
+
categories: sample.phenotypes.reduce(
|
|
67
|
+
(acc, phenotype) => ({
|
|
68
|
+
...acc,
|
|
69
|
+
[phenotype.type.id]: { label: phenotype.type.label },
|
|
70
|
+
}),
|
|
71
|
+
{},
|
|
72
|
+
),
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return {
|
|
76
|
+
type: "composed",
|
|
77
|
+
id: configStatic.name,
|
|
78
|
+
label: () => getLabel(configStatic, fieldCsqHpo.label || "HPO"),
|
|
79
|
+
description: () => getDescription(configStatic, filterField.description),
|
|
80
|
+
field: filterField,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function createConfigFilterLocus(
|
|
85
|
+
configStatic: ConfigJsonFilterComposed,
|
|
86
|
+
metadata: MetadataContainer,
|
|
87
|
+
): ConfigFilterLocus {
|
|
88
|
+
return {
|
|
89
|
+
type: "composed",
|
|
90
|
+
id: configStatic.name,
|
|
91
|
+
label: () => getLabel(configStatic, "Locus"),
|
|
92
|
+
description: () => getDescription(configStatic),
|
|
93
|
+
chromosomes: parseContigIds(metadata.records),
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function createConfigFilterAllelicImbalance(
|
|
98
|
+
configStatic: ConfigJsonFilterComposed,
|
|
99
|
+
metadata: VcfMetadataContainer,
|
|
100
|
+
sample: SampleContainer | null,
|
|
101
|
+
): ConfigFilterAllelicImbalance | null {
|
|
102
|
+
if (sample === null) return null;
|
|
103
|
+
const [fieldViab, fieldGenotype] = getSampleFields(metadata, "VIAB", "GT");
|
|
104
|
+
if (fieldViab === undefined || fieldGenotype === undefined) return null;
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
type: "composed",
|
|
108
|
+
id: configStatic.name,
|
|
109
|
+
label: () => getLabel(configStatic, fieldViab.label || "VIAB"),
|
|
110
|
+
description: () => getDescription(configStatic, fieldViab.description),
|
|
111
|
+
genotypeField: fieldGenotype,
|
|
112
|
+
viabField: fieldViab,
|
|
113
|
+
sample: sample,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function createConfigFilterInheritanceMatch(
|
|
118
|
+
configStatic: ConfigJsonFilterComposed,
|
|
119
|
+
metadata: VcfMetadataContainer,
|
|
120
|
+
sample: SampleContainer | null,
|
|
121
|
+
): ConfigFilterInheritanceMatch | null {
|
|
122
|
+
if (sample === null) return null;
|
|
123
|
+
const vimField = getSampleField(metadata, "VIM");
|
|
124
|
+
if (vimField === undefined) return null;
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
type: "composed",
|
|
128
|
+
id: configStatic.name,
|
|
129
|
+
label: () => getLabel(configStatic, vimField.label || "VIM"),
|
|
130
|
+
description: () => getDescription(configStatic, vimField.description),
|
|
131
|
+
vimField: { ...vimField, required: true },
|
|
132
|
+
sample: sample,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function createConfigFilterDeNovo(
|
|
137
|
+
configStatic: ConfigJsonFilterComposed,
|
|
138
|
+
metadata: VcfMetadataContainer,
|
|
139
|
+
sample: SampleContainer | null,
|
|
140
|
+
): ConfigFilterDeNovo | null {
|
|
141
|
+
if (sample === null) return null;
|
|
142
|
+
const vidField = getSampleField(metadata, "VID");
|
|
143
|
+
if (vidField === undefined) return null;
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
type: "composed",
|
|
147
|
+
id: configStatic.name,
|
|
148
|
+
label: () => configStatic.label || vidField.label || "VID",
|
|
149
|
+
description: () => configStatic.description || vidField.description || null,
|
|
150
|
+
vidField: { ...vidField, required: true },
|
|
151
|
+
sample: sample,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function createConfigFilterVipC(
|
|
156
|
+
configStatic: ConfigJsonFilterComposed,
|
|
157
|
+
configVip: ConfigVip,
|
|
158
|
+
metadata: VcfMetadataContainer,
|
|
159
|
+
): ConfigFilterVipC | null {
|
|
160
|
+
if (!configVip.params.vcf.filter.consequences) return null;
|
|
161
|
+
|
|
162
|
+
const vipCField = getInfoNestedField(metadata, "CSQ", "VIPC");
|
|
163
|
+
if (vipCField === undefined) return null;
|
|
164
|
+
|
|
165
|
+
const categories = vipCField.categories;
|
|
166
|
+
if (categories === undefined) return null;
|
|
167
|
+
|
|
168
|
+
// exclude categories that were removed after filtering
|
|
169
|
+
const classSet = new Set(configVip.params.vcf.filter.classes.split(","));
|
|
170
|
+
const treeCategories = Object.fromEntries(Object.entries(categories).filter(([key]) => classSet.has(key)));
|
|
171
|
+
if (Object.keys(treeCategories).length <= 1) return null;
|
|
172
|
+
|
|
173
|
+
return {
|
|
174
|
+
type: "composed",
|
|
175
|
+
id: configStatic.name,
|
|
176
|
+
label: () => getLabel(configStatic, vipCField.label || "VIPC"),
|
|
177
|
+
description: () => getDescription(configStatic, vipCField.description),
|
|
178
|
+
field: { ...vipCField, categories: treeCategories },
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function createConfigFilterVipCS(
|
|
183
|
+
configStatic: ConfigJsonFilterComposed,
|
|
184
|
+
configVip: ConfigVip,
|
|
185
|
+
metadata: VcfMetadataContainer,
|
|
186
|
+
sample: SampleContainer | null,
|
|
187
|
+
): ConfigFilterVipCS | null {
|
|
188
|
+
if (sample === null || !sample.item.data.proband) return null;
|
|
189
|
+
const vipCSField = getSampleField(metadata, "VIPC_S");
|
|
190
|
+
if (vipCSField === undefined) return null;
|
|
191
|
+
|
|
192
|
+
const categories = vipCSField.categories;
|
|
193
|
+
if (categories === undefined) return null;
|
|
194
|
+
|
|
195
|
+
// exclude categories that were removed after filtering
|
|
196
|
+
const classSet = new Set(configVip.params.vcf.filter_samples.classes.split(","));
|
|
197
|
+
const treeCategories = Object.fromEntries(Object.entries(categories).filter(([key]) => classSet.has(key)));
|
|
198
|
+
if (Object.keys(treeCategories).length <= 1) return null;
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
type: "composed",
|
|
202
|
+
id: configStatic.name,
|
|
203
|
+
label: () => getLabel(configStatic, vipCSField.label || "VIPC_S"),
|
|
204
|
+
description: () => getDescription(configStatic, vipCSField.description),
|
|
205
|
+
field: { ...vipCSField, categories: treeCategories, required: true },
|
|
206
|
+
sample,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ConfigJsonFieldGenotype, ConfigJsonFieldInfo } from "../../types/config";
|
|
2
|
+
import { ConfigFilterField, ConfigFilterFormat } from "../../types/configFilter";
|
|
3
|
+
import { SampleContainer, VcfMetadataContainer } from "../api.ts";
|
|
4
|
+
import { FieldMetadataWrapper, getInfoFieldsRegex, getSampleFieldsRegex } from "../vcf.ts";
|
|
5
|
+
import { getDescription, getLabel } from "./config.ts";
|
|
6
|
+
|
|
7
|
+
function createConfigFilterGenotype(
|
|
8
|
+
config: ConfigJsonFieldGenotype,
|
|
9
|
+
field: FieldMetadataWrapper,
|
|
10
|
+
sample: SampleContainer,
|
|
11
|
+
): ConfigFilterFormat {
|
|
12
|
+
return {
|
|
13
|
+
type: "genotype",
|
|
14
|
+
id: config.name,
|
|
15
|
+
label: () => getLabel(config, field.label || field.id),
|
|
16
|
+
description: () => getDescription(config, field.description),
|
|
17
|
+
field,
|
|
18
|
+
sample,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function initConfigFiltersGenotype(
|
|
23
|
+
config: ConfigJsonFieldGenotype,
|
|
24
|
+
metadata: VcfMetadataContainer,
|
|
25
|
+
sample: SampleContainer,
|
|
26
|
+
): ConfigFilterFormat[] {
|
|
27
|
+
return getSampleFieldsRegex(metadata, new RegExp(`^${config.name}$`))
|
|
28
|
+
.filter((field) => !field.nested)
|
|
29
|
+
.map((field) => createConfigFilterGenotype(config, field, sample));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function createConfigFilterInfo(config: ConfigJsonFieldInfo, field: FieldMetadataWrapper): ConfigFilterField {
|
|
33
|
+
return {
|
|
34
|
+
type: "info",
|
|
35
|
+
id: field.id,
|
|
36
|
+
label: () => getLabel(config, field.label || field.id),
|
|
37
|
+
description: () => getDescription(config, field.description),
|
|
38
|
+
field,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function initConfigFiltersInfo(
|
|
43
|
+
config: ConfigJsonFieldInfo,
|
|
44
|
+
metadata: VcfMetadataContainer,
|
|
45
|
+
): ConfigFilterField[] {
|
|
46
|
+
return getInfoFieldsRegex(metadata, new RegExp(`^${config.name}$`))
|
|
47
|
+
.filter((field) => !field.nested)
|
|
48
|
+
.map((field) => createConfigFilterInfo(config, field));
|
|
49
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { ConfigJsonFilterFixed } from "../../types/config";
|
|
2
|
+
import {
|
|
3
|
+
ConfigFilterAlt,
|
|
4
|
+
ConfigFilterChrom,
|
|
5
|
+
ConfigFilterFilter,
|
|
6
|
+
ConfigFilterFixed,
|
|
7
|
+
ConfigFilterId,
|
|
8
|
+
ConfigFilterPos,
|
|
9
|
+
ConfigFilterQual,
|
|
10
|
+
ConfigFilterRef,
|
|
11
|
+
} from "../../types/configFilter";
|
|
12
|
+
import { UnexpectedEnumValueException } from "../error.ts";
|
|
13
|
+
import { getDescription, getLabel } from "./config.ts";
|
|
14
|
+
|
|
15
|
+
export function initConfigFilterFixed(config: ConfigJsonFilterFixed): ConfigFilterFixed {
|
|
16
|
+
let configFilter: ConfigFilterFixed;
|
|
17
|
+
switch (config.name) {
|
|
18
|
+
case "chrom":
|
|
19
|
+
configFilter = createConfigFilterChrom(config);
|
|
20
|
+
break;
|
|
21
|
+
case "pos":
|
|
22
|
+
configFilter = createConfigFilterPos(config);
|
|
23
|
+
break;
|
|
24
|
+
case "id":
|
|
25
|
+
configFilter = createConfigFilterId(config);
|
|
26
|
+
break;
|
|
27
|
+
case "ref":
|
|
28
|
+
configFilter = createConfigFilterRef(config);
|
|
29
|
+
break;
|
|
30
|
+
case "alt":
|
|
31
|
+
configFilter = createConfigFilterAlt(config);
|
|
32
|
+
break;
|
|
33
|
+
case "qual":
|
|
34
|
+
configFilter = createConfigFilterQual(config);
|
|
35
|
+
break;
|
|
36
|
+
case "filter":
|
|
37
|
+
configFilter = createConfigFilterFilter(config);
|
|
38
|
+
break;
|
|
39
|
+
default:
|
|
40
|
+
throw new UnexpectedEnumValueException(config["name"]);
|
|
41
|
+
}
|
|
42
|
+
return configFilter;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function createConfigFilterChrom(config: ConfigJsonFilterFixed): ConfigFilterChrom {
|
|
46
|
+
return {
|
|
47
|
+
type: "fixed",
|
|
48
|
+
id: "chrom",
|
|
49
|
+
label: () => getLabel(config, "Chromosome"),
|
|
50
|
+
description: () => getDescription(config),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function createConfigFilterPos(config: ConfigJsonFilterFixed): ConfigFilterPos {
|
|
55
|
+
return {
|
|
56
|
+
type: "fixed",
|
|
57
|
+
id: "pos",
|
|
58
|
+
label: () => getLabel(config, "Position"),
|
|
59
|
+
description: () => getDescription(config),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function createConfigFilterId(config: ConfigJsonFilterFixed): ConfigFilterId {
|
|
64
|
+
return {
|
|
65
|
+
type: "fixed",
|
|
66
|
+
id: "id",
|
|
67
|
+
label: () => getLabel(config, "Identifiers"),
|
|
68
|
+
description: () => getDescription(config),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function createConfigFilterRef(config: ConfigJsonFilterFixed): ConfigFilterRef {
|
|
73
|
+
return {
|
|
74
|
+
type: "fixed",
|
|
75
|
+
id: "ref",
|
|
76
|
+
label: () => getLabel(config, "Reference"),
|
|
77
|
+
description: () => getDescription(config),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function createConfigFilterAlt(config: ConfigJsonFilterFixed): ConfigFilterAlt {
|
|
82
|
+
return {
|
|
83
|
+
type: "fixed",
|
|
84
|
+
id: "alt",
|
|
85
|
+
label: () => getLabel(config, "Alt"),
|
|
86
|
+
description: () => getDescription(config),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function createConfigFilterQual(config: ConfigJsonFilterFixed): ConfigFilterQual {
|
|
91
|
+
return {
|
|
92
|
+
type: "fixed",
|
|
93
|
+
id: "qual",
|
|
94
|
+
label: () => getLabel(config, "Quality"),
|
|
95
|
+
description: () => getDescription(config),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function createConfigFilterFilter(config: ConfigJsonFilterFixed): ConfigFilterFilter {
|
|
100
|
+
return {
|
|
101
|
+
type: "fixed",
|
|
102
|
+
id: "filter",
|
|
103
|
+
label: () => getLabel(config, "Filter"),
|
|
104
|
+
description: () => getDescription(config),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { ConfigJsonFieldInfo, ConfigJsonSort, ConfigJsonSortOrder } from "../../types/config";
|
|
2
|
+
import { ConfigSort, ConfigSortOrder, ConfigSorts } from "../../types/configSort";
|
|
3
|
+
import { MetadataContainer, VcfMetadataContainer } from "../api.ts";
|
|
4
|
+
import { getInfoField } from "../vcf.ts";
|
|
5
|
+
|
|
6
|
+
export function initConfigSorts(configs: ConfigJsonSort[], metadata: MetadataContainer): ConfigSorts {
|
|
7
|
+
return configs
|
|
8
|
+
.flatMap((configStaticSort) => createConfigSort(configStaticSort, metadata.records))
|
|
9
|
+
.filter((configSort) => configSort !== null);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function createConfigSortOrders(config: ConfigJsonSort, metadata: VcfMetadataContainer): ConfigSortOrder[] {
|
|
13
|
+
const configSortOrders = config.orders.map((order) => createConfigSortOrder(order, metadata));
|
|
14
|
+
return configSortOrders.filter((configSortOrder) => configSortOrder !== null);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function createConfigSort(config: ConfigJsonSort, metadata: VcfMetadataContainer): ConfigSort | null {
|
|
18
|
+
const orders = createConfigSortOrders(config, metadata);
|
|
19
|
+
return orders.length !== 0 ? { selected: config.selected, orders } : null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function createConfigSortOrder(order: ConfigJsonSortOrder, metadata: VcfMetadataContainer) {
|
|
23
|
+
let configSortOrder: ConfigSortOrder | null;
|
|
24
|
+
switch (order.field.type) {
|
|
25
|
+
case "info":
|
|
26
|
+
configSortOrder = createConfigSortOrderInfo(order, metadata);
|
|
27
|
+
break;
|
|
28
|
+
case "fixed":
|
|
29
|
+
case "genotype":
|
|
30
|
+
case "composed":
|
|
31
|
+
case "format":
|
|
32
|
+
throw new Error(`unsupported config filter type '${order.field.type}'`); // not exposed by vip-report-api
|
|
33
|
+
}
|
|
34
|
+
return configSortOrder;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function createConfigSortOrderInfo(
|
|
38
|
+
configStatic: ConfigJsonSortOrder,
|
|
39
|
+
metadata: VcfMetadataContainer,
|
|
40
|
+
): ConfigSortOrder | null {
|
|
41
|
+
const configField: ConfigJsonFieldInfo = configStatic.field as ConfigJsonFieldInfo;
|
|
42
|
+
const field = getInfoField(metadata, configField.name);
|
|
43
|
+
return field !== undefined ? { direction: configStatic.direction, field: field } : null;
|
|
44
|
+
}
|