Skip to content

Commit

Permalink
fixup: different title depending on if RNA or protein gene
Browse files Browse the repository at this point in the history
  • Loading branch information
phildarnowsky-broad committed Jun 4, 2024
1 parent 8a9f2c3 commit 1624dad
Show file tree
Hide file tree
Showing 4 changed files with 226 additions and 22 deletions.
1 change: 1 addition & 0 deletions browser/src/GenePage/GenePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -571,6 +571,7 @@ const GenePage = ({ datasetId, gene, geneId }: Props) => {
<MitochondrialRegionConstraintTrack
constraintRegions={gene.mitochondrial_missense_constraint_regions}
exons={gene.exons}
geneSymbol={gene.symbol}
/>
)}

Expand Down
74 changes: 56 additions & 18 deletions browser/src/GenePage/MitochondrialRegionConstraintTrack.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,63 @@ const childProps = {
}

const exons: Exon[] = [{ feature_type: 'CDS', start: 123, stop: 1999 }]
const constraintRegions: MitochondrialConstraintRegion[] = [
{ start: 555, stop: 666, oe: 0.45, oe_lower: 0.37, oe_upper: 0.47 },
{ start: 777, stop: 888, oe: 0.56, oe_lower: 0.52, oe_upper: 0.59 },
]

test('track has no unexpected changes when gene has constraint', () => {
const constraintRegions: MitochondrialConstraintRegion[] = [
{ start: 555, stop: 666, oe: 0.45, oe_lower: 0.37, oe_upper: 0.47 },
{ start: 777, stop: 888, oe: 0.56, oe_lower: 0.52, oe_upper: 0.59 },
]
const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<MitochondrialRegionConstraintTrack constraintRegions={constraintRegions} exons={exons} />
</RegionViewerContext.Provider>
)
expect(tree).toMatchSnapshot()
describe('MitochondrialRegionConstraintTrack for a protein gene', () => {
test('track has no unexpected changes when gene has constraint', () => {
const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<MitochondrialRegionConstraintTrack
geneSymbol="MT-ATP6"
constraintRegions={constraintRegions}
exons={exons}
/>
</RegionViewerContext.Provider>
)
expect(tree).toMatchSnapshot()
})

test('track has no unexpected changes when no constraint for gene', () => {
const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<MitochondrialRegionConstraintTrack
geneSymbol="MT-ATP6"
constraintRegions={null}
exons={exons}
/>
</RegionViewerContext.Provider>
)
expect(tree).toMatchSnapshot()
})
})

test('track has no unexpected changes when no constraint for gene', () => {
const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<MitochondrialRegionConstraintTrack constraintRegions={null} exons={exons} />
</RegionViewerContext.Provider>
)
expect(tree).toMatchSnapshot()
describe('MitochondrialRegionConstraintTrack for an RNA gene', () => {
test('track has no unexpected changes when gene has constraint', () => {
const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<MitochondrialRegionConstraintTrack
geneSymbol="MT-RNR1"
constraintRegions={constraintRegions}
exons={exons}
/>
</RegionViewerContext.Provider>
)
expect(tree).toMatchSnapshot()
})

test('track has no unexpected changes when no constraint for gene', () => {
const tree = renderer.create(
<RegionViewerContext.Provider value={childProps}>
<MitochondrialRegionConstraintTrack
geneSymbol="MT-RNR1"
constraintRegions={null}
exons={exons}
/>
</RegionViewerContext.Provider>
)
expect(tree).toMatchSnapshot()
})
})
8 changes: 6 additions & 2 deletions browser/src/GenePage/MitochondrialRegionConstraintTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type MitochondrialConstraintRegion = {
}

type Props = {
geneSymbol: string
constraintRegions: MitochondrialConstraintRegion[] | null
exons: Exon[]
}
Expand Down Expand Up @@ -49,14 +50,17 @@ const Tooltip = ({ region }: TooltipProps) => {

const formattedOE = (region: MitochondrialConstraintRegion) => region.oe.toFixed(3)

const MitochondrialConstraintRegionTrack = ({ constraintRegions, exons }: Props) => {
const MitochondrialConstraintRegionTrack = ({ geneSymbol, constraintRegions, exons }: Props) => {
if (constraintRegions === null) {
return null
}

const isRNAGene = geneSymbol.startsWith('MT-R')
const trackTitle = isRNAGene ? 'Regional constraint' : 'Regional missense constraint'

return (
<ConstraintTrack
trackTitle="Regional constraint"
trackTitle={trackTitle}
infobuttonTopic="TK-mitochondrial-gene-constraint"
legend={<Legend />}
valueFn={formattedOE}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,141 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`track has no unexpected changes when gene has constraint 1`] = `
exports[`MitochondrialRegionConstraintTrack for a protein gene track has no unexpected changes when gene has constraint 1`] = `
<div
className="ConstraintTrack__Wrapper-sc-113yvfg-1 iBhwwK"
>
<div
className="Track__OuterWrapper-sc-1sdyh2h-0 bBMGlf"
>
<div
className="Track__InnerWrapper-sc-1sdyh2h-1 cEOGGC"
>
<div
className="Track__SidePanel-sc-1sdyh2h-3 iSYzDq"
style={
{
"width": 4,
}
}
>
<div
className="ConstraintTrack__SidePanel-sc-113yvfg-2 dJMFds"
>
<span>
Regional missense constraint
</span>
<button
className="InfoButton__Button-sc-13t5e82-0 gxsoyZ"
onClick={[Function]}
type="button"
>
<img
alt=""
aria-hidden="true"
src="test-file-stub"
/>
<span
style={
{
"border": "0",
"clip": "rect(0 0 0 0)",
"height": "1px",
"margin": "-1px",
"overflow": "hidden",
"padding": "0",
"position": "absolute",
"whiteSpace": "nowrap",
"width": "1px",
}
}
>
More information
</span>
</button>
</div>
</div>
<div
className="Track__CenterPanel-sc-1sdyh2h-4 iAyrrk"
style={
{
"width": 3,
}
}
>
<div
className="ConstraintTrack__TopPanel-sc-113yvfg-3 imJcbb"
>
<div
className="ConstraintTrack__LegendWrapper-sc-113yvfg-4 kkHtue"
>
<span>
Constrained region
</span>
<svg
height={25}
width={50}
>
<rect
fill="#fd8d3c"
height={10}
stroke="#000"
width={30}
x={10}
y={3}
/>
</svg>
</div>
</div>
<div
className="ConstraintTrack__PlotWrapper-sc-113yvfg-0 fHKmMU"
>
<svg
height={55}
width={3}
>
<rect
height={1}
width={3}
x={0}
y={7.5}
/>
<g
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
fill="#fd8d3c"
height={15}
stroke="black"
width={111}
x={555}
y={1}
/>
</g>
<g
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
fill="#fd8d3c"
height={15}
stroke="black"
width={111}
x={777}
y={1}
/>
</g>
</svg>
</div>
</div>
</div>
</div>
</div>
`;

exports[`MitochondrialRegionConstraintTrack for a protein gene track has no unexpected changes when no constraint for gene 1`] = `null`;

exports[`MitochondrialRegionConstraintTrack for an RNA gene track has no unexpected changes when gene has constraint 1`] = `
<div
className="ConstraintTrack__Wrapper-sc-113yvfg-1 iBhwwK"
>
Expand Down Expand Up @@ -99,6 +234,32 @@ exports[`track has no unexpected changes when gene has constraint 1`] = `
x={0}
y={7.5}
/>
<g
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
fill="#fd8d3c"
height={15}
stroke="black"
width={111}
x={555}
y={1}
/>
</g>
<g
onMouseEnter={[Function]}
onMouseLeave={[Function]}
>
<rect
fill="#fd8d3c"
height={15}
stroke="black"
width={111}
x={777}
y={1}
/>
</g>
</svg>
</div>
</div>
Expand All @@ -107,4 +268,4 @@ exports[`track has no unexpected changes when gene has constraint 1`] = `
</div>
`;

exports[`track has no unexpected changes when no constraint for gene 1`] = `null`;
exports[`MitochondrialRegionConstraintTrack for an RNA gene track has no unexpected changes when no constraint for gene 1`] = `null`;

0 comments on commit 1624dad

Please sign in to comment.