@jbrowse/plugin-wiggle
Version:
JBrowse 2 wiggle adapters, tracks, etc.
32 lines (31 loc) • 2.24 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from 'react';
import { toLocale } from '@jbrowse/core/util';
import { observer } from 'mobx-react';
import Tooltip from "../../Tooltip.js";
import { toP } from "../../util.js";
const TooltipContents = forwardRef(function TooltipContents2({ model, feature }, ref) {
const start = feature.get('start');
const end = feature.get('end');
const refName = feature.get('refName');
const coord = start === end ? toLocale(start) : `${toLocale(start)}..${toLocale(end)}`;
const sources = feature.get('sources');
const source = feature.get('source');
const summary = feature.get('summary');
const obj = Object.fromEntries(model.sources.map(ent => [ent.name, ent]));
const obj2 = obj[source];
return (_jsxs("div", { ref: ref, children: [[refName, coord].filter(f => !!f).join(':'), _jsx("br", {}), sources ? (_jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { children: "color" }), _jsx("th", { children: "source" }), _jsx("th", { children: "score" })] }) }), _jsx("tbody", { children: Object.entries(sources).map(([source, data]) => {
const sourceInfo = obj[source];
return (_jsxs("tr", { children: [_jsx("td", { children: sourceInfo && (_jsx("div", { style: {
width: 16,
height: 16,
background: sourceInfo.color,
} })) }), _jsx("td", { children: sourceInfo?.name || source }), _jsx("td", { children: toP(data.score) })] }, source));
}) })] })) : (_jsxs("span", { children: [obj2?.name || source, ' ', summary && feature.get('minScore') != null
? `min:${toP(feature.get('minScore'))} avg:${toP(feature.get('score'))} max:${toP(feature.get('maxScore'))}`
: toP(feature.get('score'))] }))] }));
});
const WiggleTooltip = observer(function WiggleTooltip(props) {
return _jsx(Tooltip, { TooltipContents: TooltipContents, ...props });
});
export default WiggleTooltip;