UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

86 lines (85 loc) 4.17 kB
import { jsx as u, jsxs as F, Fragment as R } from "react/jsx-runtime"; import { useState as T, useRef as V, Suspense as W, lazy as j } from "react"; import { aU as I, u as v, o as S, s as L } from "./JBrowsePanel-uJIA-L6s.js"; function _(t, e) { var o, i, r, s; const l = e ? I(e) : void 0, d = t.get("start"); let a = t.get("end"); const f = t.get("strand"), c = t.get("mate"), m = t.get("refName"); let p, k = 0, h = 0, b = 0, N = 0; if (["<TRA", "<DEL", "<INV", "<INS", "<DUP", "<CNV"].some((n) => e == null ? void 0 : e.startsWith(n))) { const n = t.get("INFO"), g = (i = (o = n == null ? void 0 : n.END) === null || o === void 0 ? void 0 : o[0]) !== null && i !== void 0 ? i : a; p = (s = (r = n == null ? void 0 : n.CHR2) === null || r === void 0 ? void 0 : r[0]) !== null && s !== void 0 ? s : m, k = g, h = g - 1, a = d + 1; } else if (l != null && l.MatePosition) { const n = l.MatePosition.split(":"); N = l.MateDirection === "left" ? 1 : -1, b = l.Join === "left" ? -1 : 1, k = +n[1], h = +n[1] - 1, p = n[0]; } return { k1: { refName: m, start: d, end: a, strand: f, mateDirection: N }, k2: c ?? { refName: p || "unknown", end: k, start: h, mateDirection: b } }; } function B(t, e) { var o; const { k1: i, k2: r } = _(t, e); return [ t.get("name"), t.get("id"), v.assembleLocString(i), v.assembleLocString(r), (o = t.get("INFO")) === null || o === void 0 ? void 0 : o.SVTYPE, e ].filter((s) => !!s).join("<br/>"); } const U = j(() => import("./ArcTooltip-P60KiG0c.js")), A = S(function({ model: t, feature: e, alt: o, assembly: i, view: r }) { var s, l; const [d, a] = T(!1), { height: f } = t, { k1: c, k2: m } = _(e, o), p = V(null), k = L.getConf(t, "color", { feature: e, alt: o }), h = i.getCanonicalRefName(c.refName) || c.refName, b = i.getCanonicalRefName(m.refName) || m.refName, N = c.start, C = m.start, n = (s = r.bpToPx({ refName: h, coord: N })) === null || s === void 0 ? void 0 : s.offsetPx, g = (l = r.bpToPx({ refName: b, coord: C })) === null || l === void 0 ? void 0 : l.offsetPx; if (n !== void 0 && g !== void 0) { const $ = (g - n) / 2, D = Math.abs($), O = Math.min(f, D), w = n - r.offsetPx, E = g - r.offsetPx, x = w, P = E, M = d ? "black" : k, y = 3; return D > 1 ? F(R, { children: [u("path", { d: `M ${x} 0 C ${x} ${O}, ${P} ${O}, ${P} 0`, ref: p, ...v.getStrokeProps(M), strokeWidth: y, onMouseOut: () => { a(!1); }, onMouseOver: () => { a(!0); }, onClick: () => { t.selectFeature(e); }, fill: "none", pointerEvents: "stroke" }), c.mateDirection ? u("line", { ...v.getStrokeProps(M), strokeWidth: y, onMouseOut: () => { a(!1); }, onMouseOver: () => { a(!0); }, onClick: () => { t.selectFeature(e); }, x1: x, x2: x + c.mateDirection * 20, y1: 1.5, y2: 1.5 }) : null, m.mateDirection ? u("line", { ...v.getStrokeProps(M), strokeWidth: y, onMouseOut: () => { a(!1); }, onMouseOver: () => { a(!0); }, onClick: () => { t.selectFeature(e); }, x1: P, x2: P + m.mateDirection * 20, y1: 1.5, y2: 1.5 }) : null, d ? u(W, { fallback: null, children: u(U, { contents: B(e, o) }) }) : null] }) : null; } return null; }), Y = S(function({ model: t, exportSVG: e, children: o }) { const { height: i } = t, r = v.getContainingView(t), s = Math.round(r.dynamicBlocks.totalWidthPx); return e ? o : u("svg", { width: s, height: i, children: o }); }), J = S(function({ model: t, exportSVG: e }) { const o = v.getContainingView(t), i = v.getSession(t), { assemblyManager: r } = i, { features: s } = t, l = r.get(o.assemblyNames[0]); return l ? u(Y, { model: t, exportSVG: e, children: s == null ? void 0 : s.map((d) => { var a; const f = d.get("ALT"); return (a = f == null ? void 0 : f.map((c) => u(A, { session: i, feature: d, alt: c, view: o, model: t, assembly: l }, `${d.id()}-${c}`))) !== null && a !== void 0 ? a : u(A, { session: i, feature: d, view: o, model: t, assembly: l }, d.id()); }) }) : null; }); export { J as A }; //# sourceMappingURL=Arcs-D2VlVqb0.js.map