@genspectrum/dashboard-components 0.13.4 → 0.13.6
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/custom-elements.json +20 -1
- package/dist/components.d.ts +27 -21
- package/dist/components.js +136 -63
- package/dist/components.js.map +1 -1
- package/dist/util.d.ts +21 -21
- package/package.json +1 -1
- package/src/preact/components/downshift-combobox.tsx +2 -2
- package/src/preact/components/mutation-info.tsx +36 -0
- package/src/preact/locationFilter/fetchAutocompletionList.spec.ts +13 -13
- package/src/preact/locationFilter/fetchAutocompletionList.ts +55 -19
- package/src/preact/locationFilter/location-filter.stories.tsx +1 -1
- package/src/preact/locationFilter/location-filter.tsx +18 -12
- package/src/preact/mutationComparison/mutation-comparison.tsx +26 -2
- package/src/preact/mutations/mutations.tsx +5 -23
- package/src/preact/mutationsOverTime/mutations-over-time-grid.tsx +11 -5
- package/src/preact/wastewater/mutationsOverTime/wastewater-mutations-over-time.tsx +7 -1
- package/src/query/queryWastewaterMutationsOverTime.spec.ts +29 -1
- package/src/query/queryWastewaterMutationsOverTime.ts +30 -16
- package/src/web-components/input/gs-location-filter.stories.ts +1 -1
- package/src/web-components/wastewaterVisualization/gs-wastewater-mutations-over-time.tsx +9 -0
- package/standalone-bundle/dashboard-components.js +4463 -4395
- package/standalone-bundle/dashboard-components.js.map +1 -1
|
@@ -88,7 +88,35 @@ describe('queryWastewaterMutationsOverTime', () => {
|
|
|
88
88
|
);
|
|
89
89
|
|
|
90
90
|
await expect(queryWastewaterMutationsOverTime(DUMMY_LAPIS_URL, lapisFilter)).rejects.toThrowError(
|
|
91
|
-
|
|
91
|
+
/Failed to parse mutation frequency/,
|
|
92
|
+
);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('should error on invalid mutation', async () => {
|
|
96
|
+
const lapisFilter = { country: 'Germany' };
|
|
97
|
+
|
|
98
|
+
lapisRequestMocks.details(
|
|
99
|
+
{
|
|
100
|
+
country: 'Germany',
|
|
101
|
+
fields: ['date', 'location', 'nucleotideMutationFrequency', 'aminoAcidMutationFrequency'],
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
data: [
|
|
105
|
+
{
|
|
106
|
+
date: '2021-01-01',
|
|
107
|
+
location: 'Germany',
|
|
108
|
+
reference: 'organismA',
|
|
109
|
+
nucleotideMutationFrequency: JSON.stringify({
|
|
110
|
+
'not a mutation': 0.4,
|
|
111
|
+
}),
|
|
112
|
+
aminoAcidMutationFrequency: null,
|
|
113
|
+
},
|
|
114
|
+
],
|
|
115
|
+
},
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
await expect(queryWastewaterMutationsOverTime(DUMMY_LAPIS_URL, lapisFilter)).rejects.toThrowError(
|
|
119
|
+
/Failed to parse mutation: "not a mutation"/,
|
|
92
120
|
);
|
|
93
121
|
});
|
|
94
122
|
});
|
|
@@ -25,18 +25,26 @@ export async function queryWastewaterMutationsOverTime(
|
|
|
25
25
|
]);
|
|
26
26
|
const data = (await fetchData.evaluate(lapis, signal)).content;
|
|
27
27
|
|
|
28
|
-
return data.map((row) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
28
|
+
return data.map((row) => {
|
|
29
|
+
try {
|
|
30
|
+
return {
|
|
31
|
+
location: row.location as string,
|
|
32
|
+
date: toTemporalClass(parseDateStringToTemporal(row.date as string, 'day')),
|
|
33
|
+
nucleotideMutationFrequency:
|
|
34
|
+
row.nucleotideMutationFrequency !== null
|
|
35
|
+
? transformMutations(JSON.parse(row.nucleotideMutationFrequency as string))
|
|
36
|
+
: [],
|
|
37
|
+
aminoAcidMutationFrequency:
|
|
38
|
+
row.aminoAcidMutationFrequency !== null
|
|
39
|
+
? transformMutations(JSON.parse(row.aminoAcidMutationFrequency as string))
|
|
40
|
+
: [],
|
|
41
|
+
};
|
|
42
|
+
} catch (e) {
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Failed to parse row of wastewater data: ${JSON.stringify(row)}: ${(e as Error)?.message ?? 'Unknown error'}`,
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
40
48
|
}
|
|
41
49
|
|
|
42
50
|
const mutationFrequencySchema = z.record(z.number().nullable());
|
|
@@ -48,8 +56,14 @@ function transformMutations(input: unknown): { mutation: Substitution; proportio
|
|
|
48
56
|
throw new Error(`Failed to parse mutation frequency: ${mutationFrequency.error.message}`);
|
|
49
57
|
}
|
|
50
58
|
|
|
51
|
-
return Object.entries(mutationFrequency.data).map(([key, value]) =>
|
|
52
|
-
mutation
|
|
53
|
-
|
|
54
|
-
|
|
59
|
+
return Object.entries(mutationFrequency.data).map(([key, value]) => {
|
|
60
|
+
const mutation = SubstitutionClass.parse(key);
|
|
61
|
+
if (mutation === null) {
|
|
62
|
+
throw new Error(`Failed to parse mutation: "${key}"`);
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
mutation,
|
|
66
|
+
proportion: value,
|
|
67
|
+
};
|
|
68
|
+
});
|
|
55
69
|
}
|
|
@@ -219,7 +219,7 @@ export const FiresEvent: StoryObj<LocationFilterProps> = {
|
|
|
219
219
|
|
|
220
220
|
await step('Select Asia', async () => {
|
|
221
221
|
await userEvent.type(inputField(), 'Asia');
|
|
222
|
-
await userEvent.click(canvas.getByRole('option', { name:
|
|
222
|
+
await userEvent.click(canvas.getByRole('option', { name: /^Asia.*Asia$/ }));
|
|
223
223
|
|
|
224
224
|
await waitFor(() => {
|
|
225
225
|
return expect(listenerMock.mock.calls.at(-1)![0].detail).toStrictEqual({
|
|
@@ -65,6 +65,14 @@ export class WastewaterMutationsOverTimeComponent extends PreactLitAdapterWithGr
|
|
|
65
65
|
@property({ type: String })
|
|
66
66
|
height: string = '700px';
|
|
67
67
|
|
|
68
|
+
/**
|
|
69
|
+
* The maximum number of grid rows to display.
|
|
70
|
+
*
|
|
71
|
+
* Visit https://genspectrum.github.io/dashboard-components/?path=/docs/components-size-of-components--docs for more information.
|
|
72
|
+
*/
|
|
73
|
+
@property({ type: Number })
|
|
74
|
+
maxNumberOfGridRows: number = 100;
|
|
75
|
+
|
|
68
76
|
override render() {
|
|
69
77
|
return (
|
|
70
78
|
<WastewaterMutationsOverTime
|
|
@@ -72,6 +80,7 @@ export class WastewaterMutationsOverTimeComponent extends PreactLitAdapterWithGr
|
|
|
72
80
|
sequenceType={this.sequenceType}
|
|
73
81
|
width={this.width}
|
|
74
82
|
height={this.height}
|
|
83
|
+
maxNumberOfGridRows={this.maxNumberOfGridRows}
|
|
75
84
|
/>
|
|
76
85
|
);
|
|
77
86
|
}
|