From 90c654e44e7345b3744f2206bc1bdedef9b9edc4 Mon Sep 17 00:00:00 2001 From: Riley Grant Date: Wed, 1 May 2024 16:54:01 -0500 Subject: [PATCH 1/2] fix(browser): clinvar track doesn't crash with unknown transcript framshift variant In rare cases, there can be a frameshift variant from ClinVar on a transcript that the browser doesn't display, here we manually set the exon array to [] to prevent a crash when trying to render the line with CDS or UTR lines --- .../ClinvarAllVariantsPlot.tsx | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx b/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx index 5625d2ce0..221ce8c86 100644 --- a/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx +++ b/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx @@ -216,15 +216,19 @@ const VariantLine = ({ const frameshiftMaxPos = Math.max(endpoint1, endpoint2) const terminationPos = transcript && transcript.strand === '+' ? frameshiftMaxPos : frameshiftMinPos - // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. - const frameshiftExonRegions = transcript.exons - .sort((e1, e2) => e1.start - e2.start) - .filter((e) => e.start <= frameshiftMaxPos && e.stop >= frameshiftMinPos) - .map((e) => ({ - start: Math.max(e.start, frameshiftMinPos), - stop: Math.min(e.stop, frameshiftMaxPos), - feature_type: e.feature_type, - })) + + // if a frameshift variant-consequence pair from ClinVar exists for a transcript + // that the browser doesn't recognize, use an empty array for exon information + const frameshiftExonRegions = transcript + ? transcript.exons + .sort((e1, e2) => e1.start - e2.start) + .filter((e) => e.start <= frameshiftMaxPos && e.stop >= frameshiftMinPos) + .map((e) => ({ + start: Math.max(e.start, frameshiftMinPos), + stop: Math.min(e.stop, frameshiftMaxPos), + feature_type: e.feature_type, + })) + : [] return ( Date: Thu, 23 May 2024 08:38:01 -0500 Subject: [PATCH 2/2] fixup(browser): include suggestions from code review --- browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx b/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx index 221ce8c86..35a213236 100644 --- a/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx +++ b/browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx @@ -210,7 +210,9 @@ const VariantLine = ({ } if (category === 'frameshift') { - const transcript = transcripts.find((t) => t.transcript_id === variant.transcript_id) + const transcript: Transcript | undefined = transcripts.find( + (t) => t.transcript_id === variant.transcript_id + ) const [endpoint1, endpoint2] = getGlobalFrameshiftCoordinates(variant, transcript) const frameshiftMinPos = Math.min(endpoint1, endpoint2) const frameshiftMaxPos = Math.max(endpoint1, endpoint2)