UNPKG

taxonium-component

Version:

React component for exploring large phylogenetic trees in the browser

71 lines (70 loc) 2.57 kB
import { T as d } from "./tabixIndexedFile-B-0sKywF.js"; import "./unzip-ASAuJ12U.js"; import { V as g, a as h } from "./index-DYYPI5hS.js"; import { B as m } from "./index-BnQfM3Nw.js"; import { a4 as p, u } from "./JBrowsePanel-uJIA-L6s.js"; import { r as x } from "./rxjs-BnZkaVAs.js"; class F extends m.BaseFeatureDataAdapter { async configurePre(e) { const t = this.getConf("indexType"), a = this.getConf("vcfGzLocationMap")[e], n = this.getConf("indexLocationMap")[e] || { uri: `${a.uri}.${t.toLowerCase()}` }, o = p.openLocation(a, this.pluginManager), s = t === "CSI", i = new d({ filehandle: o, csiFilehandle: s ? p.openLocation(n, this.pluginManager) : void 0, tbiFilehandle: s ? void 0 : p.openLocation(n, this.pluginManager), chunkCacheSize: 50 * 2 ** 20 }); return { vcf: i, parser: new g({ header: await i.getHeader() }) }; } async configure(e, t) { const { statusCallback: a = () => { } } = t || {}; return u.updateStatus("Downloading index", a, () => this.configurePre(e)); } async getRefNames() { return Object.keys(this.getConf("vcfGzLocationMap")); } getFeatures(e, t = {}) { return x.ObservableCreate(async (a) => { const { refName: n, start: o, end: s } = e, { statusCallback: i = () => { } } = t, { vcf: r, parser: c } = await this.configure(e.refName, t); await u.updateStatus("Downloading variants", i, () => r.getLines(n, o, s, { lineCallback: (l, f) => { a.next(new h({ variant: c.parseLine(l), parser: c, id: `${this.id}-vcf-${f}` })); }, ...t })), a.complete(); }, t.stopToken); } async getSources() { const e = this.getConf("samplesTsvLocation"), t = Object.keys(this.getConf("vcfGzLocationMap"))[0]; if (e.uri === "" || e.uri === "/path/to/samples.tsv") { const { parser: a } = await this.configure(t); return a.samples.map((n) => ({ name: n })); } else { const n = (await u.fetchAndMaybeUnzipText(p.openLocation(e, this.pluginManager))).split(/\n|\r\n|\r/), o = n[0].split(" "), { parser: s } = await this.configure(t), i = new Set(s.samples); return n.slice(1).map((r) => { const c = r.split(" "); return { name: c[0], ...Object.fromEntries(c.slice(1).map((l, f) => [o[f + 1], l])) }; }).filter((r) => i.has(r.name)); } } } export { F as default }; //# sourceMappingURL=SplitVcfTabixAdapter-DGOmPVtX.js.map