-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding SeqvarConsequencesCard (#47)
- Loading branch information
Showing
5 changed files
with
203 additions
and
3 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
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
45 changes: 45 additions & 0 deletions
45
src/components/SeqvarConsequencesCard/SeqvarConsequencesCard.spec.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,45 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import { describe, expect, it } from 'vitest' | ||
|
||
import { SeqvarResult } from '../../api/mehari/types' | ||
import { setupMountedComponents } from '../../lib/testUtils' | ||
import SeqvarConsequencesCard from './SeqvarConsequencesCard.vue' | ||
|
||
/** Fixtures */ | ||
const seqvarCsqResult = SeqvarResult.fromJson( | ||
JSON.parse( | ||
fs.readFileSync( | ||
path.resolve(__dirname, '../../api/mehari/fixture.seqvarCsqResponse.BRCA1.json'), | ||
'utf-8' | ||
) | ||
) | ||
) | ||
|
||
describe.concurrent('SeqvarConsequencesCard.vue', async () => { | ||
it('renders the consequence info', async () => { | ||
// arrange: | ||
const { wrapper } = await setupMountedComponents( | ||
{ component: SeqvarConsequencesCard }, | ||
{ | ||
props: { | ||
consequences: seqvarCsqResult.result | ||
} | ||
} | ||
) | ||
|
||
// act: nothing, only test rendering | ||
|
||
// assert: | ||
const table = wrapper.find('table') | ||
expect(table.exists()).toBe(true) | ||
const headers = table.findAll('th') | ||
expect(headers.length).toBe(6) | ||
expect(headers[0].text()).toBe('Gene') | ||
expect(headers[1].text()).toBe('Transcript') | ||
expect(headers[2].text()).toBe('Consequence') | ||
expect(headers[3].text()).toBe('HGVS.p') | ||
expect(headers[4].text()).toBe('HGVS.t') | ||
expect(headers[5].text()).toBe('Exon/Intron') | ||
}) | ||
}) |
31 changes: 31 additions & 0 deletions
31
src/components/SeqvarConsequencesCard/SeqvarConsequencesCard.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,31 @@ | ||
import { JsonValue } from '@protobuf-ts/runtime' | ||
import type { Meta, StoryObj } from '@storybook/vue3' | ||
|
||
import seqvarCsqResultBrca1Json from '../../api/mehari/fixture.seqvarCsqResponse.BRCA1.json' | ||
import { SeqvarResult } from '../../api/mehari/types' | ||
import SeqvarConsequencesCard from './SeqvarConsequencesCard.vue' | ||
|
||
// Here, fixture data is loaded via `import` from JSON file. Reading the file | ||
// as in the tests fails with "process is not defined" error in the browser. | ||
|
||
// @ts-ignore | ||
const seqvarCsqResponseBrca1 = SeqvarResult.fromJson(seqvarCsqResultBrca1Json as JsonValue) | ||
|
||
const meta = { | ||
title: 'Seqvar/SeqvarConsequencesCard', | ||
component: SeqvarConsequencesCard, | ||
tags: ['autodocs'], | ||
argTypes: { | ||
consequences: { control: { type: 'object' } } | ||
}, | ||
args: { consequences: seqvarCsqResponseBrca1.result } | ||
} satisfies Meta<typeof SeqvarConsequencesCard> | ||
|
||
export default meta | ||
type Story = StoryObj<typeof meta> | ||
|
||
export const BRCA1: Story = { | ||
args: { | ||
consequences: seqvarCsqResponseBrca1.result | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
src/components/SeqvarConsequencesCard/SeqvarConsequencesCard.vue
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,85 @@ | ||
<script setup lang="ts"> | ||
import { SeqvarResultEntry } from '../../api/mehari/types' | ||
import DocsLink from '../DocsLink/DocsLink.vue' | ||
/** This component's */ | ||
const props = withDefaults( | ||
defineProps<{ | ||
/** The variant consequences. */ | ||
consequences?: SeqvarResultEntry[] | ||
}>(), | ||
{ | ||
consequences: () => [] | ||
} | ||
) | ||
</script> | ||
|
||
<template> | ||
<template v-if="!consequences?.length"> | ||
<!-- no ENSG => display loader --> | ||
<v-skeleton-loader class="mt-3 mx-auto border" type="table" /> | ||
</template> | ||
<template v-else> | ||
<v-card> | ||
<v-card-title class="pb-0 pr-2"> | ||
Consequences | ||
<DocsLink anchor="consequences" /> | ||
</v-card-title> | ||
<v-card-subtitle class="text-overline"> | ||
Variant Consequences on Overlapping Transcripts | ||
</v-card-subtitle> | ||
<v-card-text> | ||
<v-table> | ||
<thead> | ||
<tr> | ||
<th>Gene</th> | ||
<th>Transcript</th> | ||
<th>Consequence</th> | ||
<th>HGVS.p</th> | ||
<th>HGVS.t</th> | ||
<th>Exon/Intron</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<template v-if="consequences?.length"> | ||
<tr v-for="(oneTxCsq, idx) in consequences" :key="idx"> | ||
<td>{{ oneTxCsq.geneSymbol }}</td> | ||
<td> | ||
{{ oneTxCsq.featureId }} | ||
<small> ({{ oneTxCsq.featureBiotype }}) </small> | ||
<v-chip | ||
v-if="(oneTxCsq.featureTag ?? []).includes('ManeSelect')" | ||
color="primary" | ||
rounded="xl" | ||
class="ml-3" | ||
> | ||
MANE Select | ||
</v-chip> | ||
<v-chip | ||
v-if="(oneTxCsq.featureTag ?? []).includes('ManePlusClinical')" | ||
color="primary" | ||
rounded="xl" | ||
class="ml-3" | ||
> | ||
MANE Plus Clinical | ||
</v-chip> | ||
</td> | ||
<td>{{ oneTxCsq.consequences.join(', ') }}</td> | ||
<td>{{ oneTxCsq.hgvsT }}</td> | ||
<td>{{ oneTxCsq.hgvsP }}</td> | ||
<td>{{ oneTxCsq.rank!.rank }} / {{ oneTxCsq.rank!.total }}</td> | ||
</tr> | ||
</template> | ||
<template v-else> | ||
<tr> | ||
<td colspan="6" class="text-center font-italic text-grey-darken-2"> | ||
No overlapping transcripts | ||
</td> | ||
</tr> | ||
</template> | ||
</tbody> | ||
</v-table> | ||
</v-card-text> | ||
</v-card> | ||
</template> | ||
</template> |