taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
83 lines (82 loc) • 3.37 kB
JavaScript
import { T as w } from "./tabixIndexedFile-B-0sKywF.js";
import "./unzip-ASAuJ12U.js";
import { V as x, a as C } from "./index-DYYPI5hS.js";
import { B as S } from "./index-BnQfM3Nw.js";
import { a4 as u, u as f } from "./JBrowsePanel-uJIA-L6s.js";
import { r as v } from "./rxjs-BnZkaVAs.js";
class V extends S.BaseFeatureDataAdapter {
async configurePre(e) {
const t = this.getConf("vcfGzLocation"), n = this.getConf(["index", "location"]), c = this.getConf(["index", "indexType"]), r = u.openLocation(t, this.pluginManager), s = c === "CSI", i = new w({
filehandle: r,
csiFilehandle: s ? u.openLocation(n, this.pluginManager) : void 0,
tbiFilehandle: s ? void 0 : u.openLocation(n, this.pluginManager),
chunkCacheSize: 50 * 2 ** 20
});
return {
vcf: i,
parser: new x({
header: await i.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 f.updateStatus("Downloading index", t, () => this.configurePre2());
}
async getRefNames(e = {}) {
const { vcf: t } = await this.configure(e);
return t.getReferenceSequenceNames(e);
}
async getHeader(e) {
const { vcf: t } = await this.configure(e);
return t.getHeader();
}
async getMetadata(e) {
const { parser: t } = await this.configure(e);
return t.getMetadata();
}
getFeatures(e, t = {}) {
return v.ObservableCreate(async (n) => {
const { refName: c, start: r, end: s } = e, { statusCallback: i = () => {
} } = t, { vcf: p, parser: o } = await this.configure(t);
await f.updateStatus("Downloading variants", i, () => p.getLines(c, r, s, {
lineCallback: (l, a) => {
n.next(new C({
variant: o.parseLine(l),
parser: o,
id: `${this.id}-vcf-${a}`
}));
},
...t
})), n.complete();
}, t.stopToken);
}
async getSources() {
const e = this.getConf("samplesTsvLocation");
if (e.uri === "" || e.uri === "/path/to/samples.tsv") {
const { parser: t } = await this.configure();
return t.samples.map((n) => ({
name: n
}));
} else {
const n = (await f.fetchAndMaybeUnzipText(u.openLocation(e, this.pluginManager))).split(/\n|\r\n|\r/), c = n[0].split(" "), { parser: r } = await this.configure(), s = n.slice(1).filter((a) => !!a).map((a) => {
const [g, ...h] = a.split(" ");
return {
...Object.fromEntries(c.slice(1).map((d, m) => [d, h[m] || ""])),
name: g
};
}), i = new Set(r.samples), p = new Set(s.map((a) => a.name)), o = [...p].filter((a) => !i.has(a)), l = [...i].filter((a) => !p.has(a));
return o.length && console.warn(`There are ${o.length} samples in metadata file (${s.length} lines) not in VCF (${r.samples.length} samples):`, f.shorten2(o.join(","))), l.length && console.warn(`There are ${l.length} samples in VCF file (${r.samples.length} samples) not in metadata file (${s.length} lines):`, f.shorten2(l.map((a) => a).join(","))), s.filter((a) => i.has(a.name));
}
}
}
export {
V as default
};
//# sourceMappingURL=VcfTabixAdapter-BIHBArGP.js.map