Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Nov 22, 2024
1 parent 63c1e55 commit 67126c9
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 33 deletions.
5 changes: 2 additions & 3 deletions src/components/StrucvarClinvarCard/StrucvarClinvarCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import { computed, ref } from 'vue'

import { type Strucvar } from '../../lib/genomicVars'
import { roundIt } from '../../lib/utils'
import { ResponseRecord as ClinvarSvRecord } from '../../pbs/annonars/clinvar/sv'
import { AggregateClassificationSet } from '../../pbs/annonars/clinvar_data/clinvar_public'
import DocsLink from '../DocsLink/DocsLink.vue'
import {
AGGREGATE_GERMLINE_REVIEW_STATUS_LABEL,
Expand All @@ -18,13 +16,14 @@ import {
AGGREGATE_SOMATIC_CLINICAL_IMPACT_REVIEW_STATUS_STARS
} from '../SeqvarClinvarCard/constants'
import { clinsigColor } from '../SeqvarClinvarCard/helpers'
import { StrucvarsClinvarResponseRecord } from '../../ext/annonars-api/src/lib'

/** This component's props. */
const props = defineProps<{
/** Structural variant to display the card for. */
strucvar?: Strucvar
/** ClinVar records to display for. */
clinvarSvRecords?: ClinvarSvRecord[]
clinvarSvRecords?: StrucvarsClinvarResponseRecord[]
}>()

const vcvUrl = (vcv: string): string => {
Expand Down
24 changes: 10 additions & 14 deletions src/components/StrucvarGeneListCard/StrucvarGeneListCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,21 @@ import { computed, ref, watch } from 'vue'
import { onMounted } from 'vue'
import { TX_EFFECT_LABELS } from '../../api/mehari/constants'
import type { GeneTranscriptEffects } from '../../api/mehari/types'
import { type Strucvar } from '../../lib/genomicVars'
import { Record as GeneInfoRecord } from '../../pbs/annonars/genes/base'
import { StoreState } from '../../stores'
import DocsLink from '../DocsLink/DocsLink.vue'
import GeneListEntry from './GeneListEntry.vue'
import { StrucvarsGeneTranscriptEffects } from '../../ext/mehari-api/src/lib'
import { GenesGeneInfoRecord } from '../../ext/annonars-api/src/lib'
/** This component's props. */
const props = withDefaults(
defineProps<{
/** Strucvar to be displayed for. */
currentStrucvarRecord?: Strucvar
/** The consequences to be displayed. */
csq?: GeneTranscriptEffects[]
csq?: StrucvarsGeneTranscriptEffects[]
/** Gene info records to list for. */
genesInfos?: GeneInfoRecord[]
/** The state of the store that we display for. */
storeState?: StoreState
genesInfos?: GenesGeneInfoRecord[]
/** The HGNC ID of the selected gene. */
selectedGeneHgncId?: string
/** Column width of the entry. */
Expand All @@ -30,7 +27,6 @@ const props = withDefaults(
currentStrucvarRecord: undefined,
csq: undefined,
genesInfos: undefined,
storeState: StoreState.Initial,
selectedGeneHgncId: undefined,
entryColumnWidth: '280px'
}
Expand All @@ -50,12 +46,12 @@ const itemsPerPage = ref<number>(10)
const currentPage = ref<number>(1)
/** Whether the list of genes is currently loading. */
const isLoading = computed<boolean>(() => {
return (
props.storeState === undefined ||
[StoreState.Initial, StoreState.Loading].includes(props.storeState)
)
})
const isLoading = computed<boolean>(() => (
props.currentStrucvarRecord === undefined ||
props.genesInfos === undefined ||
props.selectedGeneHgncId === undefined ||
props.csq === undefined
))
/** Helper mapping from gene HGNC ID to worst transcript effect. */
const hgncToEffect = computed<{ [key: string]: string }>(() => {
Expand Down
24 changes: 12 additions & 12 deletions src/queries/annonars/genes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Queries for gene queries and related powered by TanStack Query.
*/
import { QueryClient, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue } from 'vue'
import { QueryClient, useQueries, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue, computed } from 'vue'

import {
genesClinvarOptions,
Expand All @@ -13,55 +13,55 @@ import {
/**
* Query for gene-related information from Annonars.
*
* @params hgnc_id The HGNC ID to use.
* @params hgnc_ids The HGNC IDs to use.
* @returns The query result.
*/
export const useAnnonarsGenesInfoQuery = (
{ hgnc_id }: { hgnc_id: MaybeRefOrGetter<string | undefined> },
{ hgnc_ids }: { hgnc_ids: MaybeRefOrGetter<string[] | undefined> },
queryClient?: QueryClient
) =>
useQuery(
{
...genesInfoOptions({
// @ts-ignore // https://github.com/hey-api/openapi-ts/issues/653#issuecomment-2314847011
query: () => ({
hgnc_id: toValue(hgnc_id)
hgnc_id: toValue(hgnc_ids) === undefined ? [] : toValue(hgnc_ids)?.join(",")
})
}),
staleTime: Infinity, // static data so no need to refetch
enabled: () => !!toValue(hgnc_id)
enabled: () => !!toValue(hgnc_ids)
},
queryClient
)

/**
* Query for clinvar-related information from Annonars.
*
* @params hgnc_id The HGNC ID to use.
* @params hgnc_ids The HGNC ID to use.
* @returns The query result.
*/
export const useAnnonarsGenesClinvarQuery = (
{ hgnc_id }: { hgnc_id: MaybeRefOrGetter<string | undefined> },
{ hgnc_ids }: { hgnc_ids: MaybeRefOrGetter<string[] | undefined> },
queryClient?: QueryClient
) =>
useQuery(
{
...genesClinvarOptions({
// @ts-ignore // https://github.com/hey-api/openapi-ts/issues/653#issuecomment-2314847011
query: () => ({
hgnc_id: toValue(hgnc_id)
hgnc_id: toValue(hgnc_ids) === undefined ? [] : toValue(hgnc_ids)?.join(",")
})
}),
staleTime: Infinity, // static data so no need to refetch
enabled: () => !!toValue(hgnc_id)
enabled: () => !!toValue(hgnc_ids)
},
queryClient
)

/**
* Query for looking up genes.
*
* @params query The query to use.
* @params query The queries to use.
* @returns The query result.
*/
export const useAnnonarsGenesLookupQuery = (
Expand All @@ -77,7 +77,7 @@ export const useAnnonarsGenesLookupQuery = (
})
}),
staleTime: Infinity, // static data so no need to refetch
enabled: () => !!toValue(query)
enabled: () => !!toValue(query)?.join(",")
},
queryClient
)
68 changes: 68 additions & 0 deletions src/queries/annonars/strucvars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/**
* Queries for strucvars information powered by TanStack Query.
*/
import { QueryClient, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue } from 'vue'

import { strucvarsClinvarQueryOptions } from '../../ext/annonars-api/src/lib/@tanstack/vue-query.gen'
import { ClinvarExtractedVariationType } from '../../ext/annonars-api/src/lib'

/**
* Query for overlapping ClinVar structural variants.
*
* @param genome_release The genome release to use.
* @param chromosome The chromosome to use.
* @param start The start position to use (1-based).
* @param stop The stop position to use (1-based).
* @param variation_types The variation types to use; optional.
* @param min_overlap The minimum overlap to use; optional.
* @param page_no The page number to use; optional.
* @param page_size The page size to use; optional.
* @returns The query result.
*/
export const useAnnonarsStrucvarsClinvarQuery = (
{
genome_release,
chromosome,
start,
stop,
variation_types,
min_overlap,
page_no,
page_size
}: {
genome_release: MaybeRefOrGetter<string | undefined>
chromosome: MaybeRefOrGetter<string | undefined>
start: MaybeRefOrGetter<number | undefined>
stop: MaybeRefOrGetter<number | undefined>
variation_types?: MaybeRefOrGetter<Array<ClinvarExtractedVariationType> | undefined>
min_overlap?: MaybeRefOrGetter<number | undefined>
page_no?: MaybeRefOrGetter<number | undefined>
page_size?: MaybeRefOrGetter<number | undefined>
},
queryClient?: QueryClient
) =>
useQuery(
{
...strucvarsClinvarQueryOptions({
// @ts-ignore // https://github.com/hey-api/openapi-ts/issues/653#issuecomment-2314847011
query: () => ({
genome_release: toValue(genome_release),
chromosome: toValue(chromosome),
start: toValue(start),
stop: toValue(stop),
variation_types: toValue(variation_types ?? (() => undefined)) === undefined ? undefined : toValue(variation_types)?.join(","),
min_overlap: toValue(min_overlap ?? (() => undefined)),
page_no: toValue(page_no ?? (() => undefined)),
page_size: toValue(page_size ?? (() => undefined))
})
}),
staleTime: Infinity, // static data so no need to refetch
enabled: () =>
!!toValue(genome_release) &&
!!toValue(chromosome) &&
!!toValue(start) &&
!!toValue(stop)
},
queryClient
)
4 changes: 2 additions & 2 deletions src/queries/mehari/geneTranscripts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Queries for Mehari gene transcripts by TanStack Query.
*/
import { QueryClient, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue } from 'vue'
import { QueryClient, useQueries, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue, computed } from 'vue'

import { genesTranscriptsListOptions } from '../../ext/mehari-api/src/lib/@tanstack/vue-query.gen'

Expand Down
57 changes: 57 additions & 0 deletions src/queries/mehari/strucvars.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* Queries for seqvars information powered by TanStack Query.
*/
import { QueryClient, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue } from 'vue'

import { strucvarsCsqOptions } from '../../ext/mehari-api/src/lib/@tanstack/vue-query.gen'
import { StrucvarsSvType } from '../../ext/mehari-api/src/lib'

/**
* Query for the consequence of a seqvar.
*
* @param genome_release The genome release to use.
* @param chromosome The chromosome to use.
* @param position The position to use.
* @param reference The reference to use.
* @param alternative The alternative to use.
* @param hgnc_id The HGNC ID to use; optional.
* @returns The query result.
*/
export const useMehariStrucvarsCsqQuery = (
{
genome_release,
chromosome,
start,
stop,
sv_type,
}: {
genome_release: MaybeRefOrGetter<string | undefined>
chromosome: MaybeRefOrGetter<string | undefined>
start: MaybeRefOrGetter<number | undefined>
stop?: MaybeRefOrGetter<number | undefined>
sv_type: MaybeRefOrGetter<StrucvarsSvType | undefined>
},
queryClient?: QueryClient
) =>
useQuery(
{
...strucvarsCsqOptions({
// @ts-ignore // https://github.com/hey-api/openapi-ts/issues/653#issuecomment-2314847011
query: () => ({
genome_release: toValue(genome_release),
chromosome: toValue(chromosome),
start: toValue(start),
stop: toValue(stop ?? (() => undefined)),
sv_type: toValue(sv_type)
})
}),
staleTime: Infinity, // static data so no need to refetch
enabled: () =>
!!toValue(genome_release) &&
!!toValue(chromosome) &&
!!toValue(start) &&
!!toValue(sv_type)
},
queryClient
)
4 changes: 2 additions & 2 deletions src/queries/viguno/genes.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* Queries for HPO queries and related powered by TanStack Query.
*/
import { QueryClient, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue } from 'vue'
import { QueryClient, useQueries, useQuery } from '@tanstack/vue-query'
import { MaybeRefOrGetter, toValue, computed } from 'vue'

import { hpoGenesOptions } from '../../ext/viguno-api/src/lib/@tanstack/vue-query.gen'

Expand Down

0 comments on commit 67126c9

Please sign in to comment.