@genspectrum/dashboard-components 1.17.0 → 1.18.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.
@@ -94,10 +94,10 @@ function mutationOrAnnotationMatchesTextFilter(
94
94
  return false;
95
95
  }
96
96
  return mutationAnnotations.some(
97
- (annotation) =>
98
- annotation.description.includes(textFilter) ||
99
- annotation.name.includes(textFilter) ||
100
- annotation.symbol.includes(textFilter),
97
+ (resolved) =>
98
+ resolved.annotation.description.includes(textFilter) ||
99
+ resolved.annotation.name.includes(textFilter) ||
100
+ resolved.annotation.symbol.includes(textFilter),
101
101
  );
102
102
  }
103
103
 
@@ -115,5 +115,5 @@ function mutationMatchesAnnotationFilter(
115
115
  if (mutationAnnotations === undefined || mutationAnnotations.length === 0) {
116
116
  return false;
117
117
  }
118
- return mutationAnnotations.some((annotation) => annotationNameFilter.has(annotation.name));
118
+ return mutationAnnotations.some((resolved) => annotationNameFilter.has(resolved.annotation.name));
119
119
  }
@@ -45,6 +45,10 @@ export class AppComponent extends LitElement {
45
45
  /**
46
46
  * Supply lists of mutations that are especially relevant for the current organism.
47
47
  *
48
+ * Each entry in `nucleotideMutations`, `aminoAcidMutations`, `nucleotidePositions`, and `aminoAcidPositions`
49
+ * can be either a plain string or an object with an optional `name` and `description` that override the
50
+ * group-level values in the annotation popup for that specific mutation or position.
51
+ *
48
52
  * Visit https://genspectrum.github.io/dashboard-components/?path=/docs/concepts-mutation-annotations--docs for more information.
49
53
  */
50
54
  @provide({ context: mutationAnnotationsContext })
@@ -53,10 +57,10 @@ export class AppComponent extends LitElement {
53
57
  name: string;
54
58
  description: string;
55
59
  symbol: string;
56
- nucleotideMutations?: string[];
57
- nucleotidePositions?: string[];
58
- aminoAcidMutations?: string[];
59
- aminoAcidPositions?: string[];
60
+ nucleotideMutations?: (string | { mutation: string; name?: string; description?: string })[];
61
+ nucleotidePositions?: (string | { position: string; name?: string; description?: string })[];
62
+ aminoAcidMutations?: (string | { mutation: string; name?: string; description?: string })[];
63
+ aminoAcidPositions?: (string | { position: string; name?: string; description?: string })[];
60
64
  }[] = [];
61
65
 
62
66
  /**
@@ -1,16 +1,24 @@
1
1
  import { createContext } from '@lit/context';
2
2
  import z from 'zod';
3
3
 
4
- const annotations = z.array(z.string());
4
+ const mutationEntrySchema = z.union([
5
+ z.string(),
6
+ z.object({ mutation: z.string(), name: z.string().optional(), description: z.string().optional() }),
7
+ ]);
8
+
9
+ const positionEntrySchema = z.union([
10
+ z.string(),
11
+ z.object({ position: z.string(), name: z.string().optional(), description: z.string().optional() }),
12
+ ]);
5
13
 
6
14
  const mutationAnnotationSchema = z.object({
7
15
  name: z.string(),
8
16
  description: z.string(),
9
17
  symbol: z.string(),
10
- nucleotideMutations: annotations.optional(),
11
- nucleotidePositions: annotations.optional(),
12
- aminoAcidMutations: annotations.optional(),
13
- aminoAcidPositions: annotations.optional(),
18
+ nucleotideMutations: z.array(mutationEntrySchema).optional(),
19
+ nucleotidePositions: z.array(positionEntrySchema).optional(),
20
+ aminoAcidMutations: z.array(mutationEntrySchema).optional(),
21
+ aminoAcidPositions: z.array(positionEntrySchema).optional(),
14
22
  });
15
23
  export type MutationAnnotation = z.infer<typeof mutationAnnotationSchema>;
16
24
 
@@ -39,3 +39,32 @@ The annotation can be applied to specific mutations:
39
39
  - `nucleotideMutations: [C44T]` matches only the nucleotide mutation `C44T`,
40
40
  - `aminoAcidPositions: [S:123]` matches all amino acid mutations that occur on the gene `S` at position `123`
41
41
  - If the pathogen has only one segment, one can omit the segment, writing `123` for any mutation at position `123`.
42
+
43
+ ## Per-mutation name and description
44
+
45
+ Instead of a plain string, each entry in `nucleotideMutations`, `aminoAcidMutations`, `nucleotidePositions`, and `aminoAcidPositions` can be an object with optional `name` and `description` fields.
46
+ These override the group-level `name` and `description` in the popup for that specific mutation, while the group-level values remain as fallback for entries that don't specify their own.
47
+
48
+ This is useful when grouping mutations under a shared symbol (e.g. all mutations of one drug target) while still showing per-mutation details in the popup:
49
+
50
+ ```html
51
+ <gs-app
52
+ lapis="https://your.lapis.url"
53
+ mutationAnnotations="[
54
+ {
55
+ name: '3CLpro inhibitor resistance',
56
+ description: 'Mutations affecting 3CLpro drug binding.',
57
+ symbol: 'c',
58
+ nucleotideMutations: [
59
+ { mutation: 'ORF1a:T2343C', name: '3CLpro:T31C', description: 'Disrupts nirmatrelvir binding.' },
60
+ { mutation: 'ORF1a:G2558A', name: '3CLpro:E166K' },
61
+ 'ORF1a:C2566T'
62
+ ]
63
+ },
64
+ ]"
65
+ >
66
+ {/* children... */}
67
+ </gs-app>
68
+ ```
69
+
70
+ In this example, clicking `ORF1a:T2343C` shows `3CLpro:T31C` as the title and the specific description, clicking `ORF1a:G2558A` shows `3CLpro:E166K` but falls back to the group description, and clicking `ORF1a:C2566T` falls back to both the group name and description.