Skip to content

Commit

Permalink
fix(browser): clinvar track doesn't crash with unknown transcript fra…
Browse files Browse the repository at this point in the history
…mshift 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
  • Loading branch information
rileyhgrant committed May 1, 2024
1 parent 0f71b02 commit ef61635
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions browser/src/ClinvarVariantsTrack/ClinvarAllVariantsPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,28 @@ const VariantLine = ({
opacity = 0.2
}

// console.log(variant)

if (category === 'frameshift') {
const transcript = 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)
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 (
<TooltipAnchor
Expand Down

0 comments on commit ef61635

Please sign in to comment.