taxonium-component
Version:
React component for exploring large phylogenetic trees in the browser
59 lines (58 loc) • 2.21 kB
JavaScript
import { B as E } from "./index-CpJXUZUB.js";
import { $ as v, a0 as F, u as m, O as N } from "./JBrowsePanel-BNE3gNW1.js";
import { r as b } from "./rxjs-L4bS73F7.js";
class z extends E.BaseFeatureDataAdapter {
constructor() {
super(...arguments), this.gcMode = "content";
}
async configure() {
var t;
const s = await ((t = this.getSubAdapter) === null || t === void 0 ? void 0 : t.call(this, this.getConf("sequenceAdapter")));
if (!s)
throw new Error("Error getting subadapter");
return s.dataAdapter;
}
async getRefNames(t) {
return (await this.configure()).getRefNames(t);
}
getFeatures(t, s) {
const { statusCallback: C = () => {
}, stopToken: x } = s || {};
return b.ObservableCreate(async (c) => {
var l;
const S = await this.configure(), a = this.getConf("windowSize"), g = this.getConf("windowDelta"), o = a === 1 ? 1 : Math.ceil(a / 2), A = a === 1, d = Math.max(0, Math.floor((t.start - o) / a) * a), p = Math.ceil((t.end + o) / a) * a;
if (p < 0 || d > p) {
c.complete();
return;
}
const f = ((l = (await v(S.getFeatures({
...t,
start: d,
end: p
}, s).pipe(F())))[0]) === null || l === void 0 ? void 0 : l.get("seq")) || "";
let w = performance.now();
await m.updateStatus("Calculating GC", C, () => {
for (let e = o; e < f.length - o; e += g) {
performance.now() - w > 400 && (N.checkStopToken(x), w = performance.now());
const M = A ? f[e] : f.slice(e - o, e + o);
let r = 0, i = 0, h = 0;
for (const n of M)
n === "c" || n === "C" ? r++ : (n === "g" || n === "G") && i++, n !== "N" && h++;
const u = d, k = this.gcMode === "content" ? (i + r) / (h || 1) : this.gcMode === "skew" ? (i - r) / (i + r || 1) : 0;
c.next(new m.SimpleFeature({
uniqueId: `${this.id}_${u + e}`,
refName: t.refName,
start: u + e,
end: u + e + g,
score: k
}));
}
}), c.complete();
});
}
}
z.capabilities = ["hasLocalStats"];
export {
z as default
};
//# sourceMappingURL=GCContentAdapter-DMqMsuEN.js.map