Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cada-prio API result types #83

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/api/cadaPrio/__snapshots__/client.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`CadaPrioClient > throws in case of fetching problems 1`] = `"{"entries":[{"geneSymbol":"WNT7A"},{"geneSymbol":"SMARCA2"},{"geneSymbol":"EFL1"},{"geneSymbol":"SRP54"},{"geneSymbol":"HPGD"},{"geneSymbol":"GALNS"},{"geneSymbol":"DNAJC21"},{"geneSymbol":"NOG"},{"geneSymbol":"ESCO2"},{"geneSymbol":"COL11A1"},{"geneSymbol":"PTDSS1"},{"geneSymbol":"VAC14"},{"geneSymbol":"TBX3"},{"geneSymbol":"GRIA3"},{"geneSymbol":"RNU4ATAC"},{"geneSymbol":"GDF5"},{"geneSymbol":"TRAPPC2"},{"geneSymbol":"IHH"},{"geneSymbol":"PCNT"}]}"`;
exports[`CadaPrioClient > throws in case of fetching problems 1`] = `"{"entries":[{"hgncId":"HGNC:12786","ncbiGeneId":"7476","rank":1,"score":76.84823608398438},{"hgncId":"HGNC:11098","ncbiGeneId":"6595","rank":2,"score":76.46592712402344},{"hgncId":"HGNC:25789","ncbiGeneId":"79631","rank":3,"score":69.20905303955078},{"hgncId":"HGNC:11301","ncbiGeneId":"6729","rank":4,"score":65.58743286132812},{"hgncId":"HGNC:5154","ncbiGeneId":"3248","rank":5,"score":63.857845306396484},{"hgncId":"HGNC:4122","ncbiGeneId":"2588","rank":6,"score":63.840911865234375},{"hgncId":"HGNC:27030","ncbiGeneId":"134218","rank":7,"score":63.35689926147461},{"hgncId":"HGNC:7866","ncbiGeneId":"9241","rank":8,"score":63.207393646240234},{"hgncId":"HGNC:27230","ncbiGeneId":"157570","rank":9,"score":63.09525680541992},{"hgncId":"HGNC:2186","ncbiGeneId":"1301","rank":10,"score":61.24506378173828},{"hgncId":"HGNC:9587","ncbiGeneId":"9791","rank":11,"score":60.995365142822266},{"hgncId":"HGNC:25507","ncbiGeneId":"55697","rank":12,"score":60.21630859375},{"hgncId":"HGNC:11602","ncbiGeneId":"6926","rank":13,"score":59.911136627197266},{"hgncId":"HGNC:4573","ncbiGeneId":"2892","rank":14,"score":59.312957763671875},{"hgncId":"HGNC:34016","ncbiGeneId":"100151683","rank":15,"score":59.29935836791992},{"hgncId":"HGNC:4220","ncbiGeneId":"8200","rank":16,"score":58.710994720458984},{"hgncId":"HGNC:23068","ncbiGeneId":"6399","rank":17,"score":56.57151412963867},{"hgncId":"HGNC:5956","ncbiGeneId":"3549","rank":18,"score":55.67450714111328},{"hgncId":"HGNC:16068","ncbiGeneId":"5116","rank":19,"score":55.3505859375}]}"`;
35 changes: 20 additions & 15 deletions src/api/cadaPrio/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,39 @@
* One entry of the result as returned by the API.
*/
export interface ResponseEntry$Api {
/** The HPO term. */
hpo_term: string
/** The gene symbol. */
gene_symbol: string
/** The predicted impact. */
impact: string
/** HGNC ID */
hgnc_id: string
/** NCBI Gene ID */
ncbi_gene_id: string
/** Rank */
rank: number
/** Score */
score: number
}

/**
* One entry of the result.
*/
export interface ResponseEntry {
/** The HPO term. */
hpoTerm: string
/** The gene symbol. */
geneSymbol: string
/** The predicted impact. */
impact: string
/** HGNC ID */
hgncId: string
/** NCBI Gene ID */
ncbiGeneId: string
/** Rank */
rank: number
/** Score */
score: number
}

/** Helper class for converting `ResponseEntry$Api` to `ResponseEntry`. */
class ResponseEntry$Type {
/** Converts `ResponseEntry$Api` to `ResponseEntry`. */
fromJson(data: ResponseEntry$Api): ResponseEntry {
return {
hpoTerm: data.hpo_term,
geneSymbol: data.gene_symbol,
impact: data.impact
hgncId: data.hgnc_id,
ncbiGeneId: data.ncbi_gene_id,
rank: data.rank,
score: data.score
}
}
}
Expand Down
233 changes: 76 additions & 157 deletions src/store/cadaPrio/__snapshots__/store.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,201 +1,120 @@
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html

exports[`Cada Prio Store > should handle error when predicting gene impact 1`] = `
[
{
"geneSymbol": "WNT7A",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "SMARCA2",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "EFL1",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "SRP54",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "HPGD",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "GALNS",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "DNAJC21",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "NOG",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "ESCO2",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "COL11A1",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "PTDSS1",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "VAC14",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "TBX3",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "GRIA3",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "RNU4ATAC",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "GDF5",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "TRAPPC2",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "IHH",
"hpoTerm": undefined,
"impact": undefined,
},
{
"geneSymbol": "PCNT",
"hpoTerm": undefined,
"impact": undefined,
},
]
`;

exports[`Cada Prio Store > should predict gene impact 1`] = `
[
{
"geneSymbol": "WNT7A",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:12786",
"ncbiGeneId": "7476",
"rank": 1,
"score": 76.84823608398438,
},
{
"geneSymbol": "SMARCA2",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:11098",
"ncbiGeneId": "6595",
"rank": 2,
"score": 76.46592712402344,
},
{
"geneSymbol": "EFL1",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:25789",
"ncbiGeneId": "79631",
"rank": 3,
"score": 69.20905303955078,
},
{
"geneSymbol": "SRP54",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:11301",
"ncbiGeneId": "6729",
"rank": 4,
"score": 65.58743286132812,
},
{
"geneSymbol": "HPGD",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:5154",
"ncbiGeneId": "3248",
"rank": 5,
"score": 63.857845306396484,
},
{
"geneSymbol": "GALNS",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:4122",
"ncbiGeneId": "2588",
"rank": 6,
"score": 63.840911865234375,
},
{
"geneSymbol": "DNAJC21",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:27030",
"ncbiGeneId": "134218",
"rank": 7,
"score": 63.35689926147461,
},
{
"geneSymbol": "NOG",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:7866",
"ncbiGeneId": "9241",
"rank": 8,
"score": 63.207393646240234,
},
{
"geneSymbol": "ESCO2",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:27230",
"ncbiGeneId": "157570",
"rank": 9,
"score": 63.09525680541992,
},
{
"geneSymbol": "COL11A1",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:2186",
"ncbiGeneId": "1301",
"rank": 10,
"score": 61.24506378173828,
},
{
"geneSymbol": "PTDSS1",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:9587",
"ncbiGeneId": "9791",
"rank": 11,
"score": 60.995365142822266,
},
{
"geneSymbol": "VAC14",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:25507",
"ncbiGeneId": "55697",
"rank": 12,
"score": 60.21630859375,
},
{
"geneSymbol": "TBX3",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:11602",
"ncbiGeneId": "6926",
"rank": 13,
"score": 59.911136627197266,
},
{
"geneSymbol": "GRIA3",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:4573",
"ncbiGeneId": "2892",
"rank": 14,
"score": 59.312957763671875,
},
{
"geneSymbol": "RNU4ATAC",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:34016",
"ncbiGeneId": "100151683",
"rank": 15,
"score": 59.29935836791992,
},
{
"geneSymbol": "GDF5",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:4220",
"ncbiGeneId": "8200",
"rank": 16,
"score": 58.710994720458984,
},
{
"geneSymbol": "TRAPPC2",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:23068",
"ncbiGeneId": "6399",
"rank": 17,
"score": 56.57151412963867,
},
{
"geneSymbol": "IHH",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:5956",
"ncbiGeneId": "3549",
"rank": 18,
"score": 55.67450714111328,
},
{
"geneSymbol": "PCNT",
"hpoTerm": undefined,
"impact": undefined,
"hgncId": "HGNC:16068",
"ncbiGeneId": "5116",
"rank": 19,
"score": 55.3505859375,
},
]
`;
1 change: 1 addition & 0 deletions src/store/cadaPrio/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './store'
export * from './types'
8 changes: 6 additions & 2 deletions src/store/cadaPrio/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
import { defineStore } from 'pinia'
import { ref } from 'vue'

import { CadaPrioClient, ResponseEntry } from '../../api/cadaPrio'
import { CadaPrioClient } from '../../api/cadaPrio'
import { StoreState } from '../../store'
import { GeneRank } from './types'

/** Options for `loadData()` */
export interface LoadDataOptions {
Expand All @@ -22,8 +23,11 @@ export const useCadaPrioStore = defineStore('cadaPrio', () => {
const storeState = ref<StoreState>(StoreState.Initial)

/** The current gene Ranking. */
const geneRanking = ref<ResponseEntry[] | undefined>(undefined)
const geneRanking = ref<GeneRank[] | undefined>(undefined)

/**
* Clear all data from store and reset it into initial state.
*/
function clearData() {
storeState.value = StoreState.Initial
geneRanking.value = undefined
Expand Down
1 change: 1 addition & 0 deletions src/store/cadaPrio/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { ResponseEntry as GeneRank } from '../../api/cadaPrio'
4 changes: 4 additions & 0 deletions src/store/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
import { createPinia } from 'pinia'

export * from './types'

export const pinia = createPinia()
2 changes: 1 addition & 1 deletion tsconfig.node.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true
},
"include": ["vite.config.ts"]
"include": ["vite.config.mts"]
}
2 changes: 1 addition & 1 deletion vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default defineConfig({
declarationMap: true
}
},
exclude: ['vite.config.ts']
exclude: ['vite.config.mts']
})
],
build: {
Expand Down
Loading