taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
99 lines (98 loc) • 3.57 kB
JavaScript
import { T as I } from "./tabixIndexedFile-B-0sKywF.js";
import "./unzip-ASAuJ12U.js";
import { B as S } from "./index-BnQfM3Nw.js";
import { aW as F, a4 as g, u as h } from "./JBrowsePanel-uJIA-L6s.js";
import { r as T } from "./rxjs-BnZkaVAs.js";
import { S as C } from "./simpleFeature-Bntv68qr.js";
import { p as L, f as N } from "./featureData-Bm8gwGZK.js";
var E = F();
class G extends S.BaseFeatureDataAdapter {
async configurePre(e) {
const t = this.getConf("gffGzLocation"), s = this.getConf(["index", "indexType"]), n = this.getConf(["index", "location"]), f = this.getConf("dontRedispatch"), c = new I({
filehandle: g.openLocation(t, this.pluginManager),
csiFilehandle: s === "CSI" ? g.openLocation(n, this.pluginManager) : void 0,
tbiFilehandle: s !== "CSI" ? g.openLocation(n, this.pluginManager) : void 0,
chunkCacheSize: 50 * 2 ** 20,
renameRefSeqs: (d) => d
});
return {
gff: c,
dontRedispatch: f,
header: await c.getHeader()
};
}
async configurePre2() {
return this.configured || (this.configured = this.configurePre().catch((e) => {
throw this.configured = void 0, e;
})), this.configured;
}
async configure(e) {
const { statusCallback: t = () => {
} } = e || {};
return h.updateStatus("Downloading index", t, () => this.configurePre2());
}
async getRefNames(e = {}) {
const { gff: t } = await this.configure(e);
return t.getReferenceSequenceNames(e);
}
async getHeader(e = {}) {
const { gff: t } = await this.configure(e);
return t.getHeader();
}
getFeatures(e, t = {}) {
return T.ObservableCreate(async (s) => {
const { gff: n } = await this.configure(t), f = await n.getMetadata();
await this.getFeaturesHelper(e, t, f, s, !0);
}, t.stopToken);
}
async getFeaturesHelper(e, t, s, n, f, c = e) {
var d, u;
const { statusCallback: p = () => {
} } = t;
try {
const o = [], { dontRedispatch: m, gff: x } = await this.configure(t);
if (await h.updateStatus("Downloading features", p, () => x.getLines(e.refName, e.start, e.end, (a, i) => {
o.push(this.parseLine(s.columnNumbers, a, i));
})), f && o.length) {
let a = Number.POSITIVE_INFINITY, i = Number.NEGATIVE_INFINITY;
for (const r of o) {
const H = r.fields[2];
if (!m.includes(H)) {
const l = r.start - 1;
l < a && (a = l), r.end > i && (i = r.end);
}
}
if (i > e.end || a < e.start) {
await this.getFeaturesHelper({ ...e, start: a, end: i }, t, s, n, !1, e);
return;
}
}
const w = o.map((a) => (a.fields[8] && a.fields[8] !== "." ? a.fields[8].includes("_lineHash") || (a.fields[8] += `;_lineHash=${a.lineHash}`) : a.fields[8] = `_lineHash=${a.lineHash}`, a.fields.join(" "))).join(`
`);
for (const a of L(w))
for (const i of a) {
const r = new C({
data: N(i),
id: `${this.id}-offset-${(u = (d = i.attributes) === null || d === void 0 ? void 0 : d._lineHash) === null || u === void 0 ? void 0 : u[0]}`
});
E.doesIntersect2(r.get("start"), r.get("end"), c.start, c.end) && n.next(r);
}
n.complete();
} catch (o) {
n.error(o);
}
}
parseLine(e, t, s) {
const n = t.split(" ");
return {
start: +n[e.start - 1],
end: +n[e.end - 1],
lineHash: s,
fields: n
};
}
}
export {
G as default
};
//# sourceMappingURL=Gff3TabixAdapter-CCxtm_vu.js.map