taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
68 lines (67 loc) • 1.96 kB
JavaScript
import { a4 as p, s as u, u as f } from "./JBrowsePanel-uJIA-L6s.js";
import { B as d } from "./index-BnQfM3Nw.js";
import { r as l } from "./rxjs-BnZkaVAs.js";
function h(i) {
return new Map(i.split(">").filter((t) => /\S/.test(t)).map((t) => {
const [e, ...a] = t.split(`
`), [s, ...n] = e.split(" "), r = a.join("").replace(/\s/g, "");
return [
s,
{
description: n.join(" "),
sequence: r
}
];
}));
}
class w extends d.BaseSequenceAdapter {
async getRefNames(t) {
const { fasta: e } = await this.setup(t);
return [...e.keys()];
}
async getRegions(t) {
const { fasta: e } = await this.setup(t);
return [...e.entries()].map(([a, s]) => ({
refName: a,
start: 0,
end: s.sequence.length
}));
}
async setupPre(t) {
const e = this.getConf("fastaLocation"), a = h(await p.openLocation(e, this.pluginManager).readFile("utf8"));
return {
fasta: new Map([...a.entries()].map(([s, n]) => [
u.readConfObject(this.config, "rewriteRefNames", { refName: s }) || s,
n
]))
};
}
async getHeader() {
const t = this.getConf("metadataLocation");
return t.uri === "" || t.uri === "/path/to/fa.metadata.yaml" ? null : p.openLocation(t, this.pluginManager).readFile("utf8");
}
async setup(t) {
return this.setupP || (this.setupP = this.setupPre(t).catch((e) => {
throw this.setupP = void 0, e;
})), this.setupP;
}
getFeatures(t, e) {
const { refName: a, start: s, end: n } = t;
return l.ObservableCreate(async (r) => {
const { fasta: c } = await this.setup(e), o = c.get(a);
o && r.next(new f.SimpleFeature({
id: `${a}-${s}-${n}`,
data: {
refName: a,
start: s,
end: n,
seq: o.sequence.slice(s, n)
}
})), r.complete();
});
}
}
export {
w as default
};
//# sourceMappingURL=UnindexedFastaAdapter-Ep1DTjtt.js.map