UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

86 lines (85 loc) 3 kB
import { O as D, u as p, ak as N, al as W } from "./JBrowsePanel-BNE3gNW1.js"; import { d as z, f as u, g as K, a as Q } from "./drawPhased-CAb_z73L.js"; async function Z(d, P) { const { scrollTop: I, minorAlleleFrequencyFilter: O, sources: x, rowHeight: g, features: R, regions: q, bpPerPx: v, renderingMode: H, stopToken: h, lengthCutoffFilter: B, referenceDrawingMode: C } = P, G = q[0], { statusCallback: S = () => { } } = P; D.checkStopToken(h); const T = await p.updateStatus("Calculating stats", S, () => N({ stopToken: h, features: R.values(), minorAlleleFrequencyFilter: O, lengthCutoffFilter: B })); D.checkStopToken(h); const k = new W(); return await p.updateStatus("Drawing variants", S, () => { p.forEachWithStopTokenCheck(T, h, ({ mostFrequentAlt: t, feature: n }) => { const [w, J] = p.featureSpanPx(n, G, v), L = n.get("end") - n.get("start"), c = Math.max(Math.round(J - w), 2), F = n.get("genotypes"); let s = -I; const b = x.length; if (H === "phased") for (let a = 0; a < b; a++) { const { name: l, HP: f } = x[a], e = F[l], o = Math.floor(w), i = Math.max(g, 1); if (e) if (e.includes("|")) { const m = e.split("|"); z(m, d, o, s, c, i, f, void 0, C === "draw") && k.insert({ minX: o, maxX: o + c, minY: s, maxY: s + i, genotype: e, name: l, featureId: n.id() }); } else d.fillStyle = "black", d.fillRect(o - u, s - u, c + u, i + u); s += g; } else { const a = {}; for (let l = 0; l < b; l++) { const { name: f } = x[l], e = F[f], o = Math.floor(w), i = Math.max(g, 1); if (e) { let r = a[e]; if (r === void 0) { let m = 0, A = 0, E = 0, X = 0; const Y = e.split(/[/|]/), j = Y.length; for (let y = 0; y < j; y++) { const M = Y[y]; M === t ? m++ : M === "0" ? X++ : M === "." ? A++ : E++; } r = K(X, m, E, A, j, C === "draw"), a[e] = r; } r && (Q(r, d, o, s, c, i, n.get("type"), n.get("strand"), L > 5 ? 0.75 : 1), k.insert({ minX: o, maxX: o + c, minY: s, maxY: s + i, genotype: e, name: f, featureId: n.id() })); } s += g; } } }); }), { rbush: k.toJSON(), featureGenotypeMap: Object.fromEntries(T.map(({ feature: t }) => [ t.id(), { alt: t.get("ALT"), ref: t.get("REF"), name: t.get("name"), description: t.get("description"), length: t.get("end") - t.get("start") } ])) }; } export { Z as makeImageData }; //# sourceMappingURL=makeImageData-D0Rxqm57.js.map