UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

101 lines (100 loc) 4.1 kB
import { jsxs as y, jsx as l } from "react/jsx-runtime"; import { B as A } from "./BaseCard-B_4xCCRV.js"; import { u as m, bn as B, q as C, bo as x, T as v, a as E, bp as D } from "./JBrowsePanel-ClL6pWQW.js"; import { useState as w, useEffect as R, lazy as L } from "react"; import { L as h } from "./Link-CoWt_Y7_.js"; import { n as M } from "./AlignmentsFeatureDetail-BVDBx0nB.js"; async function V({ view: t, feature: n }) { var s; const { assemblyManager: i } = m.getSession(t), a = n.get("CIGAR"), o = n.get("strand"), f = ((s = n.get("tags")) === null || s === void 0 ? void 0 : s.SA) || "", u = n.get("name"), e = B(a, 1), g = await i.waitForAssembly(t.assemblyNames[0]); if (!g) throw new Error("assembly not found"); const p = C(f, n.id(), o, u, !0), r = n.toJSON(); r.clipPos = e, r.strand = 1, r.mate = { refName: u, start: e, end: e + x(a) }; const S = [r, ...p]; for (const [d, c] of S.entries()) c.refName = g.getCanonicalRefName(c.refName) || c.refName, c.syntenyId = d, c.mate.syntenyId = d, c.mate.uniqueId = `${c.uniqueId}_mate`; return S.sort((d, c) => d.clipPos - c.clipPos), S; } const q = L(() => import("./BreakendMultiLevelOptionDialog-B7SgVjat.js")), F = L(() => import("./BreakendSingleLevelOptionDialog-BXFzWPGw.js")); function I({ model: t, feature: n }) { const { view: s } = t, [i, a] = w(), [o, f] = w(); R(() => { (async () => { try { const e = await V({ view: s, feature: new m.SimpleFeature(n) }); a(e); } catch (e) { f(e), console.error(e); } })(); }, [n, s]); const u = []; if (i) for (let e = 0; e < i.length - 1; e++) u.push([i[e], i[e + 1]]); return u.length ? y("div", { children: [l(v, { children: "Launch split view" }), o ? l(E.ErrorMessage, { error: o }) : null, l("ul", { children: u.map((e, g) => { const [p, r] = e; return y("li", { children: [p.refName, ":", m.toLocale(p.strand === 1 ? p.end : p.start), " ->", " ", r.refName, ":", m.toLocale(r.strand === 1 ? r.start : r.end), " ", l(O, { model: t, f1: p, f2: r }), " ", l(P, { model: t, f1: p, f2: r })] }, `${JSON.stringify(e)}-${g}`); }) })] }) : null; } function O({ model: t, f1: n, f2: s }) { return l(h, { href: "#", onClick: (i) => { i.preventDefault(); const a = m.getSession(t); a.queueDialog((o) => [ q, { handleClose: o, session: a, feature: new m.SimpleFeature({ ...n, mate: s }), view: t.view, assemblyName: t.view.displayedRegions[0].assemblyName } ]); }, children: "(top/bottom)" }); } function P({ model: t, f1: n, f2: s }) { return l(h, { href: "#", onClick: (i) => { i.preventDefault(); const a = m.getSession(t); a.queueDialog((o) => [ F, { handleClose: o, session: a, feature: new m.SimpleFeature({ ...n, mate: s }), view: t.view, assemblyName: t.view.displayedRegions[0].assemblyName } ]); }, children: "(single row)" }); } function T({ tag: t, model: n }) { return y("div", { children: [l(v, { children: "List of supplementary alignment locations" }), l("ul", { children: t.split(";").filter((s) => !!s).map((s, i) => { const [a, o, f, u] = s.split(","), e = D(u), g = Math.floor(e / 5), p = +o, r = +o + e, S = p - g, d = r + g, c = `${a}:${Math.max(1, S)}-${d}`, N = p.toLocaleString("en-US"), b = r.toLocaleString("en-US"), $ = `${a}:${N}-${b} (${f}) [${e}bp]`; return l("li", { children: l(h, { href: "#", onClick: async (k) => { k.preventDefault(), M(c, n); }, children: $ }) }, `${c}-${i}`); }) })] }); } function H(t) { const { model: n, tag: s, feature: i } = t, a = m.getSession(n), { pluginManager: o } = m.getEnv(a); let f = !1; try { f = !!o.getViewType("BreakpointSplitView"); } catch { } return y(A, { ...t, title: "Supplementary alignments", children: [l(T, { model: n, tag: s }), f ? l(I, { model: n, feature: i }) : null] }); } export { H as default }; //# sourceMappingURL=SupplementaryAlignments-CebupL-v.js.map