-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwastewaterConfig.ts
More file actions
427 lines (409 loc) · 14.6 KB
/
Copy pathwastewaterConfig.ts
File metadata and controls
427 lines (409 loc) · 14.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
import type { MutationAnnotation } from '@genspectrum/dashboard-components/util';
import type { ResistanceMutationCollectionConfig } from '../components/views/wasap/wasapPageConfig';
import { VARIANT_TIME_FRAME, type WasapPageConfig } from '../components/views/wasap/wasapPageConfig';
export const wastewaterOrganisms = {
covid: 'covid',
rsvA: 'rsv-a',
rsvB: 'rsv-b',
} as const;
export type WastewaterOrganismName = (typeof wastewaterOrganisms)[keyof typeof wastewaterOrganisms];
export const wastewaterPathFragment = 'swiss-wastewater';
export const wastewaterOrganismConfigs: Record<WastewaterOrganismName, WasapPageConfig> = {
[wastewaterOrganisms.covid]: {
internalName: wastewaterOrganisms.covid,
name: 'SARS-CoV-2',
path: `/${wastewaterPathFragment}/covid`,
description: 'Analyze SARS-CoV-2 data that was collected by the WISE project.',
linkTemplate: {
nucleotideMutation:
'https://open.cov-spectrum.org/explore/World/AllSamples/AllTimes/variants?nucMutations={{mutation}}',
aminoAcidMutation:
'https://open.cov-spectrum.org/explore/World/AllSamples/AllTimes/variants?aaMutations={{mutation}}',
},
manualAnalysisModeEnabled: true,
variantAnalysisModeEnabled: true,
resistanceAnalysisModeEnabled: true,
untrackedAnalysisModeEnabled: true,
collectionAnalysisModeEnabled: true,
defaultAnalysisMode: 'resistance',
resistanceMutationCollections: [
{
collectionId: 4,
name: '3CLpro',
annotationSymbol: 'c',
description:
'SARS-CoV-2 3C-like protease (3CLpro, or Mpro for Main protease) inhibitor resistance mutation as per <a class="link" href="https://covdb.stanford.edu/drms">Stanford Coronavirus Antiviral & Resistance database</a> (last updated on 21 August 2024).',
},
{
collectionId: 5,
name: 'RdRp',
annotationSymbol: 'r',
description:
'SARS-CoV-2 RNA-dependent RNA polymerase (RdRP) inhibitor resistance mutation as per <a class="link" href="https://covdb.stanford.edu/drms">Stanford Coronavirus Antiviral & Resistance database</a> (last updated on 21 August 2024).',
},
{
collectionId: 6,
name: 'Spike',
annotationSymbol: 's',
description:
'SARS-CoV-2 Spike monoclonal antibody (mAb) resistance mutation as per <a class="link" href="https://covdb.stanford.edu/drms">Stanford Coronavirus Antiviral & Resistance database</a> (last updated on 21 August 2024).',
},
] satisfies ResistanceMutationCollectionConfig[],
lapisBaseUrl: 'https://lapis.wasap.genspectrum.org/covid',
samplingDateField: 'samplingDate',
locationNameField: 'locationName',
predefinedVariantsSource: {
collectionsUserId: 3,
collectionsTag: '#pango-lineage',
variantSourceLabel: 'Nextclade',
},
clinicalLapis: {
lapisBaseUrl: 'https://lapis.cov-spectrum.org/open/v2',
dateField: 'date',
cladeField: 'nextstrainClade',
lineageField: 'nextcladePangoLineage',
},
browseDataUrl: 'https://db.wasap.genspectrum.org/covid/search',
browseDataDescription: 'Browse the data in the W-ASAP Loculus instance.',
collectionsApiBaseUrl: 'https://cov-spectrum.org/api/v2',
collectionTitleFilter: 'wastewater',
defaultLocationName: 'Zürich (ZH)',
clinicalSequenceCountWarningThreshold: 50,
filterDefaults: {
manual: {
mode: 'manual',
sequenceType: 'nucleotide',
mutations: undefined,
},
variant: {
mode: 'variant',
signatureType: 'computed',
sequenceType: 'nucleotide',
variant: 'XFG*',
minProportion: 0.8,
minCount: 15,
minJaccard: 0.75,
timeFrame: VARIANT_TIME_FRAME.all,
collectionId: 4961,
},
resistance: {
mode: 'resistance',
sequenceType: 'amino acid',
resistanceSet: 'Spike',
},
untracked: {
mode: 'untracked',
sequenceType: 'nucleotide',
excludeSet: 'predefined',
},
collection: {
mode: 'collection',
collectionId: 1,
},
},
},
[wastewaterOrganisms.rsvA]: {
internalName: wastewaterOrganisms.rsvA,
name: 'RSV-A',
path: `/${wastewaterPathFragment}/rsv-a`,
description: 'Analyze RSV-A data that was collected by the WISE project.',
linkTemplate: {
nucleotideMutation:
'https://genspectrum.org/rsv-a/single-variant?sampleCollectionDateRangeLower=Last+year&nucleotideMutations={{mutation}}',
aminoAcidMutation:
'https://genspectrum.org/rsv-a/single-variant?sampleCollectionDateRangeLower=Last+year&aminoAcidMutations={{mutation}}',
},
manualAnalysisModeEnabled: true,
variantAnalysisModeEnabled: true,
lapisBaseUrl: 'https://lapis.wasap.genspectrum.org/rsva',
samplingDateField: 'samplingDate',
locationNameField: 'locationName',
clinicalLapis: {
lapisBaseUrl: 'https://lapis.pathoplexus.org/rsv-a',
dateField: 'sampleCollectionDateRangeLower',
lineageField: 'lineage',
},
browseDataUrl: 'https://db.wasap.genspectrum.org/rsva/search',
browseDataDescription: 'Browse the data in the W-ASAP Loculus instance.',
defaultLocationName: 'Geneva',
clinicalSequenceCountWarningThreshold: 50,
filterDefaults: {
manual: {
mode: 'manual',
sequenceType: 'nucleotide',
mutations: undefined,
},
variant: {
mode: 'variant',
signatureType: 'computed',
sequenceType: 'nucleotide',
variant: 'A.D.1*',
minProportion: 0.8,
minCount: 15,
minJaccard: 0.75,
timeFrame: VARIANT_TIME_FRAME.all,
},
},
},
[wastewaterOrganisms.rsvB]: {
internalName: wastewaterOrganisms.rsvB,
name: 'RSV-B',
path: `/${wastewaterPathFragment}/rsv-b`,
description: 'Analyze RSV-B data that was collected by the WISE project.',
linkTemplate: {
nucleotideMutation:
'https://genspectrum.org/rsv-b/single-variant?sampleCollectionDateRangeLower=Last+year&nucleotideMutations={{mutation}}',
aminoAcidMutation:
'https://genspectrum.org/rsv-b/single-variant?sampleCollectionDateRangeLower=Last+year&aminoAcidMutations={{mutation}}',
},
manualAnalysisModeEnabled: true,
variantAnalysisModeEnabled: true,
lapisBaseUrl: 'https://lapis.wasap.genspectrum.org/rsvb',
samplingDateField: 'samplingDate',
locationNameField: 'locationName',
clinicalLapis: {
lapisBaseUrl: 'https://lapis.pathoplexus.org/rsv-b',
dateField: 'sampleCollectionDateRangeLower',
lineageField: 'lineage',
},
browseDataUrl: 'https://db.wasap.genspectrum.org/rsvb/search',
browseDataDescription: 'Browse the data in the W-ASAP Loculus instance.',
defaultLocationName: 'Zurich',
clinicalSequenceCountWarningThreshold: 50,
filterDefaults: {
manual: {
mode: 'manual',
sequenceType: 'nucleotide',
mutations: undefined,
},
variant: {
mode: 'variant',
signatureType: 'computed',
sequenceType: 'nucleotide',
variant: 'B.D.E.1*',
minProportion: 0.8,
minCount: 15,
minJaccard: 0.75,
timeFrame: VARIANT_TIME_FRAME.all,
},
},
},
};
function withResistanceCollectionOverrides(config: WasapPageConfig): WasapPageConfig {
// eslint-disable-next-line @typescript-eslint/naming-convention
const stagingIds: Record<string, number> = { '3CLpro': 4, 'RdRp': 5, 'Spike': 6 };
return {
...config,
...(config.resistanceAnalysisModeEnabled && {
resistanceMutationCollections: config.resistanceMutationCollections.map((set) => ({
...set,
collectionId: stagingIds[set.name] ?? set.collectionId,
})),
}),
...(config.variantAnalysisModeEnabled &&
config.predefinedVariantsSource !== undefined && {
predefinedVariantsSource: {
...config.predefinedVariantsSource,
collectionsUserId: 1,
},
}),
};
}
export const wastewaterOrganismStagingConfigs: Record<WastewaterOrganismName, WasapPageConfig> = {
...wastewaterOrganismConfigs,
[wastewaterOrganisms.covid]: withResistanceCollectionOverrides(
wastewaterOrganismConfigs[wastewaterOrganisms.covid],
),
};
export const wastewaterConfig = {
menuListEntryDecoration: 'decoration-teal',
backgroundColor: 'bg-tealMuted',
backgroundColorFocus: 'group-hover:bg-teal',
borderEntryDecoration: 'hover:border-teal',
browseDataUrl: 'https://wise-loculus.genspectrum.org',
browseDataDescription: 'Browse the data in the WISE Loculus instance.',
lapisBaseUrl: 'https://api.wise-loculus.genspectrum.org',
pages: {
rsv: {
path: `/${wastewaterPathFragment}/rsv`,
description: 'Analyze RSV data that was collected by the WISE project.',
},
influenza: {
path: `/${wastewaterPathFragment}/flu`,
description: 'Analyze Influenza data that was collected by the WISE project.',
},
},
};
export const wastewaterBreadcrumb = {
name: 'Swiss Wastewater',
href: `/${wastewaterPathFragment}`,
};
export const RSVTypes = ['RSV-A', 'RSV-B'] as const;
export type RSVType = (typeof RSVTypes)[number];
export const InfluenzaTypes = ['H1', 'N1', 'H3', 'N2'] as const;
export type InfluenzaType = (typeof InfluenzaTypes)[number];
export function getMutationAnnotation(reference: InfluenzaType): MutationAnnotation[] {
switch (reference) {
case 'N1':
return mutationAnnotationsN1;
case 'N2':
return mutationAnnotationsN2;
default:
return [];
}
}
function symbolMap(medication: string): string {
switch (medication) {
case 'Laninamivir':
return '*';
case 'Oseltamivir':
return '!';
case 'Peramivir':
return '^';
case 'Zanamivir':
return '+';
default:
return '';
}
}
function createMutationAnnotation(medication: string, aaMutationList: string[]): MutationAnnotation {
return {
name: `${medication} resistance mutations`,
description: `This mutation is associated with reduced inhibition by ${medication}, for more details see the <a class='link' href='https://www.who.int/teams/global-influenza-programme/laboratory-network/quality-assurance/antiviral-susceptibility-influenza/neuraminidase-inhibitor'>Global Influenza Programme Report</a>.`,
symbol: symbolMap(medication),
nucleotideMutations: [],
aminoAcidMutations: aaMutationList,
};
}
// See https://github.com/anna-parker/NAIMutations/tree/main for calculation details
// TODO(#650): Some mutations are only of interest when with other mutations (e.g. deletions) but are now marked individually
const mutationAnnotationsN1: MutationAnnotation[] = [
createMutationAnnotation('Laninamivir', [
'P458T',
'S247R',
'H275Y',
'E119A',
'Q136K',
'E119D',
'E119G',
'Q136R',
'I223R',
'I427T',
'I223K',
'I436N',
'R152K',
]),
createMutationAnnotation('Oseltamivir', [
'E119D',
'I223R',
'I427T',
'E119V',
'S247N',
'P458T',
'I223M',
'S247G',
'R293K',
'I223L',
'S247R',
'Q313R',
'N295S',
'I223K',
'R152K',
'D199E',
'H275Y',
'D199N',
'E119A',
'D199Y',
'G147R',
'E119G',
'I223V',
'I436N',
'D199G',
]),
createMutationAnnotation('Peramivir', [
'P458T',
'S247R',
'H275Y',
'Q136K',
'D199N',
'G147R',
'E119D',
'E119G',
'Q136R',
'I223R',
'I223K',
'E119V',
'I436N',
'I223V',
'S247N',
]),
createMutationAnnotation('Zanamivir', [
'P458T',
'S247R',
'H275Y',
'E119A',
'Q136K',
'D199Y',
'E119D',
'E119G',
'S110F',
'Q136R',
'I427T',
'E119V',
'I436N',
'I223K',
'I223R',
'I117R',
]),
];
// WHO uses reference KJ609208.1 and AB124658.1, mutations here use reference CY114383.1
// When KJ609208.1 and AB124658.1 are aligned to CY114383.1 using nextclade we see no insertions/deletions only mutations
// Therefore, we can use CY114383.1 as the reference for the mutations
// See https://github.com/anna-parker/NAIMutations/tree/main for calculation details
// TODO(#650): Some mutations are only of interest when with other mutations (e.g. deletions) but are now marked individually
const mutationAnnotationsN2: MutationAnnotation[] = [
createMutationAnnotation('Laninamivir', ['T148I', 'E119V', 'N142S']),
createMutationAnnotation('Oseltamivir', [
'E276D',
'N329R',
'N245Y',
'E119V',
'K249E',
'R371K',
'R292K',
'S331R',
'T148I',
'E119I',
'I222V',
'N294S',
'D151E',
'I222L',
'I222T',
'R224K',
'247-',
'Q391K',
'N142S',
'248-',
'245-',
'250-',
]),
createMutationAnnotation('Peramivir', ['N142S', 'E119V', 'R292K', 'D151A', 'T148I']),
createMutationAnnotation('Zanamivir', [
'E276D',
'R224K',
'E119I',
'Q136K',
'247-',
'Q391K',
'E119D',
'R371K',
'N142S',
'K249E',
'E119V',
'R292K',
'250-',
'D151G',
'D151A',
'T148I',
]),
];