diff --git a/graphql-api/src/graphql/resolvers/va.spec.ts b/graphql-api/src/graphql/resolvers/va.spec.ts index 874c4275f..b0eb11bcb 100644 --- a/graphql-api/src/graphql/resolvers/va.spec.ts +++ b/graphql-api/src/graphql/resolvers/va.spec.ts @@ -61,6 +61,11 @@ describe('resolveVACohortAlleleFrequency', () => { ancestry_groups: [], filters: ['AC0'], flags: ['monoallelic'], + quality_metrics: { + allele_balance: { + alt: { bin_freq: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19] }, + }, + }, } const genomeEsDocument = { @@ -72,6 +77,16 @@ describe('resolveVACohortAlleleFrequency', () => { filters: ['AC0'], ancestry_groups: [], flags: ['monoallelic'], + quality_metrics: { + allele_balance: { + alt: { + bin_freq: [ + 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, + 117, 118, 119, + ], + }, + }, + }, } const variantESDocument = { @@ -117,7 +132,7 @@ describe('resolveVACohortAlleleFrequency', () => { lowComplexityRegion: true, lowConfidenceLossOfFunctionError: true, lossOfFunctionWarning: true, - heterozygousSkewedAlleleCount: null, + heterozygousSkewedAlleleCount: 37, }, }, ] @@ -158,7 +173,7 @@ describe('resolveVACohortAlleleFrequency', () => { lowComplexityRegion: true, lowConfidenceLossOfFunctionError: true, lossOfFunctionWarning: true, - heterozygousSkewedAlleleCount: null, + heterozygousSkewedAlleleCount: 237, }, }, ] diff --git a/graphql-api/src/graphql/resolvers/va.ts b/graphql-api/src/graphql/resolvers/va.ts index 309a066e2..0e8401d97 100644 --- a/graphql-api/src/graphql/resolvers/va.ts +++ b/graphql-api/src/graphql/resolvers/va.ts @@ -381,6 +381,25 @@ const addSubcohorts = ( return Object.values(subcohortMap) } +type ESFrequencies = { + quality_metrics: { + allele_balance: { + alt?: { + bin_freq: number[] + } + } + } +} + +const calculateHeterozygousSkewedAlleleCount = (frequencies: ESFrequencies): number | null => { + const { alt } = frequencies.quality_metrics.allele_balance + if (!alt) { + return null + } + + return alt.bin_freq[18] + alt.bin_freq[19] +} + const resolveVACohortAlleleFrequencies = async ( obj: any, args: any, @@ -406,7 +425,7 @@ const resolveVACohortAlleleFrequencies = async ( lowComplexityRegion: obj.flags.includes('lcr'), lowConfidenceLossOfFunctionError: obj.flags.includes('lc_lof'), lossOfFunctionWarning: obj.flags.includes('lof_flag'), - heterozygousSkewedAlleleCount: null, + heterozygousSkewedAlleleCount: calculateHeterozygousSkewedAlleleCount(frequencies), } const fullSet: Subset = {