@genspectrum/dashboard-components 0.1.1
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/LICENSE +661 -0
- package/README.md +109 -0
- package/custom-elements.json +1587 -0
- package/dist/dashboard-components.js +7322 -0
- package/dist/dashboard-components.js.map +1 -0
- package/dist/genspectrum-components.d.ts +298 -0
- package/dist/style.css +2930 -0
- package/package.json +109 -0
- package/src/constants.ts +6 -0
- package/src/index.ts +1 -0
- package/src/lapisApi/ReferenceGenome.ts +30 -0
- package/src/lapisApi/__mockData__/referenceGenome.json +58 -0
- package/src/lapisApi/lapisApi.ts +99 -0
- package/src/lapisApi/lapisTypes.ts +51 -0
- package/src/operator/Dataset.ts +3 -0
- package/src/operator/DivisionOperator.spec.ts +27 -0
- package/src/operator/DivisionOperator.ts +60 -0
- package/src/operator/FetchAggregatedOperator.ts +44 -0
- package/src/operator/FetchInsertionsOperator.ts +24 -0
- package/src/operator/FetchSubstitutionsOrDeletionsOperator.ts +49 -0
- package/src/operator/FillMissingOperator.spec.ts +26 -0
- package/src/operator/FillMissingOperator.ts +30 -0
- package/src/operator/GroupByAndSumOperator.spec.ts +26 -0
- package/src/operator/GroupByAndSumOperator.ts +26 -0
- package/src/operator/GroupByOperator.spec.ts +43 -0
- package/src/operator/GroupByOperator.ts +32 -0
- package/src/operator/MapOperator.spec.ts +13 -0
- package/src/operator/MapOperator.ts +16 -0
- package/src/operator/MockOperator.spec.ts +11 -0
- package/src/operator/MockOperator.ts +12 -0
- package/src/operator/Operator.ts +5 -0
- package/src/operator/SlidingOperator.spec.ts +52 -0
- package/src/operator/SlidingOperator.ts +23 -0
- package/src/operator/SortOperator.spec.ts +13 -0
- package/src/operator/SortOperator.ts +16 -0
- package/src/preact/LapisUrlContext.ts +3 -0
- package/src/preact/ReferenceGenomeContext.ts +5 -0
- package/src/preact/components/SegmentSelector.tsx +62 -0
- package/src/preact/components/chart.stories.tsx +42 -0
- package/src/preact/components/chart.tsx +32 -0
- package/src/preact/components/checkbox-selector.stories.tsx +56 -0
- package/src/preact/components/checkbox-selector.tsx +46 -0
- package/src/preact/components/confidence-interval-selector.tsx +45 -0
- package/src/preact/components/csv-download-button.stories.tsx +25 -0
- package/src/preact/components/csv-download-button.tsx +51 -0
- package/src/preact/components/error-display.stories.tsx +22 -0
- package/src/preact/components/error-display.tsx +5 -0
- package/src/preact/components/headline.stories.tsx +29 -0
- package/src/preact/components/headline.tsx +16 -0
- package/src/preact/components/info.stories.tsx +22 -0
- package/src/preact/components/info.tsx +16 -0
- package/src/preact/components/loading-display.stories.tsx +20 -0
- package/src/preact/components/loading-display.tsx +5 -0
- package/src/preact/components/min-max-percent-slider.css +40 -0
- package/src/preact/components/min-max-range-slider.tsx +95 -0
- package/src/preact/components/mutation-type-selector.tsx +30 -0
- package/src/preact/components/no-data-display.stories.tsx +20 -0
- package/src/preact/components/no-data-display.tsx +5 -0
- package/src/preact/components/percent-intput.tsx +49 -0
- package/src/preact/components/proportion-selector-dropdown.stories.tsx +66 -0
- package/src/preact/components/proportion-selector-dropdown.tsx +33 -0
- package/src/preact/components/proportion-selector.stories.tsx +81 -0
- package/src/preact/components/proportion-selector.tsx +43 -0
- package/src/preact/components/scaling-selector.stories.tsx +25 -0
- package/src/preact/components/scaling-selector.tsx +36 -0
- package/src/preact/components/select.stories.tsx +42 -0
- package/src/preact/components/select.tsx +21 -0
- package/src/preact/components/table.stories.tsx +24 -0
- package/src/preact/components/table.tsx +51 -0
- package/src/preact/components/tabs.stories.tsx +60 -0
- package/src/preact/components/tabs.tsx +49 -0
- package/src/preact/dateRangeSelector/date-range-selector.stories.tsx +32 -0
- package/src/preact/dateRangeSelector/date-range-selector.tsx +228 -0
- package/src/preact/dateRangeSelector/dateConversion.ts +8 -0
- package/src/preact/locationFilter/__mockData__/aggregated.json +775 -0
- package/src/preact/locationFilter/fetchAutocompletionList.spec.ts +36 -0
- package/src/preact/locationFilter/fetchAutocompletionList.ts +43 -0
- package/src/preact/locationFilter/location-filter.stories.tsx +50 -0
- package/src/preact/locationFilter/location-filter.tsx +112 -0
- package/src/preact/mutationComparison/__mockData__/nucleotideMutationsOtherVariant.json +295 -0
- package/src/preact/mutationComparison/__mockData__/nucleotideMutationsSomeVariant.json +304 -0
- package/src/preact/mutationComparison/fetchMutationData.spec.ts +118 -0
- package/src/preact/mutationComparison/getMutationComparisonTableData.spec.ts +125 -0
- package/src/preact/mutationComparison/getMutationComparisonTableData.ts +40 -0
- package/src/preact/mutationComparison/mutation-comparison-table.tsx +43 -0
- package/src/preact/mutationComparison/mutation-comparison-venn.tsx +122 -0
- package/src/preact/mutationComparison/mutation-comparison.stories.tsx +152 -0
- package/src/preact/mutationComparison/mutation-comparison.tsx +179 -0
- package/src/preact/mutationComparison/queryMutationData.ts +53 -0
- package/src/preact/mutationFilter/mutation-filter.stories.tsx +164 -0
- package/src/preact/mutationFilter/mutation-filter.tsx +268 -0
- package/src/preact/mutationFilter/parseAndValidateMutation.ts +54 -0
- package/src/preact/mutationFilter/parseMutation.spec.ts +150 -0
- package/src/preact/mutationFilter/sequenceTypeFromSegment.spec.ts +66 -0
- package/src/preact/mutationFilter/sequenceTypeFromSegment.ts +20 -0
- package/src/preact/mutations/__mockData__/nucleotideInsertions.json +252 -0
- package/src/preact/mutations/__mockData__/nucleotideMutations.json +880 -0
- package/src/preact/mutations/getInsertionsTableData.spec.ts +36 -0
- package/src/preact/mutations/getInsertionsTableData.ts +10 -0
- package/src/preact/mutations/getMutationsGridData.spec.ts +135 -0
- package/src/preact/mutations/getMutationsGridData.ts +92 -0
- package/src/preact/mutations/getMutationsTableData.spec.ts +94 -0
- package/src/preact/mutations/getMutationsTableData.ts +17 -0
- package/src/preact/mutations/mutations-grid.tsx +84 -0
- package/src/preact/mutations/mutations-insertions-table.tsx +33 -0
- package/src/preact/mutations/mutations-table.tsx +47 -0
- package/src/preact/mutations/mutations.stories.tsx +95 -0
- package/src/preact/mutations/mutations.tsx +192 -0
- package/src/preact/mutations/queryMutations.ts +55 -0
- package/src/preact/prevalenceOverTime/__mockData__/denominator.json +1700 -0
- package/src/preact/prevalenceOverTime/__mockData__/denominatorOneVariant.json +608 -0
- package/src/preact/prevalenceOverTime/__mockData__/numeratorEG.json +1560 -0
- package/src/preact/prevalenceOverTime/__mockData__/numeratorJN1.json +592 -0
- package/src/preact/prevalenceOverTime/__mockData__/numeratorOneVariant.json +604 -0
- package/src/preact/prevalenceOverTime/getPrevalenceOverTimeTableData.spec.ts +67 -0
- package/src/preact/prevalenceOverTime/getPrevalenceOverTimeTableData.ts +18 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time-bar-chart.tsx +105 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time-bubble-chart.tsx +86 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time-line-chart.tsx +141 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time-table.tsx +46 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time.stories.tsx +165 -0
- package/src/preact/prevalenceOverTime/prevalence-over-time.tsx +202 -0
- package/src/preact/relativeGrowthAdvantage/__mockData__/denominator.json +376 -0
- package/src/preact/relativeGrowthAdvantage/__mockData__/numerator.json +332 -0
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage-chart.tsx +138 -0
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.stories.tsx +71 -0
- package/src/preact/relativeGrowthAdvantage/relative-growth-advantage.tsx +136 -0
- package/src/preact/shared/charts/LogitScale.ts +48 -0
- package/src/preact/shared/charts/colors.ts +26 -0
- package/src/preact/shared/charts/confideceInterval.ts +29 -0
- package/src/preact/shared/charts/getYAxisScale.ts +16 -0
- package/src/preact/shared/charts/scales.ts +16 -0
- package/src/preact/shared/icons/DeleteIcon.tsx +17 -0
- package/src/preact/shared/sort/sortInsertions.spec.ts +47 -0
- package/src/preact/shared/sort/sortInsertions.ts +21 -0
- package/src/preact/shared/sort/sortMutationPositions.spec.ts +31 -0
- package/src/preact/shared/sort/sortMutationPositions.ts +14 -0
- package/src/preact/shared/sort/sortSubstitutionsAndDeletions.spec.ts +47 -0
- package/src/preact/shared/sort/sortSubstitutionsAndDeletions.ts +17 -0
- package/src/preact/shared/table/formatProportion.ts +3 -0
- package/src/preact/textInput/__mockData__/aggregated_hosts.json +24 -0
- package/src/preact/textInput/fetchAutocompleteList.ts +9 -0
- package/src/preact/textInput/text-input.stories.tsx +49 -0
- package/src/preact/textInput/text-input.tsx +73 -0
- package/src/preact/useQuery.ts +27 -0
- package/src/query/queryInsertions.ts +14 -0
- package/src/query/queryPrevalenceOverTime.ts +126 -0
- package/src/query/queryRelativeGrowthAdvantage.ts +131 -0
- package/src/query/querySubstitutionsOrDeletions.ts +19 -0
- package/src/styles/tailwind.css +3 -0
- package/src/styles/tailwind.d.ts +3 -0
- package/src/types.ts +23 -0
- package/src/utils/mutations.spec.ts +64 -0
- package/src/utils/mutations.ts +165 -0
- package/src/utils/temporal.spec.ts +97 -0
- package/src/utils/temporal.ts +348 -0
- package/src/utils/test-utils.ts +5 -0
- package/src/utils/type-utils.ts +15 -0
- package/src/utils/utils.spec.ts +16 -0
- package/src/utils/utils.ts +38 -0
- package/src/web-components/PreactLitAdapter.tsx +62 -0
- package/src/web-components/PreactLitAdapterWithGridJsStyles.tsx +12 -0
- package/src/web-components/app.ts +51 -0
- package/src/web-components/display/index.ts +4 -0
- package/src/web-components/display/mutation-comparison-component.stories.ts +138 -0
- package/src/web-components/display/mutation-comparison-component.tsx +31 -0
- package/src/web-components/display/mutations-component.stories.ts +107 -0
- package/src/web-components/display/mutations-component.tsx +27 -0
- package/src/web-components/display/prevalence-over-time-component.stories.ts +205 -0
- package/src/web-components/display/prevalence-over-time-component.tsx +46 -0
- package/src/web-components/display/relative-growth-advantage-component.stories.ts +89 -0
- package/src/web-components/display/relative-growth-advantage-component.tsx +37 -0
- package/src/web-components/index.ts +3 -0
- package/src/web-components/input/date-range-selector-component.stories.ts +53 -0
- package/src/web-components/input/date-range-selector-component.tsx +33 -0
- package/src/web-components/input/index.ts +4 -0
- package/src/web-components/input/location-filter-component.stories.ts +184 -0
- package/src/web-components/input/location-filter-component.tsx +68 -0
- package/src/web-components/input/location-filter.mdx +25 -0
- package/src/web-components/input/mutation-filter-component.stories.ts +97 -0
- package/src/web-components/input/mutation-filter-component.tsx +27 -0
- package/src/web-components/input/text-input-component.stories.ts +92 -0
- package/src/web-components/input/text-input-component.tsx +30 -0
- package/src/web-components/lapis-context.ts +3 -0
- package/src/web-components/reference-genome-context.ts +5 -0
- package/src/web-components/withinShadowRoot.story.ts +34 -0
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { type FunctionComponent } from 'preact';
|
|
2
|
+
import { type Dispatch, type StateUpdater, useContext, useState } from 'preact/hooks';
|
|
3
|
+
|
|
4
|
+
import { getInsertionsTableData } from './getInsertionsTableData';
|
|
5
|
+
import { getMutationsTableData } from './getMutationsTableData';
|
|
6
|
+
import { MutationsGrid } from './mutations-grid';
|
|
7
|
+
import { InsertionsTable } from './mutations-insertions-table';
|
|
8
|
+
import MutationsTable from './mutations-table';
|
|
9
|
+
import { filterMutationsData, queryMutationsData } from './queryMutations';
|
|
10
|
+
import {
|
|
11
|
+
type InsertionEntry,
|
|
12
|
+
type LapisFilter,
|
|
13
|
+
type SequenceType,
|
|
14
|
+
type SubstitutionOrDeletionEntry,
|
|
15
|
+
} from '../../types';
|
|
16
|
+
import { LapisUrlContext } from '../LapisUrlContext';
|
|
17
|
+
import { type DisplayedSegment, SegmentSelector, useDisplayedSegments } from '../components/SegmentSelector';
|
|
18
|
+
import { CsvDownloadButton } from '../components/csv-download-button';
|
|
19
|
+
import { ErrorDisplay } from '../components/error-display';
|
|
20
|
+
import Headline from '../components/headline';
|
|
21
|
+
import Info from '../components/info';
|
|
22
|
+
import { LoadingDisplay } from '../components/loading-display';
|
|
23
|
+
import { type DisplayedMutationType, MutationTypeSelector } from '../components/mutation-type-selector';
|
|
24
|
+
import { NoDataDisplay } from '../components/no-data-display';
|
|
25
|
+
import type { ProportionInterval } from '../components/proportion-selector';
|
|
26
|
+
import { ProportionSelectorDropdown } from '../components/proportion-selector-dropdown';
|
|
27
|
+
import Tabs from '../components/tabs';
|
|
28
|
+
import { useQuery } from '../useQuery';
|
|
29
|
+
|
|
30
|
+
export type View = 'table' | 'grid' | 'insertions';
|
|
31
|
+
|
|
32
|
+
export interface MutationsProps {
|
|
33
|
+
variant: LapisFilter;
|
|
34
|
+
sequenceType: SequenceType;
|
|
35
|
+
views: View[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const Mutations: FunctionComponent<MutationsProps> = ({ variant, sequenceType, views }) => {
|
|
39
|
+
const lapis = useContext(LapisUrlContext);
|
|
40
|
+
const { data, error, isLoading } = useQuery(async () => {
|
|
41
|
+
return queryMutationsData(variant, sequenceType, lapis);
|
|
42
|
+
}, [variant, sequenceType, lapis]);
|
|
43
|
+
|
|
44
|
+
const headline = 'Mutations';
|
|
45
|
+
if (isLoading) {
|
|
46
|
+
return (
|
|
47
|
+
<Headline heading={headline}>
|
|
48
|
+
<LoadingDisplay />
|
|
49
|
+
</Headline>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (error !== null) {
|
|
54
|
+
return (
|
|
55
|
+
<Headline heading={headline}>
|
|
56
|
+
<ErrorDisplay error={error} />
|
|
57
|
+
</Headline>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (data === null) {
|
|
62
|
+
return (
|
|
63
|
+
<Headline heading={headline}>
|
|
64
|
+
<NoDataDisplay />
|
|
65
|
+
</Headline>
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<Headline heading={headline}>
|
|
71
|
+
<MutationsTabs mutationsData={data} sequenceType={sequenceType} views={views} />
|
|
72
|
+
</Headline>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
type MutationTabsProps = {
|
|
77
|
+
mutationsData: { insertions: InsertionEntry[]; substitutionsOrDeletions: SubstitutionOrDeletionEntry[] };
|
|
78
|
+
sequenceType: SequenceType;
|
|
79
|
+
views: View[];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const MutationsTabs: FunctionComponent<MutationTabsProps> = ({ mutationsData, sequenceType, views }) => {
|
|
83
|
+
const [proportionInterval, setProportionInterval] = useState({ min: 0.05, max: 1 });
|
|
84
|
+
|
|
85
|
+
const [displayedSegments, setDisplayedSegments] = useDisplayedSegments(sequenceType);
|
|
86
|
+
const [displayedMutationTypes, setDisplayedMutationTypes] = useState<DisplayedMutationType[]>([
|
|
87
|
+
{ label: 'Substitutions', checked: true, type: 'substitution' },
|
|
88
|
+
{ label: 'Deletions', checked: true, type: 'deletion' },
|
|
89
|
+
]);
|
|
90
|
+
|
|
91
|
+
const filteredData = filterMutationsData(mutationsData, displayedSegments, displayedMutationTypes);
|
|
92
|
+
|
|
93
|
+
const getTab = (view: View) => {
|
|
94
|
+
switch (view) {
|
|
95
|
+
case 'table':
|
|
96
|
+
return {
|
|
97
|
+
title: 'Table',
|
|
98
|
+
content: <MutationsTable data={filteredData.tableData} proportionInterval={proportionInterval} />,
|
|
99
|
+
};
|
|
100
|
+
case 'grid':
|
|
101
|
+
return {
|
|
102
|
+
title: 'Grid',
|
|
103
|
+
content: (
|
|
104
|
+
<MutationsGrid
|
|
105
|
+
data={filteredData.gridData}
|
|
106
|
+
sequenceType={sequenceType}
|
|
107
|
+
proportionInterval={proportionInterval}
|
|
108
|
+
/>
|
|
109
|
+
),
|
|
110
|
+
};
|
|
111
|
+
case 'insertions':
|
|
112
|
+
return {
|
|
113
|
+
title: 'Insertions',
|
|
114
|
+
content: <InsertionsTable data={filteredData.insertions} />,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const tabs = views.map((view) => getTab(view));
|
|
120
|
+
|
|
121
|
+
const toolbar = (activeTab: string) => (
|
|
122
|
+
<Toolbar
|
|
123
|
+
activeTab={activeTab}
|
|
124
|
+
displayedSegments={displayedSegments}
|
|
125
|
+
setDisplayedSegments={setDisplayedSegments}
|
|
126
|
+
displayedMutationTypes={displayedMutationTypes}
|
|
127
|
+
setDisplayedMutationTypes={setDisplayedMutationTypes}
|
|
128
|
+
filteredData={filteredData}
|
|
129
|
+
proportionInterval={proportionInterval}
|
|
130
|
+
setProportionInterval={setProportionInterval}
|
|
131
|
+
/>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return <Tabs tabs={tabs} toolbar={toolbar} />;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
type ToolbarProps = {
|
|
138
|
+
activeTab: string;
|
|
139
|
+
displayedSegments: DisplayedSegment[];
|
|
140
|
+
setDisplayedSegments: (segments: DisplayedSegment[]) => void;
|
|
141
|
+
displayedMutationTypes: DisplayedMutationType[];
|
|
142
|
+
setDisplayedMutationTypes: (types: DisplayedMutationType[]) => void;
|
|
143
|
+
filteredData: { tableData: SubstitutionOrDeletionEntry[]; insertions: InsertionEntry[] };
|
|
144
|
+
proportionInterval: ProportionInterval;
|
|
145
|
+
setProportionInterval: Dispatch<StateUpdater<ProportionInterval>>;
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const Toolbar: FunctionComponent<ToolbarProps> = ({
|
|
149
|
+
activeTab,
|
|
150
|
+
displayedSegments,
|
|
151
|
+
setDisplayedSegments,
|
|
152
|
+
displayedMutationTypes,
|
|
153
|
+
setDisplayedMutationTypes,
|
|
154
|
+
filteredData,
|
|
155
|
+
proportionInterval,
|
|
156
|
+
setProportionInterval,
|
|
157
|
+
}) => {
|
|
158
|
+
return (
|
|
159
|
+
<div class='flex flex-row'>
|
|
160
|
+
<SegmentSelector displayedSegments={displayedSegments} setDisplayedSegments={setDisplayedSegments} />
|
|
161
|
+
{activeTab === 'Table' && (
|
|
162
|
+
<MutationTypeSelector
|
|
163
|
+
setDisplayedMutationTypes={setDisplayedMutationTypes}
|
|
164
|
+
displayedMutationTypes={displayedMutationTypes}
|
|
165
|
+
/>
|
|
166
|
+
)}
|
|
167
|
+
{(activeTab === 'Table' || activeTab === 'Grid') && (
|
|
168
|
+
<>
|
|
169
|
+
<ProportionSelectorDropdown
|
|
170
|
+
proportionInterval={proportionInterval}
|
|
171
|
+
setMinProportion={(min) => setProportionInterval((prev) => ({ ...prev, min }))}
|
|
172
|
+
setMaxProportion={(max) => setProportionInterval((prev) => ({ ...prev, max }))}
|
|
173
|
+
openDirection={'left'}
|
|
174
|
+
/>
|
|
175
|
+
<CsvDownloadButton
|
|
176
|
+
className='mx-1 btn btn-xs'
|
|
177
|
+
getData={() => getMutationsTableData(filteredData.tableData, proportionInterval)}
|
|
178
|
+
filename='substitutionsAndDeletions.csv'
|
|
179
|
+
/>
|
|
180
|
+
</>
|
|
181
|
+
)}
|
|
182
|
+
{activeTab === 'Insertions' && (
|
|
183
|
+
<CsvDownloadButton
|
|
184
|
+
className='mx-1 btn btn-xs'
|
|
185
|
+
getData={() => getInsertionsTableData(filteredData.insertions)}
|
|
186
|
+
filename='insertions.csv'
|
|
187
|
+
/>
|
|
188
|
+
)}
|
|
189
|
+
<Info className='mx-1' content='Info for mutations' />
|
|
190
|
+
</div>
|
|
191
|
+
);
|
|
192
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { queryInsertions } from '../../query/queryInsertions';
|
|
2
|
+
import { querySubstitutionsOrDeletions } from '../../query/querySubstitutionsOrDeletions';
|
|
3
|
+
import {
|
|
4
|
+
type InsertionEntry,
|
|
5
|
+
type LapisFilter,
|
|
6
|
+
type MutationEntry,
|
|
7
|
+
type SubstitutionOrDeletionEntry,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
import { type DisplayedSegment } from '../components/SegmentSelector';
|
|
10
|
+
import { type DisplayedMutationType } from '../components/mutation-type-selector';
|
|
11
|
+
|
|
12
|
+
export async function queryMutationsData(
|
|
13
|
+
variant: LapisFilter,
|
|
14
|
+
sequenceType: 'nucleotide' | 'amino acid',
|
|
15
|
+
lapis: string,
|
|
16
|
+
) {
|
|
17
|
+
const substitutionsOrDeletions = (await querySubstitutionsOrDeletions(variant, sequenceType, lapis)).content;
|
|
18
|
+
const insertions = (await queryInsertions(variant, sequenceType, lapis)).content;
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
substitutionsOrDeletions,
|
|
22
|
+
insertions,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function filterMutationsData(
|
|
27
|
+
data: { insertions: InsertionEntry[]; substitutionsOrDeletions: SubstitutionOrDeletionEntry[] },
|
|
28
|
+
displayedSegments: DisplayedSegment[],
|
|
29
|
+
displayedMutationTypes: DisplayedMutationType[],
|
|
30
|
+
) {
|
|
31
|
+
function bySelectedSegments(mutationEntry: MutationEntry) {
|
|
32
|
+
if (mutationEntry.mutation.segment === undefined) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
return displayedSegments.some(
|
|
36
|
+
(displayedSegment) =>
|
|
37
|
+
displayedSegment.segment === mutationEntry.mutation.segment && displayedSegment.checked,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const byDisplayedMutationTypes = (mutationEntry: SubstitutionOrDeletionEntry) => {
|
|
42
|
+
return displayedMutationTypes.some(
|
|
43
|
+
(displayedMutationType) =>
|
|
44
|
+
displayedMutationType.checked && displayedMutationType.type === mutationEntry.type,
|
|
45
|
+
);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
const filteredSubstitutionsOrDeletions = data.substitutionsOrDeletions.filter(bySelectedSegments);
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
insertions: data.insertions.filter(bySelectedSegments),
|
|
52
|
+
tableData: filteredSubstitutionsOrDeletions.filter(byDisplayedMutationTypes),
|
|
53
|
+
gridData: filteredSubstitutionsOrDeletions,
|
|
54
|
+
};
|
|
55
|
+
}
|