UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

49 lines (48 loc) 1.77 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { getSession, notEmpty } from '@jbrowse/core/util'; import { colord } from '@jbrowse/core/util/colord'; import { observer } from 'mobx-react'; import { makeStyles } from 'tss-react/mui'; const useStyles = makeStyles()(theme => ({ highlight: { height: '100%', position: 'absolute', background: colord(theme.palette.highlight.main).alpha(0.35).toRgbString(), borderLeft: `1px solid ${theme.palette.highlight.main}`, borderRight: `1px solid ${theme.palette.highlight.main}`, }, })); const OverviewHighlight = observer(function OverviewHighlight({ model, overview, }) { const { classes } = useStyles(); const { highlight, cytobandOffset } = model; const session = getSession(model); const { assemblyManager } = session; return highlight .map(r => { var _a; const asm = assemblyManager.get(r.assemblyName); const refName = (_a = asm === null || asm === void 0 ? void 0 : asm.getCanonicalRefName(r.refName)) !== null && _a !== void 0 ? _a : r.refName; const s = overview.bpToPx({ ...r, refName, coord: r.start, }); const e = overview.bpToPx({ ...r, refName, coord: r.end, }); return s !== undefined && e !== undefined ? { width: Math.abs(e - s), left: s + cytobandOffset, } : undefined; }) .filter(notEmpty) .map(({ left, width }, idx) => (_jsx("div", { className: classes.highlight, style: { width: width, left: left, } }, `${left}_${width}_${idx}`))); }); export default OverviewHighlight;