@genome-spy/app 0.79.1 → 0.80.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,128 +0,0 @@
1
- import { t as e } from "./esm-Cx-EbkOj.js";
2
- import { n as t } from "./esm-C3k-CPce.js";
3
- //#region ../core/node_modules/@gmod/indexedfasta/esm/fetchableSmallFasta.js
4
- var n = new TextDecoder("utf8");
5
- function r(e) {
6
- return e.split(">").filter((e) => /\S/.test(e)).map((e) => {
7
- let [t, ...n] = e.split("\n"), [r, ...i] = t.split(" "), a = n.join("").replace(/\s/g, "");
8
- return {
9
- id: r,
10
- description: i.join(" "),
11
- sequence: a
12
- };
13
- });
14
- }
15
- var i = class {
16
- data;
17
- indexed;
18
- constructor({ fasta: e, path: i }) {
19
- let a;
20
- if (e) a = e;
21
- else if (i) a = new t(i);
22
- else throw Error("Need to pass fasta or path");
23
- this.data = a.readFile().then((e) => r(n.decode(e)));
24
- }
25
- getIndexed() {
26
- return this.indexed ??= this.data.then((e) => new Map(e.map((e) => [e.id, e]))), this.indexed;
27
- }
28
- async fetch(e, t, n) {
29
- let r = (await this.getIndexed()).get(e);
30
- if (!r) throw Error(`no sequence with id ${e} exists`);
31
- return r.sequence.slice(t, n);
32
- }
33
- async getSequenceNames() {
34
- return (await this.data).map((e) => e.id);
35
- }
36
- }, a = new TextDecoder("utf8");
37
- function o(e, t, n, r) {
38
- return e + t * Math.floor(r / n) + r % n;
39
- }
40
- async function s(e, t = {}) {
41
- let n = a.decode(await e.readFile(t)), r = /* @__PURE__ */ new Map();
42
- for (let e of n.split("\n")) {
43
- let t = e.trim();
44
- if (!t) continue;
45
- let n = t.split(" ");
46
- if (n.length < 5) throw Error(`Malformed FAI line (expected 5 tab-separated columns, got ${String(n.length)}): ${t}`);
47
- let [i, a, o, s, c] = n;
48
- if (i.startsWith(">")) throw Error("found > in sequence name, might have supplied FASTA file for the FASTA index");
49
- let l = +a, u = +s;
50
- if (l > 0 && u === 0) throw Error(`Invalid FAI index for "${i}": LINEBASES is 0, FASTA likely missing trailing newline; regenerate the .fai index`);
51
- r.set(i, {
52
- length: l,
53
- offset: +o,
54
- lineLength: u,
55
- lineBytes: +c
56
- });
57
- }
58
- return r;
59
- }
60
- async function c(e, t, n = 0, r, i) {
61
- if (n < 0) throw TypeError("regionStart cannot be less than 0");
62
- let s = Math.min(r ?? t.length, t.length);
63
- if (n >= s) return "";
64
- let c = o(t.offset, t.lineBytes, t.lineLength, n), l = o(t.offset, t.lineBytes, t.lineLength, s) - c, u = a.decode(await e.read(l, c, i)).replace(/\s+/g, "");
65
- if (/[^\x20-\x7e]/.test(u.slice(0, 1e3))) throw Error("Non-ASCII bytes in sequence; file may be gzip — use BgzipIndexedFasta or decompress");
66
- return u;
67
- }
68
- var l = class {
69
- fasta;
70
- fai;
71
- indexes;
72
- constructor({ fasta: e, fai: n, path: r, faiPath: i }) {
73
- if (e) this.fasta = e;
74
- else if (r) this.fasta = new t(r);
75
- else throw Error("Need to pass filehandle for fasta or path to localfile");
76
- if (n) this.fai = n;
77
- else if (i) this.fai = new t(i);
78
- else if (r) this.fai = new t(`${r}.fai`);
79
- else throw Error("Need to pass filehandle for fai or path to localfile");
80
- }
81
- async getIndexes(e) {
82
- return this.indexes ??= s(this.fai, e).catch((e) => {
83
- throw this.indexes = void 0, e;
84
- }), this.indexes;
85
- }
86
- async getSequenceNames(e) {
87
- return [...(await this.getIndexes(e)).keys()];
88
- }
89
- async getSequenceSizes(e) {
90
- let t = {};
91
- for (let [n, r] of await this.getIndexes(e)) t[n] = r.length;
92
- return t;
93
- }
94
- async getSequenceSize(e, t) {
95
- return (await this.getIndexes(t)).get(e)?.length;
96
- }
97
- async hasReferenceSequence(e, t) {
98
- return (await this.getIndexes(t)).has(e);
99
- }
100
- async getResiduesByName(e, t, n, r) {
101
- let i = (await this.getIndexes(r)).get(e);
102
- if (i !== void 0) return c(this.fasta, i, t, n, r);
103
- }
104
- async getSequence(e, t, n, r) {
105
- return this.getResiduesByName(e, t, n, r);
106
- }
107
- }, u = class extends l {
108
- constructor({ fasta: n, path: r, fai: i, faiPath: a, gzi: o, gziPath: s }) {
109
- let c;
110
- if (n && o) c = new e({
111
- filehandle: n,
112
- gziFilehandle: o
113
- });
114
- else if (r && s) c = new e({
115
- filehandle: new t(r),
116
- gziFilehandle: new t(s)
117
- });
118
- else throw Error("BgzipIndexedFasta requires either {fasta, gzi} or {path, gziPath}");
119
- super({
120
- fasta: c,
121
- fai: i,
122
- faiPath: a,
123
- path: r
124
- });
125
- }
126
- };
127
- //#endregion
128
- export { u as BgzipIndexedFasta, i as FetchableSmallFasta, l as IndexedFasta, r as parseSmallFasta };