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

feat: Retrieval of affected genes in SV from mehari (#56) #107

Merged
merged 2 commits into from
Oct 4, 2023
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
35 changes: 32 additions & 3 deletions frontend/src/api/__tests__/mehari.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import createFetchMock from 'vitest-fetch-mock'

import { MehariClient } from '@/api/mehari'
import * as BRCA1TxInfo from '@/assets/__tests__/BRCA1TxInfo.json'
import * as SVInfo from '@/assets/__tests__/ExampleSVTxInfo.json'

const fetchMocker = createFetchMock(vi)

Expand All @@ -16,15 +17,22 @@ describe.concurrent('Mehari Client', () => {
fetchMocker.mockResponseOnce(JSON.stringify(BRCA1TxInfo))

const client = new MehariClient()
const result = await client.retrieveTxCsq('grch37', 'chr17', 43044295, 'A', 'G', 'HGNC:1100')
const result = await client.retrieveSeqvarsCsq(
'grch37',
'chr17',
43044295,
'A',
'G',
'HGNC:1100'
)
expect(JSON.stringify(result)).toEqual(JSON.stringify(BRCA1TxInfo))
})

it('fetches TxCsq info correctly without HGNC id', async () => {
fetchMocker.mockResponseOnce(JSON.stringify(BRCA1TxInfo))

const client = new MehariClient()
const result = await client.retrieveTxCsq('grch37', 'chr17', 43044295, 'A', 'G')
const result = await client.retrieveSeqvarsCsq('grch37', 'chr17', 43044295, 'A', 'G')
expect(JSON.stringify(result)).toEqual(JSON.stringify(BRCA1TxInfo))
})

Expand All @@ -37,7 +45,28 @@ describe.concurrent('Mehari Client', () => {
})

const client = new MehariClient()
const result = await client.retrieveTxCsq('grch37', 'chr17', 43044295, 'A', 'T')
const result = await client.retrieveSeqvarsCsq('grch37', 'chr17', 43044295, 'A', 'T')
expect(JSON.stringify(result)).toEqual(JSON.stringify({ status: 400 }))
})

it('fetches Structur Variant info correctly', async () => {
fetchMocker.mockResponseOnce(JSON.stringify(SVInfo))

const client = new MehariClient()
const result = await client.retrieveStrucvarsCsq('grch37', 'chr17', 43044295, 43044297, 'DEL')
expect(JSON.stringify(result)).toEqual(JSON.stringify(SVInfo))
})

it('fails to fetch variant info with wrong variant', async () => {
fetchMocker.mockResponse((req) => {
if (req.url.includes('alternative=G')) {
return Promise.resolve(JSON.stringify(SVInfo))
}
return Promise.resolve(JSON.stringify({ status: 400 }))
})

const client = new MehariClient()
const result = await client.retrieveStrucvarsCsq('grch37', 'chr17', 43044295, 43044297, 'INS')
expect(JSON.stringify(result)).toEqual(JSON.stringify({ status: 400 }))
})
})
18 changes: 17 additions & 1 deletion frontend/src/api/mehari.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class MehariClient {
this.csrfToken = csrfToken ?? null
}

async retrieveTxCsq(
async retrieveSeqvarsCsq(
genomeRelease: string,
chromosome: string,
pos: number,
Expand All @@ -30,4 +30,20 @@ export class MehariClient {
})
return await response.json()
}

async retrieveStrucvarsCsq(
genomeRelease: string,
chromosome: string,
start: number,
stop: number,
sv_type: string
): Promise<any> {
const url =
`${this.apiBaseUrl}strucvars/csq?genome_release=${genomeRelease}&` +
`chromosome=${chromosome}&start=${start}&stop=${stop}&sv_type=${sv_type}`
const response = await fetch(url, {
method: 'GET'
})
return await response.json()
}
}
3 changes: 3 additions & 0 deletions frontend/src/assets/__tests__/ExampleSV.json
Git LFS file not shown
3 changes: 3 additions & 0 deletions frontend/src/assets/__tests__/ExampleSVTxInfo.json
Git LFS file not shown
Loading
Loading