taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
86 lines (85 loc) • 3 kB
JavaScript
import { R as j, u as p, at as N, au as W } from "./JBrowsePanel-uJIA-L6s.js";
import { d as z, f as u, g as K, a as Q } from "./drawPhased-DD0eFoRt.js";
async function Z(d, P) {
const { scrollTop: D, minorAlleleFrequencyFilter: I, sources: x, rowHeight: g, features: q, regions: v, bpPerPx: H, renderingMode: O, stopToken: h, lengthCutoffFilter: B, referenceDrawingMode: C } = P, G = v[0], { statusCallback: S = () => {
} } = P;
j.checkStopToken(h);
const T = await p.updateStatus("Calculating stats", S, () => N({
stopToken: h,
features: q.values(),
minorAlleleFrequencyFilter: I,
lengthCutoffFilter: B
}));
j.checkStopToken(h);
const k = new W();
return await p.updateStatus("Drawing variants", S, () => {
p.forEachWithStopTokenCheck(T, h, ({ mostFrequentAlt: e, feature: n }) => {
const [w, J] = p.featureSpanPx(n, G, H), L = n.get("end") - n.get("start"), c = Math.max(Math.round(J - w), 2), F = n.get("genotypes");
let s = -D;
const b = x.length;
if (O === "phased")
for (let a = 0; a < b; a++) {
const { name: l, HP: f } = x[a], t = F[l], o = Math.floor(w), i = Math.max(g, 1);
if (t)
if (t.includes("|")) {
const m = t.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: t,
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], t = F[f], o = Math.floor(w), i = Math.max(g, 1);
if (t) {
let r = a[t];
if (r === void 0) {
let m = 0, A = 0, E = 0, R = 0;
const X = t.split(/[/|]/), Y = X.length;
for (let y = 0; y < Y; y++) {
const M = X[y];
M === e ? m++ : M === "0" ? R++ : M === "." ? A++ : E++;
}
r = K(R, m, E, A, Y, C === "draw"), a[t] = 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: t,
name: f,
featureId: n.id()
}));
}
s += g;
}
}
});
}), {
rbush: k.toJSON(),
featureGenotypeMap: Object.fromEntries(T.map(({ feature: e }) => [
e.id(),
{
alt: e.get("ALT"),
ref: e.get("REF"),
name: e.get("name"),
description: e.get("description"),
length: e.get("end") - e.get("start")
}
]))
};
}
export {
Z as makeImageData
};
//# sourceMappingURL=makeImageData-va14dQAI.js.map