From 28295c60203d05f2d138acae0a9131d66228fa19 Mon Sep 17 00:00:00 2001 From: gromdimon Date: Mon, 19 Feb 2024 10:40:01 +0100 Subject: [PATCH] component proto --- src/api/litvar/client.ts | 2 +- .../SeqvarLitvarCard/SeqvarLitvarCard.vue | 369 ++++++++++++++++++ src/stores/{litvat => litvar}/index.ts | 2 +- src/stores/{litvat => litvar}/store.ts | 11 +- src/stores/litvar/types.ts | 40 ++ src/stores/litvat/types.ts | 40 -- 6 files changed, 418 insertions(+), 46 deletions(-) create mode 100644 src/components/SeqvarLitvarCard/SeqvarLitvarCard.vue rename src/stores/{litvat => litvar}/index.ts (50%) rename src/stores/{litvat => litvar}/store.ts (84%) create mode 100644 src/stores/litvar/types.ts delete mode 100644 src/stores/litvat/types.ts diff --git a/src/api/litvar/client.ts b/src/api/litvar/client.ts index b6d5274..fba4f14 100644 --- a/src/api/litvar/client.ts +++ b/src/api/litvar/client.ts @@ -67,4 +67,4 @@ export class LitVarClient { return searchData } -} \ No newline at end of file +} diff --git a/src/components/SeqvarLitvarCard/SeqvarLitvarCard.vue b/src/components/SeqvarLitvarCard/SeqvarLitvarCard.vue new file mode 100644 index 0000000..19b74dc --- /dev/null +++ b/src/components/SeqvarLitvarCard/SeqvarLitvarCard.vue @@ -0,0 +1,369 @@ + + + + + + + diff --git a/src/stores/litvat/index.ts b/src/stores/litvar/index.ts similarity index 50% rename from src/stores/litvat/index.ts rename to src/stores/litvar/index.ts index 9bd8e77..7c17971 100644 --- a/src/stores/litvat/index.ts +++ b/src/stores/litvar/index.ts @@ -1,2 +1,2 @@ export * from './store' -export * from './types' \ No newline at end of file +export * from './types' diff --git a/src/stores/litvat/store.ts b/src/stores/litvar/store.ts similarity index 84% rename from src/stores/litvat/store.ts rename to src/stores/litvar/store.ts index ffba011..483c026 100644 --- a/src/stores/litvat/store.ts +++ b/src/stores/litvar/store.ts @@ -4,6 +4,8 @@ import { defineStore } from 'pinia' import { ref } from 'vue' +import { Seqvar } from '@/lib/genomicVars' + import { LitVarClient } from '../../api/litvar' import { StoreState } from '../types' import { type SearchResults } from './types' @@ -13,13 +15,13 @@ export const useLitVarStore = defineStore('litvar', () => { const storeState = ref(StoreState.Initial) /** The Seqvar name currently loaded for. */ - const seqVar = ref(undefined) + const seqVar = ref(undefined) /** Detailed result information. */ const searchResults = ref({}) /** Initialize the store for the given SeqVar name. */ - const initialize = async (seqVar$?: string, force: boolean = false) => { + const initialize = async (seqVar$?: Seqvar, force: boolean = false) => { // Skip if already loaded if (!force && seqVar$ === seqVar.value) { return @@ -39,7 +41,8 @@ export const useLitVarStore = defineStore('litvar', () => { // "Just" lookup via LitVar client. const client = new LitVarClient() try { - searchResults.value = await client.performSearch(seqVar$) + const seqvarName = seqVar$.toString() + searchResults.value = await client.performSearch(seqvarName) storeState.value = StoreState.Active } catch (err) { storeState.value = StoreState.Error @@ -62,4 +65,4 @@ export const useLitVarStore = defineStore('litvar', () => { initialize, clearData } -}) \ No newline at end of file +}) diff --git a/src/stores/litvar/types.ts b/src/stores/litvar/types.ts new file mode 100644 index 0000000..8dbf0b0 --- /dev/null +++ b/src/stores/litvar/types.ts @@ -0,0 +1,40 @@ +import { type SearchResult } from '../../api/litvar' + +/** Enumeration for annotation types */ +export enum AnnotationType { + /** Disease */ + Disease = 'Disease', + /** Gene */ + Gene = 'Gene', + /** Chemical */ + Chemical = 'Chemical', + /** Species */ + Species = 'Species', + /** Variant */ + Variant = 'Variant', + /** CellLine */ + CellLine = 'CellLine' +} + +/** Location of an annotation. */ +export interface AnnotationLocation { + /** The offset of the annotation. */ + offset: number + /** The length of the annotation. */ + length: number +} + +/** One annotation record. */ +export interface Annotation { + /** The type of annotation. */ + type: AnnotationType + /** The name of the annotation. */ + name?: string + /** The text of the annotation. */ + text?: string + /** Locations of the annotation */ + locations: AnnotationLocation[] +} + +/** Search results type. */ +export type SearchResults = { [key: string]: SearchResult } diff --git a/src/stores/litvat/types.ts b/src/stores/litvat/types.ts deleted file mode 100644 index 3985da0..0000000 --- a/src/stores/litvat/types.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { type SearchResult } from '../../api/litvar' - -// /** Enumeration for annotation types */ -// export enum AnnotationType { -// /** Disease */ -// Disease = 'Disease', -// /** Gene */ -// Gene = 'Gene', -// /** Chemical */ -// Chemical = 'Chemical', -// /** Species */ -// Species = 'Species', -// /** Variant */ -// Variant = 'Variant', -// /** CellLine */ -// CellLine = 'CellLine' -// } - -// /** Location of an annotation. */ -// export interface AnnotationLocation { -// /** The offset of the annotation. */ -// offset: number -// /** The length of the annotation. */ -// length: number -// } - -// /** One annotation record. */ -// export interface Annotation { -// /** The type of annotation. */ -// type: AnnotationType -// /** The name of the annotation. */ -// name?: string -// /** The text of the annotation. */ -// text?: string -// /** Locations of the annotation */ -// locations: AnnotationLocation[] -// } - -/** Search results type. */ -export type SearchResults = { [key: string]: SearchResult }