-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(components): add mutation comparison with table
- Loading branch information
1 parent
ec3b244
commit eadd9a7
Showing
20 changed files
with
1,166 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
129 changes: 129 additions & 0 deletions
129
components/src/preact-components/display/mutation-comparison-component.stories.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
import type { Meta, StoryObj } from '@storybook/web-components'; | ||
import { html } from 'lit'; | ||
import './mutation-comparison-component'; | ||
import '../../components/app'; | ||
import { LAPIS_URL, NUCLEOTIDE_INSERTIONS_ENDPOINT, NUCLEOTIDE_MUTATIONS_ENDPOINT } from '../../constants'; | ||
import { MutationComparisonProps } from '../../preact/mutationComparison/mutation-comparison'; | ||
import nucleotideMutationsSomeVariant from '../../preact/mutationComparison/__mockData__/nucleotideMutationsSomeVariant.json'; | ||
import nucleotideInsertionsSomeVariant from '../../preact/mutationComparison/__mockData__/nucleotideInsertionsSomeVariant.json'; | ||
import nucleotideMutationsOtherVariant from '../../preact/mutationComparison/__mockData__/nucleotideMutationsOtherVariant.json'; | ||
import nucleotideInsertionsOtherVariant from '../../preact/mutationComparison/__mockData__/nucleotideInsertionsOtherVariant.json'; | ||
|
||
const meta: Meta<MutationComparisonProps> = { | ||
title: 'Visualization/Mutation comparison', | ||
component: 'gs-mutation-comparison-component', | ||
argTypes: { | ||
variants: { control: 'object' }, | ||
sequenceType: { | ||
options: ['nucleotide', 'amino acid'], | ||
control: { type: 'radio' }, | ||
}, | ||
views: { | ||
options: ['table', 'grid'], | ||
control: { type: 'check' }, | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
const Template: StoryObj<MutationComparisonProps> = { | ||
render: (args) => html` | ||
<div class="w-11/12 h-11/12"> | ||
<gs-app lapis="${LAPIS_URL}"> | ||
<gs-mutation-comparison-component | ||
.variants=${args.variants} | ||
.sequenceType=${args.sequenceType} | ||
.views=${args.views} | ||
></gs-mutation-comparison-component> | ||
</gs-app> | ||
</div> | ||
`, | ||
}; | ||
|
||
const dateTo = '2022-01-01'; | ||
const dateFrom = '2021-01-01'; | ||
|
||
export const Default = { | ||
...Template, | ||
args: { | ||
variants: [ | ||
{ | ||
displayName: 'Some variant', | ||
lapisFilter: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo }, | ||
}, | ||
{ | ||
displayName: 'Other variant', | ||
lapisFilter: { | ||
country: 'Switzerland', | ||
pangoLineage: 'B.1.1.7', | ||
dateFrom, | ||
dateTo, | ||
}, | ||
}, | ||
], | ||
sequenceType: 'nucleotide', | ||
views: ['table'], | ||
}, | ||
parameters: { | ||
fetchMock: { | ||
mocks: [ | ||
{ | ||
matcher: { | ||
name: 'nucleotideMutationsSomeVariant', | ||
url: NUCLEOTIDE_MUTATIONS_ENDPOINT, | ||
query: { | ||
country: 'Switzerland', | ||
pangoLineage: 'B.1.1.7', | ||
dateTo, | ||
minProportion: 0, | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: nucleotideMutationsSomeVariant, | ||
}, | ||
}, | ||
{ | ||
matcher: { | ||
name: 'nucleotideInsertionsSomeVariant', | ||
url: NUCLEOTIDE_INSERTIONS_ENDPOINT, | ||
query: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateTo }, | ||
}, | ||
response: { | ||
status: 200, | ||
body: nucleotideInsertionsSomeVariant, | ||
}, | ||
}, | ||
{ | ||
matcher: { | ||
name: 'nucleotideMutationsOtherVariant', | ||
url: NUCLEOTIDE_MUTATIONS_ENDPOINT, | ||
query: { | ||
country: 'Switzerland', | ||
pangoLineage: 'B.1.1.7', | ||
dateFrom, | ||
dateTo, | ||
minProportion: 0, | ||
}, | ||
}, | ||
response: { | ||
status: 200, | ||
body: nucleotideMutationsOtherVariant, | ||
}, | ||
}, | ||
{ | ||
matcher: { | ||
name: 'nucleotideInsertionsOtherVariant', | ||
url: NUCLEOTIDE_INSERTIONS_ENDPOINT, | ||
query: { country: 'Switzerland', pangoLineage: 'B.1.1.7', dateFrom, dateTo }, | ||
}, | ||
response: { | ||
status: 200, | ||
body: nucleotideInsertionsOtherVariant, | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; |
30 changes: 30 additions & 0 deletions
30
components/src/preact-components/display/mutation-comparison-component.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { customElement, property } from 'lit/decorators.js'; | ||
import { SequenceType } from '../../types'; | ||
import { PreactLitAdapterWithGridJsStyles } from '../PreactLitAdapterWithGridJsStyles'; | ||
import { | ||
MutationComparison, | ||
MutationComparisonVariant, | ||
View, | ||
} from '../../preact/mutationComparison/mutation-comparison'; | ||
|
||
@customElement('gs-mutation-comparison-component') | ||
export class MutationComparisonComponent extends PreactLitAdapterWithGridJsStyles { | ||
@property({ type: Array }) | ||
variants: MutationComparisonVariant[] = []; | ||
|
||
@property({ type: String }) | ||
sequenceType: SequenceType = 'nucleotide'; | ||
|
||
@property({ type: Array }) | ||
views: View[] = ['table']; | ||
|
||
override render() { | ||
return <MutationComparison variants={this.variants} sequenceType={this.sequenceType} views={this.views} />; | ||
} | ||
} | ||
|
||
declare global { | ||
interface HTMLElementTagNameMap { | ||
'gs-mutation-comparison-component': MutationComparisonComponent; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
147 changes: 147 additions & 0 deletions
147
components/src/preact/mutationComparison/__mockData__/nucleotideInsertionsOtherVariant.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"info": { | ||
"dataVersion": 1709685650 | ||
}, | ||
"data": [ | ||
{ | ||
"insertion": "ins_21571:TTT", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_26654:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_28250:CTG", | ||
"count": 25 | ||
}, | ||
{ | ||
"insertion": "ins_13915:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_27552:TT", | ||
"count": 28 | ||
}, | ||
{ | ||
"insertion": "ins_2170:GAGCCAGGG", | ||
"count": 3 | ||
}, | ||
{ | ||
"insertion": "ins_21305:GAGAGAGAGCAA", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_11305:ATTTCATTGTTT", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_28230:AAACTTGTCA", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_27687:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_27553:TGATCAG", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29903:NNNNNNNNNNNNNNNNN", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29727:GG", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29053:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_27672:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29735:TACAGT", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_1813:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_20793:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_11521:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_18219:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29005:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_2842:AC", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_7021:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_14898:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_17019:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_4013:AGC", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_28250:CT", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29593:AT", | ||
"count": 2 | ||
}, | ||
{ | ||
"insertion": "ins_2857:A", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_21102:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_27231:TACATGGGGG", | ||
"count": 2 | ||
}, | ||
{ | ||
"insertion": "ins_19983:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29725:T", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_29759:CACCGA", | ||
"count": 1 | ||
}, | ||
{ | ||
"insertion": "ins_27863:TT", | ||
"count": 1 | ||
} | ||
] | ||
} |
Oops, something went wrong.