Skip to content

Commit

Permalink
Try making va_api graphql response from elasticsarch data
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsolo1 committed May 6, 2024
1 parent ee902e1 commit b11212b
Show file tree
Hide file tree
Showing 11 changed files with 1,865 additions and 97 deletions.
28 changes: 28 additions & 0 deletions graphql-api/__tests__/va_shaper.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import Ajv from 'ajv'
import * as fs from 'fs'
import { vaShaper } from '../src/queries/helpers/va-shaper'

// vaShaper

const elasticData = JSON.parse(fs.readFileSync('./data/elastic/1-55051215-G-GA.json', 'utf8'))
const restData = JSON.parse(fs.readFileSync('./data/rest/1-55051215-G-GA.json', 'utf8'))
const jsonSchema = JSON.parse(fs.readFileSync('./data/schema/va_schema.json', 'utf8'))

const ajv = new Ajv({ strict: false })
const validate = ajv.compile(jsonSchema)

test('validate restData against jsonSchema', () => {
const data = { ...restData[0] }
// console.log(data)
const valid = validate(data.gks_va_freq)
if (!valid) console.log(validate.errors)

Check warning on line 18 in graphql-api/__tests__/va_shaper.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

Unexpected console statement
expect(valid).toBe(true)
})

test('validate shaped es data against jsonSchema', () => {
const data = vaShaper(elasticData)
console.log(data)

Check warning on line 24 in graphql-api/__tests__/va_shaper.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

Unexpected console statement
const valid = validate(data.va)
if (!valid) console.log(validate.errors)

Check warning on line 26 in graphql-api/__tests__/va_shaper.spec.ts

View workflow job for this annotation

GitHub Actions / Checks

Unexpected console statement
expect(valid).toBe(true)
})
1 change: 1 addition & 0 deletions graphql-api/data/elastic/1-55051215-G-GA.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions graphql-api/data/elastic_shaped/1-55051215-G-GA.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions graphql-api/data/rest/1-55051215-G-GA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"alleles":["G","GA"],"gks_va_freq":{"alleleFrequency":0.0006317119393556538,"ancillaryResults":{"grpMaxFAF95":{"confidenceInterval":0.95,"frequency":0.01436439999999997,"groupId":"chr1-55051215-G-GA.AFR"},"homozygotes":2,"jointGrpMaxFAF95":{"confidenceInterval":0.95,"frequency":0.015524919999999998,"groupId":"chr1-55051215-G-GA.AFR"}},"cohort":{"id":"ALL"},"derivedFrom":{"id":"gnomAD4.0.0","label":"gnomAD v4.0.0","type":"DataSet","version":"4.0.0"},"focusAllele":{"_id":"ga4gh:VA.hingrE1dTh6sN0lzvUD-vpatd6ukTP3S","location":{"_id":"ga4gh:VSL.InpKcN9eiYwJ2voGoMTySZ3bdsiNem1o","interval":{"end":{"type":"Number","value":55051215},"start":{"type":"Number","value":55051215},"type":"SequenceInterval"},"sequence_id":"ga4gh:SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO","type":"SequenceLocation"},"state":{"sequence":"A","type":"LiteralSequenceExpression"},"type":"Allele"},"focusAlleleCount":192,"id":"gnomAD-4.0.0-chr1-55051215-G-GA","label":"Overall Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":303936,"qualityMeasures":{"fractionCoverage20x":0.20684673444175844,"heterozygousSkewedAlleleCount":0,"lowComplexityRegion":false,"meanDepth":6.826644065848823,"monoallelic":false,"qcFilters":[]},"subcohortFrequency":[{"alleleFrequency":0.016577788082541154,"ancillaryResults":{"homozygotes":2},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"African/African-American"}],"id":"AFR"},"focusAllele":"#/focusAllele","focusAlleleCount":143,"id":"chr1-55051215-G-GA.AFR","label":"African/African-American Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":8626,"subcohortFrequency":[{"alleleFrequency":0.019029126213592235,"ancillaryResults":{"homozygotes":1},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"African/African-American"},{"name":"biological sex","value":"XX"}],"id":"AFR.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":98,"id":"chr1-55051215-G-GA.AFR.XX","label":"African/African-American Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":5150,"type":"CohortAlleleFrequency"},{"alleleFrequency":0.012945914844649022,"ancillaryResults":{"homozygotes":1},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"African/African-American"},{"name":"biological sex","value":"XY"}],"id":"AFR.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":45,"id":"chr1-55051215-G-GA.AFR.XY","label":"African/African-American Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":3476,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0.0006967363403006967,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Admixed American"}],"id":"AMR"},"focusAllele":"#/focusAllele","focusAlleleCount":19,"id":"chr1-55051215-G-GA.AMR","label":"Admixed American Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":27270,"subcohortFrequency":[{"alleleFrequency":0.0007686395080707148,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Admixed American"},{"name":"biological sex","value":"XX"}],"id":"AMR.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":12,"id":"chr1-55051215-G-GA.AMR.XX","label":"Admixed American Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":15612,"type":"CohortAlleleFrequency"},{"alleleFrequency":0.0006004460456338995,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Admixed American"},{"name":"biological sex","value":"XY"}],"id":"AMR.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":7,"id":"chr1-55051215-G-GA.AMR.XY","label":"Admixed American Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":11658,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Ashkenazi Jewish"}],"id":"ASJ"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.ASJ","label":"Ashkenazi Jewish Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":10788,"subcohortFrequency":[{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Ashkenazi Jewish"},{"name":"biological sex","value":"XX"}],"id":"ASJ.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.ASJ.XX","label":"Ashkenazi Jewish Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":5164,"type":"CohortAlleleFrequency"},{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Ashkenazi Jewish"},{"name":"biological sex","value":"XY"}],"id":"ASJ.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.ASJ.XY","label":"Ashkenazi Jewish Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":5624,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"East Asian"}],"id":"EAS"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.EAS","label":"East Asian Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":9210,"subcohortFrequency":[{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"East Asian"},{"name":"biological sex","value":"XX"}],"id":"EAS.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.EAS.XX","label":"East Asian Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":4158,"type":"CohortAlleleFrequency"},{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"East Asian"},{"name":"biological sex","value":"XY"}],"id":"EAS.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.EAS.XY","label":"East Asian Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":5052,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Finnish"}],"id":"FIN"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.FIN","label":"Finnish Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":12364,"subcohortFrequency":[{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Finnish"},{"name":"biological sex","value":"XX"}],"id":"FIN.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.FIN.XX","label":"Finnish Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":6434,"type":"CohortAlleleFrequency"},{"alleleFrequency":0,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Finnish"},{"name":"biological sex","value":"XY"}],"id":"FIN.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":0,"id":"chr1-55051215-G-GA.FIN.XY","label":"Finnish Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":5930,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0.0017972681524083393,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Middle Eastern"}],"id":"MID"},"focusAllele":"#/focusAllele","focusAlleleCount":5,"id":"chr1-55051215-G-GA.MID","label":"Middle Eastern Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":2782,"subcohortFrequency":[{"alleleFrequency":0.002962962962962963,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Middle Eastern"},{"name":"biological sex","value":"XX"}],"id":"MID.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":4,"id":"chr1-55051215-G-GA.MID.XX","label":"Middle Eastern Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":1350,"type":"CohortAlleleFrequency"},{"alleleFrequency":0.0006983240223463687,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Middle Eastern"},{"name":"biological sex","value":"XY"}],"id":"MID.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":1,"id":"chr1-55051215-G-GA.MID.XY","label":"Middle Eastern Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":1432,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0.00004404621076741084,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Non-Finnish European"}],"id":"NFE"},"focusAllele":"#/focusAllele","focusAlleleCount":7,"id":"chr1-55051215-G-GA.NFE","label":"Non-Finnish European Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":158924,"subcohortFrequency":[{"alleleFrequency":0.000053718675297467166,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Non-Finnish European"},{"name":"biological sex","value":"XX"}],"id":"NFE.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":4,"id":"chr1-55051215-G-GA.NFE.XX","label":"Non-Finnish European Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":74462,"type":"CohortAlleleFrequency"},{"alleleFrequency":0.00003551893159053776,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Non-Finnish European"},{"name":"biological sex","value":"XY"}],"id":"NFE.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":3,"id":"chr1-55051215-G-GA.NFE.XY","label":"Non-Finnish European Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":84462,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0.001124543154343548,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Remaining individuals"}],"id":"REMAINING"},"focusAllele":"#/focusAllele","focusAlleleCount":16,"id":"chr1-55051215-G-GA.REMAINING","label":"Remaining individuals Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":14228,"subcohortFrequency":[{"alleleFrequency":0.0014518002322880372,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Remaining individuals"},{"name":"biological sex","value":"XX"}],"id":"REMAINING.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":10,"id":"chr1-55051215-G-GA.REMAINING.XX","label":"Remaining individuals Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":6888,"type":"CohortAlleleFrequency"},{"alleleFrequency":0.0008174386920980927,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"Remaining individuals"},{"name":"biological sex","value":"XY"}],"id":"REMAINING.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":6,"id":"chr1-55051215-G-GA.REMAINING.XY","label":"Remaining individuals Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":7340,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},{"alleleFrequency":0.000033476164970540974,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"South Asian"}],"id":"SAS"},"focusAllele":"#/focusAllele","focusAlleleCount":2,"id":"chr1-55051215-G-GA.SAS","label":"South Asian Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":59744,"subcohortFrequency":[{"alleleFrequency":0.00008576329331046312,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"South Asian"},{"name":"biological sex","value":"XX"}],"id":"SAS.XX"},"focusAllele":"#/focusAllele","focusAlleleCount":1,"id":"chr1-55051215-G-GA.SAS.XX","label":"South Asian Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":11660,"type":"CohortAlleleFrequency"},{"alleleFrequency":0.00002079693869062474,"ancillaryResults":{"homozygotes":0},"cohort":{"characteristics":[{"name":"genetic ancestry","value":"South Asian"},{"name":"biological sex","value":"XY"}],"id":"SAS.XY"},"focusAllele":"#/focusAllele","focusAlleleCount":1,"id":"chr1-55051215-G-GA.SAS.XY","label":"South Asian Cohort Allele Frequency for chr1-55051215-G-GA","locusAlleleCount":48084,"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"}],"type":"CohortAlleleFrequency"},"gks_vrs_variant":{"_id":"ga4gh:VA.hingrE1dTh6sN0lzvUD-vpatd6ukTP3S","location":{"_id":"ga4gh:VSL.InpKcN9eiYwJ2voGoMTySZ3bdsiNem1o","interval":{"end":{"type":"Number","value":55051215},"start":{"type":"Number","value":55051215},"type":"SequenceInterval"},"sequence_id":"ga4gh:SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO","type":"SequenceLocation"},"state":{"sequence":"A","type":"LiteralSequenceExpression"},"type":"Allele"},"locus":{"contig":"chr1","position":55051215,"reference_genome":"GRCh38"}}]
Loading

0 comments on commit b11212b

Please sign in to comment.