UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

55 lines (54 loc) 3.22 kB
import { u as B, l as G, q as H } from "./JBrowsePanel-uJIA-L6s.js"; import { g as J, a as K, b as Q } from "./color-CalL0laX.js"; function a(n) { return Math.random() * 2 * n - n; } function O(n, e, _, c) { n.strokeStyle = c, n.beginPath(), n.moveTo(e, 0), n.lineTo(e, _), n.stroke(); } function k(n, e, _, c) { const { chainData: h, colorBy: b, drawInter: L, drawLongRange: R, lineWidthSetting: V, jitterVal: i } = n; if (!h) return; const g = B.getContainingView(n), { assemblyManager: W } = B.getSession(n), { chains: $, stats: I } = h, P = G(h), S = W.get(g.assemblyNames[0]), f = (b == null ? void 0 : b.type) || "insertSizeAndOrientation"; if (!S) return; e.lineWidth = V; function z(o, t, s, r) { var l, u, N; const w = o.strand, A = t.strand, q = w === -1, j = A === -1, D = q ? o.start : o.end, E = P ? j ? t.start : t.end : j ? t.end : t.start, F = s.getCanonicalRefName(o.refName) || o.refName, X = s.getCanonicalRefName(t.refName) || t.refName, p = (l = g.bpToPx({ refName: F, coord: D })) === null || l === void 0 ? void 0 : l.offsetPx, C = (u = g.bpToPx({ refName: X, coord: E })) === null || u === void 0 ? void 0 : u.offsetPx; if (p !== void 0 && C !== void 0) { const T = (C - p) / 2, m = Math.abs(T), d = p - g.offsetPx, Y = C - g.offsetPx, M = m > 1e4; r && M ? (e.moveTo(d, 0), e.beginPath()) : (e.beginPath(), e.moveTo(d, 0)), r && M ? e.strokeStyle = "red" : P ? f === "insertSizeAndOrientation" ? e.strokeStyle = J(o, t, I)[0] : f === "orientation" ? e.strokeStyle = K(o)[0] : f === "insertSize" ? e.strokeStyle = ((N = Q(o, t, I)) === null || N === void 0 ? void 0 : N[0]) || "grey" : f === "gradient" && (e.strokeStyle = `hsl(${Math.log10(m) * 10},50%,50%)`) : f === "orientation" || f === "insertSizeAndOrientation" ? w === -1 && A === 1 ? e.strokeStyle = "navy" : w === 1 && A === -1 ? e.strokeStyle = "green" : e.strokeStyle = "grey" : f === "gradient" && (e.strokeStyle = `hsl(${Math.log10(m) * 10},50%,50%)`); const v = d + T * 2, y = Math.min(c + a(i), m); r ? m > 1e5 ? (O(e, d + a(i), c, "red"), O(e, Y + a(i), c, "red")) : M ? (e.arc(d + T + a(i), 0, m, 0, Math.PI), e.stroke()) : (e.bezierCurveTo(d + a(i), y, v, y, v + a(i), 0), e.stroke()) : (e.bezierCurveTo(d + a(i), y, v, y, v + a(i), 0), e.stroke()); } else p && L && O(e, p - g.offsetPx, c, "purple"); } for (const o of $) if (o.length === 1 && R) { const t = o[0]; if (P && !(t.flags & 8)) { const s = { refName: t.next_ref || "", start: t.next_pos || 0, end: t.next_pos || 0, strand: t.strand }; z(t, s, S, !0); } else { const s = [t, ...H(t.SA, t.id, t.strand, t.name)].sort((r, l) => r.clipPos - l.clipPos); for (let r = 0; r < s.length - 1; r++) { const l = s[r], u = s[r + 1]; z(l, u, S, !0); } } } else { const t = P ? o.filter((s) => !(s.flags & 2048) && !(s.flags & 8)) : o.sort((s, r) => s.clipPos - r.clipPos).filter((s) => !(s.flags & 256)); for (let s = 0; s < t.length - 1; s++) z(t[s], t[s + 1], S, !1); } } export { k as drawFeats }; //# sourceMappingURL=drawFeats-GsFvxwlm.js.map