Skip to content

Commit

Permalink
feat: improve HPO lookup result quality with latest viguno (#338) (#346)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe authored Dec 27, 2023
1 parent 096cc85 commit 84d2c7b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
4 changes: 2 additions & 2 deletions frontend/src/api/viguno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ export class VigunoClient {
return await response.json()
}

async queryHpoTermsByName(query: string, matchType: string = 'contains'): Promise<any> {
const url = `${this.apiBaseUrl}hpo/terms?name=${query}&match=${matchType}`
async queryHpoTermsByName(query: string): Promise<any> {
const url = `${this.apiBaseUrl}hpo/terms?name=${query}`
const response = await fetch(url, {
method: 'GET'
})
Expand Down
10 changes: 8 additions & 2 deletions frontend/src/components/CaseInformationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ watch(
:items="termsStore.omimTerms"
:loading="omimIsLoading"
label="Disease"
item-title="name"
:item-title="(item) => item.name"
:item-value="(item) => item"
multiple
chips
Expand All @@ -187,8 +187,14 @@ watch(
:items="termsStore.hpoTerms"
:loading="hpoIsLoading"
label="HPO Terms"
item-title="name"
:item-title="(item) => `${item.name} (${item.term_id})`"
:item-value="(item) => item"
:item-props="
(item) => ({
subtitle: item.definition
})
"
:no-filter="true"
multiple
chips
closable-chips
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/stores/__tests__/terms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ describe.concurrent('Terms Store', () => {
})

it('fetches HPO term by ID', async () => {
const mockHpoTerm = { term_id: 'HP:0000118', name: 'Phenotypic abnormality' }
fetchMocker.mockResponseOnce(JSON.stringify({ result: mockHpoTerm }))
const mockHpoTerms = [{ term_id: 'HP:0000118', name: 'Phenotypic abnormality' }]
fetchMocker.mockResponseOnce(JSON.stringify({ result: mockHpoTerms }))

const store = useTermsStore()
await store.fetchHpoTerms('HP:0000118')

expect(store.storeState).toBe(StoreState.Active)
expect(store.hpoTerms).toEqual([mockHpoTerm])
expect(store.hpoTerms).toEqual(mockHpoTerms)
})

it('handles error when fetching HPO terms', async () => {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/stores/case.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export const ZygosityLabels = new Map<Zygosity, string>([
export interface HpoTerm {
term_id: string
name: string
definition?: string
}

/** Interface for storing one OMIM term, for storage and API. */
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/stores/terms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ export const useTermsStore = defineStore('terms', () => {
try {
// Check if query matches the pattern for HPO ID
if (hpoIdPattern.test(query)) {
// Extract only the digits part if "HPO:" is present
const hpoId = query.replace(/^HP:/, '')
const response = await vigunoClient.resolveHpoTermById(hpoId)
hpoTerms.value = [response.result as HpoTerm]
const response = await vigunoClient.resolveHpoTermById(query)
hpoTerms.value = response.result as HpoTerm[]
} else {
const response = await vigunoClient.queryHpoTermsByName(query)
hpoTerms.value = response.result.map((item: any) => item as HpoTerm)
Expand Down

0 comments on commit 84d2c7b

Please sign in to comment.