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: adding store/geneInfo #72

Merged
merged 1 commit into from
Feb 1, 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
11 changes: 11 additions & 0 deletions src/api/annonars/__snapshots__/client.spec.ts.snap

Large diffs are not rendered by default.

32 changes: 11 additions & 21 deletions src/api/annonars/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@ import createFetchMock from 'vitest-fetch-mock'
import { LinearStrucvarImpl, SeqvarImpl } from '../../lib/genomicVars'
import { Record as GeneInfoRecord } from '../../pbs/annonars/genes/base'
import { AnnonarsClient } from './client'
import {
ClinvarSvQueryResponse,
GeneInfoResult,
GeneSearchResponse,
SeqvarInfoResponse
} from './types'
import { ClinvarSvQueryResponse } from './types'

const geneInfoBrca1Json = JSON.parse(
fs.readFileSync(
Expand All @@ -28,6 +23,9 @@ const searchInfoInfoEmpJson = JSON.parse(
const clinvarStrucvarResponseBrca1Json = JSON.parse(
fs.readFileSync(path.resolve(__dirname, './fixture.strucvarClinvarResponse.BRCA1.json'), 'utf8')
)
const clinvarPerGeneInfoResponseBrca1Json = JSON.parse(
fs.readFileSync(path.resolve(__dirname, './fixture.geneClinvar.BRCA1.json'), 'utf8')
)

const fetchMocker = createFetchMock(vi)

Expand All @@ -49,9 +47,7 @@ describe.concurrent('AnnonarsClient.fetchGeneInfo()', () => {
const result = await client.fetchGeneInfo('BRCA1')

// assert:
expect(JSON.stringify(result)).toEqual(
JSON.stringify(GeneInfoResult.fromJson({ genes: { 'HGNC:1100': geneInfoBrca1Json } }))
)
expect(JSON.stringify(result)).toMatchSnapshot()
})

it('fails to fetch gene info with wrong HGNC id', async () => {
Expand Down Expand Up @@ -89,9 +85,7 @@ describe.concurrent('AnnonarsClient.fetchVariantInfo()', () => {
const result = await client.fetchVariantInfo(seqvar)

// assert:
expect(JSON.stringify(result)).toEqual(
JSON.stringify(SeqvarInfoResponse.fromJson(variantInfoBrca1Json))
)
expect(JSON.stringify(result)).toMatchSnapshot()
})

it('do removes chr prefix from chromosome if genome release is grch38', async () => {
Expand All @@ -108,9 +102,7 @@ describe.concurrent('AnnonarsClient.fetchVariantInfo()', () => {
const result = await client.fetchVariantInfo(seqvar)

// assert:
expect(JSON.stringify(result)).toEqual(
JSON.stringify(SeqvarInfoResponse.fromJson(variantInfoBrca1Json))
)
expect(JSON.stringify(result)).toMatchSnapshot()
})

it('fails to fetch variant info with wrong variant', async () => {
Expand Down Expand Up @@ -142,14 +134,14 @@ describe.concurrent('AnnonarsClient.fetchGeneClinvarInfo()', () => {

it('fetches gene clinvar info correctly', async () => {
// arrange:
fetchMocker.mockResponseOnce(JSON.stringify(geneInfoBrca1Json))
fetchMocker.mockResponseOnce(JSON.stringify(clinvarPerGeneInfoResponseBrca1Json))

// act:
const client = new AnnonarsClient()
const result = await client.fetchGeneClinvarInfo('BRCA1')
const result = await client.fetchGeneClinvarInfo('HGNC:1100')

// assert:
expect(JSON.stringify(result)).toEqual(JSON.stringify(geneInfoBrca1Json))
expect(JSON.stringify(result)).toMatchSnapshot()
})

it('fails to fetch gene clinvar info with wrong HGNC id', async () => {
Expand Down Expand Up @@ -190,9 +182,7 @@ describe.concurrent('AnnonarsClient.fetchGenes()', () => {
)

// assert:
expect(JSON.stringify(result)).toEqual(
JSON.stringify(GeneSearchResponse.fromJson(searchInfoInfoEmpJson))
)
expect(JSON.stringify(result)).toMatchSnapshot()
})

it('fails to fetch genes with wrong query', async () => {
Expand Down
7 changes: 6 additions & 1 deletion src/api/annonars/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,12 @@ export class AnnonarsClient {
if (!response.ok) {
throw new Error(`failed to fetch gene clinvar info: ${response.statusText}`)
}
return await response.json()
const responseJson = await response.json()
if (responseJson?.genes && responseJson?.genes[hgncId]) {
return ClinvarPerGeneRecord.fromJson(responseJson.genes[hgncId])
} else {
throw new Error(`failed to fetch gene clinvar info for HGNC ID: ${hgncId}`)
}
}

/**
Expand Down
216 changes: 216 additions & 0 deletions src/api/annonars/fixture.geneClinvar.BRCA1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
{
"genes": {
"HGNC:1100": {
"perImpactCounts": [
{ "impact": "IMPACT_THREE_PRIME_UTR_VARIANT", "counts": [30, 112, 196, 41, 115] },
{ "impact": "IMPACT_FIVE_PRIME_UTR_VARIANT", "counts": [47, 376, 244, 33, 275] },
{ "impact": "IMPACT_FRAMESHIFT_VARIANT", "counts": [0, 1, 31, 115, 3883] },
{ "impact": "IMPACT_INFRAME_INDEL", "counts": [5, 15, 168, 10, 20] },
{ "impact": "IMPACT_INTRON_VARIANT", "counts": [1085, 4679, 3585, 186, 1701] },
{ "impact": "IMPACT_MISSENSE_VARIANT", "counts": [124, 374, 2202, 158, 212] },
{ "impact": "IMPACT_NON_CODING_TRANSCRIPT_VARIANT", "counts": [0, 1, 7, 9, 437] },
{ "impact": "IMPACT_STOP_GAINED", "counts": [1, 0, 1, 1, 12] },
{ "impact": "IMPACT_SPLICE_ACCEPTOR_VARIANT", "counts": [0, 1, 4, 13, 82] },
{ "impact": "IMPACT_SPLICE_DONOR_VARIANT", "counts": [0, 0, 7, 10, 87] },
{ "impact": "IMPACT_SYNONYMOUS_VARIANT", "counts": [11, 178, 7, 0, 5] },
{ "impact": "IMPACT_UPSTREAM_TRANSCRIPT_VARIANT", "counts": [4, 0, 0, 0, 0] }
],
"perFreqCounts": [
{
"coarseClinsig": "COARSE_CLINICAL_SIGNIFICANCE_BENIGN",
"counts": [5712, 0, 0, 0, 0, 317, 87, 101, 133, 133, 113, 122, 31, 18, 24, 279, 3, 0]
},
{
"coarseClinsig": "COARSE_CLINICAL_SIGNIFICANCE_UNCERTAIN",
"counts": [6318, 0, 0, 0, 0, 173, 22, 20, 3, 2, 4, 3, 0, 1, 0, 10, 0, 0]
},
{
"coarseClinsig": "COARSE_CLINICAL_SIGNIFICANCE_PATHOGENIC",
"counts": [7934, 0, 0, 0, 0, 35, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
}
],
"variants": [
{
"genomeRelease": "GRCh37",
"variants": [
{
"release": "GRCh37",
"chromosome": "17",
"start": 41197708,
"stop": 41197708,
"reference": "T",
"alternative": "G",
"vcv": "VCV000041833",
"referenceAssertions": [
{
"rcv": "RCV000034760",
"title": "NM_007294.4(BRCA1):c.5579A>C (p.His1860Pro) AND not provided",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_BENIGN",
"reviewStatus": "REVIEW_STATUS_NO_ASSERTION_CRITERIA_PROVIDED"
}
]
},
{
"release": "GRCh37",
"chromosome": "17",
"start": 41234473,
"stop": 41234473,
"reference": "G",
"alternative": "C",
"vcv": "VCV000182080",
"referenceAssertions": [
{
"rcv": "RCV000159851",
"title": "NM_007294.4(BRCA1):c.4305C>G (p.Asp1435Glu) AND not provided",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
},
{
"release": "GRCh37",
"chromosome": "17",
"start": 41234589,
"stop": 41234591,
"reference": "CTCT",
"alternative": "C",
"vcv": "VCV000182116",
"referenceAssertions": [
{
"rcv": "RCV000159925",
"title": "NM_007294.4(BRCA1):c.4187_4189del (p.Gln1396del) AND not provided",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
},
{
"release": "GRCh37",
"chromosome": "17",
"start": 41226408,
"stop": 41226409,
"reference": "GC",
"alternative": "AA",
"vcv": "VCV000182117",
"referenceAssertions": [
{
"rcv": "RCV000159926",
"title": "NM_007294.4(BRCA1):c.4614_4615delinsTT (p.Gln1538His) AND not specified",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
},
{
"release": "GRCh37",
"chromosome": "17",
"start": 41276145,
"stop": 41276149,
"reference": "AGAAA",
"alternative": "TT",
"vcv": "VCV000246265",
"referenceAssertions": [
{
"rcv": "RCV000235381",
"title": "NM_007294.4(BRCA1):c.-19-17_-19-13delinsAA AND not specified",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
}
]
},
{
"genomeRelease": "GRCh38",
"variants": [
{
"release": "GRCh38",
"chromosome": "17",
"start": 43045691,
"stop": 43045691,
"reference": "T",
"alternative": "G",
"vcv": "VCV000041833",
"referenceAssertions": [
{
"rcv": "RCV000034760",
"title": "NM_007294.4(BRCA1):c.5579A>C (p.His1860Pro) AND not provided",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_BENIGN",
"reviewStatus": "REVIEW_STATUS_NO_ASSERTION_CRITERIA_PROVIDED"
}
]
},
{
"release": "GRCh38",
"chromosome": "17",
"start": 43082456,
"stop": 43082456,
"reference": "G",
"alternative": "C",
"vcv": "VCV000182080",
"referenceAssertions": [
{
"rcv": "RCV000159851",
"title": "NM_007294.4(BRCA1):c.4305C>G (p.Asp1435Glu) AND not provided",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
},
{
"release": "GRCh38",
"chromosome": "17",
"start": 43082572,
"stop": 43082574,
"reference": "CTCT",
"alternative": "C",
"vcv": "VCV000182116",
"referenceAssertions": [
{
"rcv": "RCV000159925",
"title": "NM_007294.4(BRCA1):c.4187_4189del (p.Gln1396del) AND not provided",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
},
{
"release": "GRCh38",
"chromosome": "17",
"start": 43074391,
"stop": 43074392,
"reference": "GC",
"alternative": "AA",
"vcv": "VCV000182117",
"referenceAssertions": [
{
"rcv": "RCV000159926",
"title": "NM_007294.4(BRCA1):c.4614_4615delinsTT (p.Gln1538His) AND not specified",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
},
{
"release": "GRCh38",
"chromosome": "17",
"start": 43124128,
"stop": 43124132,
"reference": "AGAAA",
"alternative": "TT",
"vcv": "VCV000246265",
"referenceAssertions": [
{
"rcv": "RCV000235381",
"title": "NM_007294.4(BRCA1):c.-19-17_-19-13delinsAA AND not specified",
"clinicalSignificance": "CLINICAL_SIGNIFICANCE_UNCERTAIN_SIGNIFICANCE",
"reviewStatus": "REVIEW_STATUS_CRITERIA_PROVIDED_SINGLE_SUBMITTER"
}
]
}
]
}
]
}
}
}
Loading
Loading