-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow selection of a region detail in regulatory activity viewer (#1182)
- By clicking on and dragging across the region overview, it is possible to select a subregion that shows up in the region details panel below - The cursor over the svg changes its shape to suggest that a subregion can be selected - Features (including their fragments) that are outside the selected subregion are greyed out in the RegionOverview panel. The greyed-out features are not interactive, and do not respond to mouse hover or to clicks - RegionOverview shows gene extents (dashed lines to either side of a transcript if the transcript is shorter than the gene itself) - Allow display of multiple transcription start sites - Show a popup ('zmenu"), upon a click on a gene in region overview - Add inert areas outside the selection in region overview, so that if you click or mouse over a feature outside the selected area in the region overview, nothing happens
- Loading branch information
Showing
24 changed files
with
1,192 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
...egulatory-activity-viewer/components/activity-viewer-popup/AcrivityViewerPopup.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.regularRow span + span { | ||
margin-left: 1ch; | ||
} | ||
|
||
.strand { | ||
margin-right: 2.5ch; | ||
} | ||
|
||
.light { | ||
font-weight: var(--font-weight-light); | ||
} | ||
|
||
.strong { | ||
font-weight: var(--font-weight-bold); | ||
} |
75 changes: 75 additions & 0 deletions
75
...t/app/regulatory-activity-viewer/components/activity-viewer-popup/ActivityViewerPopup.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { useState, type ReactNode } from 'react'; | ||
import classNames from 'classnames'; | ||
|
||
import PointerBox, { | ||
Position | ||
} from 'src/shared/components/pointer-box/PointerBox'; | ||
|
||
import pointerBoxStyles from 'src/shared/components/pointer-box/PointerBox.module.css'; | ||
import toolboxStyles from 'src/shared/components/toolbox/Toolbox.module.css'; | ||
|
||
/** | ||
* This component is similar to the "Zmenu" component of the genome browser. | ||
* Since graphics in the regulatory activity viewer tend to be svgs, | ||
* the component adds a tiny rect element as an anchor for the popup. | ||
*/ | ||
|
||
type Props = { | ||
x: number; | ||
y: number; | ||
children: ReactNode; | ||
onClose: () => void; | ||
}; | ||
|
||
const ActivityViewerPopup = (props: Props) => { | ||
const { x, y, children, onClose } = props; | ||
const [anchorElement, setAnchorElement] = useState<SVGRectElement | null>( | ||
null | ||
); | ||
|
||
const pointerBoxClasses = classNames( | ||
toolboxStyles.toolbox, | ||
pointerBoxStyles.pointerBoxShadow | ||
); | ||
|
||
return ( | ||
<> | ||
<rect | ||
ref={setAnchorElement} | ||
x={x} | ||
y={y} | ||
width={0} | ||
height={0} | ||
fill="transparent" | ||
/> | ||
{anchorElement && ( | ||
<PointerBox | ||
position={Position.RIGHT_BOTTOM} | ||
anchor={anchorElement} | ||
onOutsideClick={onClose} | ||
className={pointerBoxClasses} | ||
> | ||
{children} | ||
</PointerBox> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ActivityViewerPopup; |
82 changes: 82 additions & 0 deletions
82
...tent/app/regulatory-activity-viewer/components/activity-viewer-popup/GenePopupContent.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/** | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
import { getStrandDisplayName } from 'src/shared/helpers/formatters/strandFormatter'; | ||
import { getFormattedLocation } from 'src/shared/helpers/formatters/regionFormatter'; | ||
|
||
import TextButton from 'src/shared/components/text-button/TextButton'; | ||
|
||
import { Strand } from 'src/shared/types/core-api/strand'; | ||
import type { GeneInRegionOverview } from 'src/content/app/regulatory-activity-viewer/types/regionOverview'; | ||
|
||
import styles from './AcrivityViewerPopup.module.css'; | ||
|
||
type GeneField = | ||
| 'stable_id' | ||
| 'symbol' | ||
| 'unversioned_stable_id' | ||
| 'biotype' | ||
| 'strand' | ||
| 'start' | ||
| 'end'; | ||
|
||
type Props = { | ||
gene: Pick<GeneInRegionOverview, GeneField> & { region_name: string }; | ||
onFocus: () => void; | ||
}; | ||
|
||
const GenePopupContent = (props: Props) => { | ||
const { gene } = props; | ||
|
||
const geneSymbolAndIdentifier = gene.symbol ? ( | ||
<> | ||
<span>{gene.symbol}</span> <span>{gene.stable_id}</span> | ||
</> | ||
) : ( | ||
<span>{gene.stable_id}</span> | ||
); | ||
|
||
return ( | ||
<div> | ||
<div className={styles.regularRow}> | ||
<span className={styles.light}>Gene </span> | ||
{geneSymbolAndIdentifier} | ||
</div> | ||
<div className={styles.regularRow}> | ||
<span className={styles.light}>Biotype </span> | ||
<span>{gene.biotype}</span> | ||
</div> | ||
<div className={styles.light}> | ||
<span className={styles.strand}> | ||
{/* TODO: Change Strand enum into a union type */} | ||
{getStrandDisplayName(gene.strand as Strand)}{' '} | ||
</span> | ||
<span> | ||
{getFormattedLocation({ | ||
chromosome: gene.region_name, | ||
start: gene.start, | ||
end: gene.end | ||
})} | ||
</span> | ||
</div> | ||
<div> | ||
<TextButton onClick={props.onFocus}>Make focus</TextButton> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GenePopupContent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.