taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
91 lines (90 loc) • 2.65 kB
JavaScript
import { I as h } from "./main-D1zX1xg0.js";
import { B as m } from "./index-CpJXUZUB.js";
import { u as g, a1 as v } from "./JBrowsePanel-BNE3gNW1.js";
import { r as y } from "./rxjs-L4bS73F7.js";
import { S as M } from "./simpleFeature-DimH8SQV.js";
import { p as x, f as T } from "./featureData-Bm8gwGZK.js";
import { p as F } from "./parseLineByLine-u4wRqQjK.js";
function b(l, a = () => {
}) {
const t = [], r = {};
return F.parseLineByLine(l, (e) => {
if (e.startsWith("#"))
t.push(e);
else {
if (e.startsWith(">"))
return !1;
{
const s = e.indexOf(" "), n = e.slice(0, s);
r[n] || (r[n] = ""), r[n] += `${e}
`;
}
}
return !0;
}, a), {
header: t.join(`
`),
featureMap: r
};
}
class O extends m.BaseFeatureDataAdapter {
constructor() {
super(...arguments), this.calculatedIntervalTreeMap = {};
}
async loadDataP(a) {
const { statusCallback: t = () => {
} } = a || {}, r = await g.fetchAndMaybeUnzip(v.openLocation(this.getConf("gffLocation"), this.pluginManager), a), { header: e, featureMap: s } = b(r, t), n = Object.fromEntries(Object.entries(s).map(([o, c]) => [
o,
(i) => {
if (!this.calculatedIntervalTreeMap[o]) {
i == null || i("Parsing GFF data");
const u = new h();
for (const f of x(c).flat().map((p, d) => new M({
data: T(p),
id: `${this.id}-${o}-${d}`
})))
u.insert([f.get("start"), f.get("end")], f);
this.calculatedIntervalTreeMap[o] = u;
}
return this.calculatedIntervalTreeMap[o];
}
]));
return {
header: e,
intervalTreeMap: n
};
}
async loadData(a) {
return this.gffFeatures || (this.gffFeatures = this.loadDataP(a).catch((t) => {
throw this.gffFeatures = void 0, t;
})), this.gffFeatures;
}
async getRefNames(a = {}) {
const { intervalTreeMap: t } = await this.loadData(a);
return Object.keys(t);
}
async getHeader(a = {}) {
const { header: t } = await this.loadData(a);
return t;
}
getFeatures(a, t = {}) {
return y.ObservableCreate(async (r) => {
var e;
try {
const { start: s, end: n, refName: o } = a, { intervalTreeMap: c } = await this.loadData(t);
for (const i of ((e = c[o]) === null || e === void 0 ? void 0 : e.call(c, t.statusCallback).search([
s,
n
])) || [])
r.next(i);
r.complete();
} catch (s) {
r.error(s);
}
}, t.stopToken);
}
}
export {
O as default
};
//# sourceMappingURL=Gff3Adapter-Cm8K4l2t.js.map