taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
72 lines (71 loc) • 2.83 kB
JavaScript
import { T as S } from "./tabixIndexedFile-B-0sKywF.js";
import "./unzip-ASAuJ12U.js";
import { B as $ } from "./index-BnQfM3Nw.js";
import { a4 as p, u as y } from "./JBrowsePanel-uJIA-L6s.js";
import { r as F } from "./rxjs-BnZkaVAs.js";
class z extends $.BaseFeatureDataAdapter {
async configurePre() {
const e = this.pluginManager, n = this.getConf("bedGraphGzLocation"), s = this.getConf(["index", "location"]), o = this.getConf(["index", "indexType"]), t = p.openLocation(n, e), a = o === "CSI", i = new S({
filehandle: t,
csiFilehandle: a ? p.openLocation(s, e) : void 0,
tbiFilehandle: a ? void 0 : p.openLocation(s, e),
chunkCacheSize: 50 * 2 ** 20
}), u = this.getConf("columnNames"), c = await i.getHeader();
return {
columnNames: u,
bedGraph: i,
header: c
};
}
async configure() {
return this.configured || (this.configured = this.configurePre().catch((e) => {
throw this.configured = void 0, e;
})), this.configured;
}
async getNames() {
const { bedGraph: e, columnNames: n } = await this.configure();
if (n.length)
return n;
const t = (await e.getHeader()).split(/\n|\r\n|\r/).filter((a) => !!a).at(-1);
return t != null && t.includes(" ") ? t.slice(1).split(" ").map((a) => a.trim()) : void 0;
}
async getRefNames(e = {}) {
const { bedGraph: n } = await this.configure();
return n.getReferenceSequenceNames(e);
}
async getHeader() {
const { bedGraph: e } = await this.configure();
return e.getHeader();
}
getFeatures(e, n = {}) {
return F.ObservableCreate(async (s) => {
var o;
const { bedGraph: t } = await this.configure(), a = await t.getMetadata(), { columnNumbers: i } = a, u = i.ref - 1, c = i.start - 1, d = i.end - 1, f = c === d, w = ((o = await this.getNames()) === null || o === void 0 ? void 0 : o.slice(f ? 2 : 3)) || [];
await t.getLines(e.refName, e.start + (f ? -1 : 0), e.end, {
lineCallback: (m, x) => {
const l = m.split(" "), G = l[u], h = +l[c], g = +(f ? h + 1 : l[d]), b = l.slice(d + 1);
if (Number.isNaN(h) || Number.isNaN(g))
throw new Error(`start/end NaN on line "${m}", with colStart:${c} and colEnd:${d}. run "tabix -p bed" to ensure bed preset`);
for (let r = 0; r < b.length; r++) {
const C = `${this.id}-${x}-${r}`, N = Math.abs(+b[r]), E = w[r] || `col${r}`;
N && s.next(new y.SimpleFeature({
id: C,
data: {
refName: G,
start: h,
end: g,
score: N,
source: E
}
}));
}
},
...n
}), s.complete();
});
}
}
export {
z as default
};
//# sourceMappingURL=BedGraphTabixAdapter-B6CVKBe0.js.map