@genspectrum/dashboard-components 0.9.1 → 0.10.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@genspectrum/dashboard-components",
3
- "version": "0.9.1",
3
+ "version": "0.10.0",
4
4
  "description": "GenSpectrum web components for building dashboards",
5
5
  "type": "module",
6
6
  "license": "AGPL-3.0-only",
@@ -20,7 +20,7 @@ export const ConfidenceIntervalSelector: FunctionComponent<ConfidenceIntervalSel
20
20
 
21
21
  const items = [
22
22
  { label: 'Confidence interval method', value: 'none', disabled: true },
23
- ...confidenceIntervalMethods.concat('none').map((method) => {
23
+ ...confidenceIntervalMethods.map((method) => {
24
24
  switch (method) {
25
25
  case 'wilson':
26
26
  return { label: 'Wilson, 95% CI', value: 'wilson' };
@@ -35,6 +35,16 @@ describe('parseMutation', () => {
35
35
  input: 'ins_gene1:10:ACGT',
36
36
  expected: { type: 'aminoAcidInsertions', value: new InsertionClass('gene1', 10, 'ACGT') },
37
37
  },
38
+ {
39
+ name: 'should parse amino acid insertions in all upper case',
40
+ input: 'INS_GENE1:10:ACGT',
41
+ expected: { type: 'aminoAcidInsertions', value: new InsertionClass('GENE1', 10, 'ACGT') },
42
+ },
43
+ {
44
+ name: 'should parse amino acid insertions in all lower case',
45
+ input: 'ins_gene1:10:acgt',
46
+ expected: { type: 'aminoAcidInsertions', value: new InsertionClass('gene1', 10, 'acgt') },
47
+ },
38
48
  {
39
49
  name: 'should parse amino acid insertion with LAPIS-style wildcard',
40
50
  input: 'ins_gene1:10:?AC?GT',
@@ -78,6 +88,16 @@ describe('parseMutation', () => {
78
88
  input: 'gene1:A123-',
79
89
  expected: { type: 'aminoAcidMutations', value: new DeletionClass('gene1', 'A', 123) },
80
90
  },
91
+ {
92
+ name: 'should parse amino acid deletion in all upper case',
93
+ input: 'GENE1:A123-',
94
+ expected: { type: 'aminoAcidMutations', value: new DeletionClass('GENE1', 'A', 123) },
95
+ },
96
+ {
97
+ name: 'should parse amino acid deletion in all lower case',
98
+ input: 'gene1:a123-',
99
+ expected: { type: 'aminoAcidMutations', value: new DeletionClass('gene1', 'a', 123) },
100
+ },
81
101
  {
82
102
  name: 'should parse amino acid deletion without valueAtReference',
83
103
  input: 'gene1:123-',
@@ -123,6 +143,16 @@ describe('parseMutation', () => {
123
143
  input: 'gene1:A123T',
124
144
  expected: { type: 'aminoAcidMutations', value: new SubstitutionClass('gene1', 'A', 'T', 123) },
125
145
  },
146
+ {
147
+ name: 'should parse amino acid substitution in all upper case',
148
+ input: 'GENE1:A123T',
149
+ expected: { type: 'aminoAcidMutations', value: new SubstitutionClass('GENE1', 'A', 'T', 123) },
150
+ },
151
+ {
152
+ name: 'should parse amino acid substitution in all lower case',
153
+ input: 'gene1:a123t',
154
+ expected: { type: 'aminoAcidMutations', value: new SubstitutionClass('gene1', 'a', 't', 123) },
155
+ },
126
156
  {
127
157
  name: 'should return null for substitution with segment not in reference genome',
128
158
  input: 'notInReferenceGenome:A123T',
@@ -9,11 +9,12 @@ export const sequenceTypeFromSegment = (
9
9
  return isSingleSegmented(referenceGenome) ? 'nucleotide' : undefined;
10
10
  }
11
11
 
12
- if (referenceGenome.nucleotideSequences.some((sequence) => sequence.name === possibleSegment)) {
12
+ const segment = possibleSegment.toLowerCase();
13
+ if (referenceGenome.nucleotideSequences.some((sequence) => sequence.name.toLowerCase() === segment)) {
13
14
  return 'nucleotide';
14
15
  }
15
16
 
16
- if (referenceGenome.genes.some((gene) => gene.name === possibleSegment)) {
17
+ if (referenceGenome.genes.some((gene) => gene.name.toLowerCase() === segment)) {
17
18
  return 'amino acid';
18
19
  }
19
20
  return undefined;
@@ -30,7 +30,7 @@ export default {
30
30
  control: { type: 'check' },
31
31
  },
32
32
  confidenceIntervalMethods: {
33
- options: ['wilson'],
33
+ options: ['none', 'wilson'],
34
34
  control: { type: 'check' },
35
35
  },
36
36
  width: { control: 'text' },
@@ -73,7 +73,7 @@ export const TwoVariants: StoryObj<PrevalenceOverTimeProps> = {
73
73
  granularity: 'month',
74
74
  smoothingWindow: 0,
75
75
  views: ['bar', 'line', 'bubble', 'table'],
76
- confidenceIntervalMethods: ['wilson'],
76
+ confidenceIntervalMethods: ['none', 'wilson'],
77
77
  width: '100%',
78
78
  height: '700px',
79
79
  lapisDateField: 'date',
@@ -147,7 +147,7 @@ export const OneVariant: StoryObj<PrevalenceOverTimeProps> = {
147
147
  granularity: 'day',
148
148
  smoothingWindow: 7,
149
149
  views: ['bar', 'line', 'bubble', 'table'],
150
- confidenceIntervalMethods: ['wilson'],
150
+ confidenceIntervalMethods: ['none', 'wilson'],
151
151
  width: '100%',
152
152
  height: '700px',
153
153
  lapisDateField: 'date',
@@ -205,7 +205,7 @@ export const ShowsNoDataBanner: StoryObj<PrevalenceOverTimeProps> = {
205
205
  granularity: 'day',
206
206
  smoothingWindow: 7,
207
207
  views: ['bar', 'line', 'bubble', 'table'],
208
- confidenceIntervalMethods: ['wilson'],
208
+ confidenceIntervalMethods: ['none', 'wilson'],
209
209
  width: '100%',
210
210
  height: '700px',
211
211
  lapisDateField: 'date',
@@ -1,5 +1,5 @@
1
1
  import { type FunctionComponent } from 'preact';
2
- import { useContext, useState } from 'preact/hooks';
2
+ import { useContext, useEffect, useState } from 'preact/hooks';
3
3
 
4
4
  import { getPrevalenceOverTimeTableData } from './getPrevalenceOverTimeTableData';
5
5
  import PrevalenceOverTimeBarChart from './prevalence-over-time-bar-chart';
@@ -97,6 +97,16 @@ const PrevalenceOverTimeTabs: FunctionComponent<PrevalenceOverTimeTabsProps> = (
97
97
  const [confidenceIntervalMethod, setConfidenceIntervalMethod] = useState<ConfidenceIntervalMethod>(
98
98
  confidenceIntervalMethods.length > 0 ? confidenceIntervalMethods[0] : 'none',
99
99
  );
100
+
101
+ useEffect(() => {
102
+ setConfidenceIntervalMethod((confidenceIntervalMethod) => {
103
+ if (!confidenceIntervalMethods.includes(confidenceIntervalMethod)) {
104
+ return confidenceIntervalMethods.length > 0 ? confidenceIntervalMethods[0] : 'none';
105
+ }
106
+ return confidenceIntervalMethod;
107
+ });
108
+ }, [confidenceIntervalMethods]);
109
+
100
110
  const yAxisMaxConfig = { linear: yAxisMaxLinear, logarithmic: yAxisMaxLogarithmic };
101
111
 
102
112
  const getTab = (view: View) => {
@@ -14,7 +14,7 @@ export interface MutationClass extends Mutation {
14
14
  }
15
15
 
16
16
  export const substitutionRegex =
17
- /^((?<segment>[A-Za-z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Za-z])?(?<position>\d+)(?<substitutionValue>[A-Za-z.])?$/;
17
+ /^((?<segment>[A-Z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Z])?(?<position>\d+)(?<substitutionValue>[A-Z.])?$/i;
18
18
 
19
19
  export interface Substitution extends Mutation {
20
20
  type: 'substitution';
@@ -68,7 +68,7 @@ export class SubstitutionClass implements MutationClass, Substitution {
68
68
  }
69
69
  }
70
70
 
71
- export const deletionRegex = /^((?<segment>[A-Za-z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Za-z])?(?<position>\d+)(-)$/;
71
+ export const deletionRegex = /^((?<segment>[A-Z0-9_-]+)(?=:):)?(?<valueAtReference>[A-Z])?(?<position>\d+)(-)$/i;
72
72
 
73
73
  export interface Deletion extends Mutation {
74
74
  type: 'deletion';
@@ -119,7 +119,7 @@ export class DeletionClass implements MutationClass, Deletion {
119
119
  }
120
120
 
121
121
  export const insertionRegexp =
122
- /^ins_((?<segment>[A-Za-z0-9_-]+)(?=:):)?(?<position>\d+):(?<insertedSymbols>(([A-Za-z?]|(\.\*))+))$/i;
122
+ /^ins_((?<segment>[A-Z0-9_-]+)(?=:):)?(?<position>\d+):(?<insertedSymbols>(([A-Z?]|(\.\*))+))$/i;
123
123
 
124
124
  export interface Insertion extends Mutation {
125
125
  type: 'insertion';
@@ -46,7 +46,7 @@ const meta: Meta<Required<PrevalenceOverTimeProps>> = {
46
46
  control: { type: 'check' },
47
47
  },
48
48
  confidenceIntervalMethods: {
49
- options: ['wilson'],
49
+ options: ['none', 'wilson'],
50
50
  control: { type: 'check' },
51
51
  },
52
52
  width: { control: 'text' },
@@ -103,11 +103,11 @@ export class PrevalenceOverTimeComponent extends PreactLitAdapterWithGridJsStyle
103
103
 
104
104
  /**
105
105
  * A list of methods to calculate the confidence interval.
106
- * The option `none` is always available and disables confidence intervals.
107
106
  * Pass an empty array to disable the confidence interval selector.
107
+ * The first entry will be selected by default.
108
108
  */
109
109
  @property({ type: Array })
110
- confidenceIntervalMethods: ('wilson' | 'none')[] = ['wilson'];
110
+ confidenceIntervalMethods: ('wilson' | 'none')[] = ['none', 'wilson'];
111
111
 
112
112
  /**
113
113
  * The width of the component.