taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
87 lines (86 loc) • 2.75 kB
JavaScript
import { I as b } from "./main-D1zX1xg0.js";
import { B as v } from "./index-BnQfM3Nw.js";
import { u as h, a4 as y } from "./JBrowsePanel-uJIA-L6s.js";
import { r as x } from "./rxjs-BnZkaVAs.js";
import { S as T } from "./simpleFeature-Bntv68qr.js";
import { p as D, f as M } from "./featureData-Bm8gwGZK.js";
class E extends v.BaseFeatureDataAdapter {
constructor() {
super(...arguments), this.calculatedIntervalTreeMap = {};
}
async loadDataP(a) {
const { statusCallback: t = () => {
} } = a || {}, r = await h.fetchAndMaybeUnzip(y.openLocation(this.getConf("gffLocation"), this.pluginManager), a), c = [], n = {}, d = new TextDecoder("utf8");
let i = 0, l = 0;
for (; i < r.length; ) {
const s = r.indexOf(10, i), p = s === -1 ? r.subarray(i) : r.subarray(i, s), e = d.decode(p).trim();
if (e)
if (e.startsWith("#"))
c.push(e);
else {
if (e.startsWith(">"))
break;
{
const f = e.indexOf(" "), o = e.slice(0, f);
n[o] || (n[o] = ""), n[o] += `${e}
`;
}
}
l++ % 1e4 === 0 && t(`Loading ${h.getProgressDisplayStr(i, r.length)}`), i = s + 1;
}
const u = Object.fromEntries(Object.entries(n).map(([s, p]) => [
s,
(e) => {
if (!this.calculatedIntervalTreeMap[s]) {
e == null || e("Parsing GFF data");
const f = new b();
for (const o of D(p).flat().map((g, m) => new T({
data: M(g),
id: `${this.id}-${s}-${m}`
})))
f.insert([o.get("start"), o.get("end")], o);
this.calculatedIntervalTreeMap[s] = f;
}
return this.calculatedIntervalTreeMap[s];
}
]));
return {
header: c.join(`
`),
intervalTreeMap: u
};
}
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 x.ObservableCreate(async (r) => {
var c;
try {
const { start: n, end: d, refName: i } = a, { intervalTreeMap: l } = await this.loadData(t);
for (const u of ((c = l[i]) === null || c === void 0 ? void 0 : c.call(l, t.statusCallback).search([
n,
d
])) || [])
r.next(u);
r.complete();
} catch (n) {
r.error(n);
}
}, t.stopToken);
}
}
export {
E as default
};
//# sourceMappingURL=Gff3Adapter-BzUNSMTR.js.map