@genome-spy/app 0.69.0 → 0.70.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,78 +1,78 @@
1
- function R(d, t, e) {
2
- const r = /* @__PURE__ */ Object.create(null), i = e.length, a = t.length, l = 9, s = 58;
1
+ function S(m, t, e) {
2
+ const r = /* @__PURE__ */ Object.create(null), o = e.length, s = t.length, c = 9, i = 58;
3
3
  let n = 0;
4
- if (d === "GT") {
5
- for (let o = 0; o < i; o++) {
6
- const p = n;
7
- for (; n < a && t.charCodeAt(n) !== l; )
4
+ if (m === "GT") {
5
+ for (let l = 0; l < o; l++) {
6
+ const d = n;
7
+ for (; n < s && t.charCodeAt(n) !== c; )
8
8
  n++;
9
- r[e[o]] = t.slice(p, n), n++;
9
+ r[e[l]] = t.slice(d, n), n++;
10
10
  }
11
11
  return r;
12
12
  }
13
- const c = d.indexOf("GT");
14
- if (c === -1)
13
+ const a = m.indexOf("GT");
14
+ if (a === -1)
15
15
  return r;
16
- if (c === 0) {
17
- for (let o = 0; o < i; o++) {
18
- const p = n;
19
- for (; n < a && t.charCodeAt(n) !== s && t.charCodeAt(n) !== l; )
16
+ if (a === 0) {
17
+ for (let l = 0; l < o; l++) {
18
+ const d = n;
19
+ for (; n < s && t.charCodeAt(n) !== i && t.charCodeAt(n) !== c; )
20
20
  n++;
21
- for (r[e[o]] = t.slice(p, n); n < a && t.charCodeAt(n) !== l; )
21
+ for (r[e[l]] = t.slice(d, n); n < s && t.charCodeAt(n) !== c; )
22
22
  n++;
23
23
  n++;
24
24
  }
25
25
  return r;
26
26
  }
27
- let b = 0;
28
- for (let o = 0; o < c; o++)
29
- d.charCodeAt(o) === s && b++;
30
- for (let o = 0; o < i; o++) {
31
- const p = n;
32
- let u = n;
33
- for (; u < a && t.charCodeAt(u) !== l; )
34
- u++;
35
- let g = 0, N = p;
36
- for (let h = p; h <= u; h++)
37
- if (h === u || t.charCodeAt(h) === s) {
38
- if (g === b) {
39
- r[e[o]] = t.slice(N, h);
27
+ let u = 0;
28
+ for (let l = 0; l < a; l++)
29
+ m.charCodeAt(l) === i && u++;
30
+ for (let l = 0; l < o; l++) {
31
+ const d = n;
32
+ let f = n;
33
+ for (; f < s && t.charCodeAt(f) !== c; )
34
+ f++;
35
+ let y = 0, b = d;
36
+ for (let p = d; p <= f; p++)
37
+ if (p === f || t.charCodeAt(p) === i) {
38
+ if (y === u) {
39
+ r[e[l]] = t.slice(b, p);
40
40
  break;
41
41
  }
42
- g++, N = h + 1;
42
+ y++, b = p + 1;
43
43
  }
44
- n = u + 1;
44
+ n = f + 1;
45
45
  }
46
46
  return r;
47
47
  }
48
- function E(d) {
48
+ function R(m) {
49
49
  const t = [], e = [];
50
- let r = !1, i = !1;
51
- const a = d.length;
52
- for (let l = 0; l < a; l++) {
53
- const s = d[l];
54
- s === '"' ? (r = !r, e.push(s)) : s === "[" ? (i = !0, e.push(s)) : s === "]" ? (i = !1, e.push(s)) : s === "," && !r && !i ? (t.push(e.join("").trim()), e.length = 0) : e.push(s);
50
+ let r = !1, o = !1;
51
+ const s = m.length;
52
+ for (let c = 0; c < s; c++) {
53
+ const i = m[c];
54
+ i === '"' ? (r = !r, e.push(i)) : i === "[" ? (o = !0, e.push(i)) : i === "]" ? (o = !1, e.push(i)) : i === "," && !r && !o ? (t.push(e.join("").trim()), e.length = 0) : e.push(i);
55
55
  }
56
56
  return e.length > 0 && t.push(e.join("").trim()), t;
57
57
  }
58
- function F(d, t) {
59
- const e = d.indexOf(t);
60
- return [d.slice(0, e), d.slice(e + 1)];
58
+ function E(m, t) {
59
+ const e = m.indexOf(t);
60
+ return [m.slice(0, e), m.slice(e + 1)];
61
61
  }
62
- function C(d) {
63
- const t = d.slice(1, -1), e = E(t), r = [];
64
- for (let i = 0; i < e.length; i++) {
65
- const a = e[i], [l, s] = F(a, "=");
66
- if (s && s.startsWith("[") && s.endsWith("]")) {
67
- const n = s.slice(1, -1).split(",");
68
- for (let c = 0; c < n.length; c++)
69
- n[c] = n[c].trim();
70
- r.push([l, n]);
71
- } else s && s.startsWith('"') && s.endsWith('"') ? r.push([l, s.slice(1, -1)]) : r.push([l, s]);
62
+ function F(m) {
63
+ const t = m.slice(1, -1), e = R(t), r = [];
64
+ for (let o = 0; o < e.length; o++) {
65
+ const s = e[o], [c, i] = E(s, "=");
66
+ if (i && i.startsWith("[") && i.endsWith("]")) {
67
+ const n = i.slice(1, -1).split(",");
68
+ for (let a = 0; a < n.length; a++)
69
+ n[a] = n[a].trim();
70
+ r.push([c, n]);
71
+ } else i && i.startsWith('"') && i.endsWith('"') ? r.push([c, i.slice(1, -1)]) : r.push([c, i]);
72
72
  }
73
73
  return Object.fromEntries(r);
74
74
  }
75
- const S = {
75
+ const A = {
76
76
  // INFO fields
77
77
  InfoFields: {
78
78
  // from the VCF4.3 spec, https://samtools.github.io/hts-specs/VCFv4.3.pdf
@@ -417,14 +417,14 @@ const S = {
417
417
  }
418
418
  }
419
419
  };
420
- function L(d) {
420
+ function C(m) {
421
421
  try {
422
- return decodeURIComponent(d);
422
+ return decodeURIComponent(m);
423
423
  } catch {
424
- return d;
424
+ return m;
425
425
  }
426
426
  }
427
- class M {
427
+ class L {
428
428
  constructor({ header: t = "", strict: e = !0 }) {
429
429
  if (!t.length)
430
430
  throw new Error("empty header received");
@@ -432,22 +432,22 @@ class M {
432
432
  if (!r.length)
433
433
  throw new Error("no non-empty header lines specified");
434
434
  this.strict = e, this.metadata = {
435
- INFO: { ...S.InfoFields },
436
- FORMAT: { ...S.GenotypeFields },
437
- ALT: { ...S.AltTypes },
438
- FILTER: { ...S.FilterTypes }
435
+ INFO: { ...A.InfoFields },
436
+ FORMAT: { ...A.GenotypeFields },
437
+ ALT: { ...A.AltTypes },
438
+ FILTER: { ...A.FilterTypes }
439
439
  };
440
- let i;
440
+ let o;
441
441
  for (let n = 0; n < r.length; n++) {
442
- const c = r[n];
443
- if (c.startsWith("#"))
444
- c.startsWith("##") ? this.parseMetadata(c) : i = c;
442
+ const a = r[n];
443
+ if (a.startsWith("#"))
444
+ a.startsWith("##") ? this.parseMetadata(a) : o = a;
445
445
  else throw new Error(`Bad line in header:
446
- ${c}`);
446
+ ${a}`);
447
447
  }
448
- if (!i)
448
+ if (!o)
449
449
  throw new Error("No format line found in header");
450
- const a = i.trim().split(" "), l = a.slice(0, 8), s = [
450
+ const s = o.trim().split(" "), c = s.slice(0, 8), i = [
451
451
  "#CHROM",
452
452
  "POS",
453
453
  "ID",
@@ -457,85 +457,83 @@ ${c}`);
457
457
  "FILTER",
458
458
  "INFO"
459
459
  ];
460
- if (a.length < 8)
460
+ if (s.length < 8)
461
461
  throw new Error(`VCF header missing columns:
462
- ${i}`);
463
- if (l.length !== s.length || !l.every((n, c) => n === s[c]))
462
+ ${o}`);
463
+ if (c.length !== i.length || !c.every((n, a) => n === i[a]))
464
464
  throw new Error(`VCF column headers not correct:
465
- ${i}`);
466
- this.samples = a.slice(9);
465
+ ${o}`);
466
+ this.samples = s.slice(9);
467
467
  }
468
468
  parseInfo(t) {
469
- var s;
470
- const e = {}, r = t.includes("%"), i = t.split(";"), a = this.metadata.INFO, l = i.length;
471
- for (let n = 0; n < l; n++) {
472
- const c = i[n], b = c.indexOf("="), o = b === -1 ? c : c.slice(0, b), p = b === -1 ? void 0 : c.slice(b + 1), u = (s = a[o]) == null ? void 0 : s.Type;
473
- if (u === "Flag")
474
- e[o] = !0;
475
- else if (!p)
476
- e[o] = !0;
469
+ const e = {}, r = t.includes("%"), o = t.split(";"), s = this.metadata.INFO, c = o.length;
470
+ for (let i = 0; i < c; i++) {
471
+ const n = o[i], a = n.indexOf("="), u = a === -1 ? n : n.slice(0, a), l = a === -1 ? void 0 : n.slice(a + 1), d = s[u]?.Type;
472
+ if (d === "Flag")
473
+ e[u] = !0;
474
+ else if (!l)
475
+ e[u] = !0;
477
476
  else {
478
- const g = u === "Integer" || u === "Float", N = p.split(","), h = N.length;
477
+ const f = d === "Integer" || d === "Float", y = l.split(","), b = y.length;
479
478
  if (r) {
480
- const f = [];
481
- for (let m = 0; m < h; m++) {
482
- const y = N[m];
483
- if (y === ".")
484
- f.push(void 0);
479
+ const p = [];
480
+ for (let h = 0; h < b; h++) {
481
+ const D = y[h];
482
+ if (D === ".")
483
+ p.push(void 0);
485
484
  else {
486
- const D = L(y);
487
- f.push(g ? Number(D) : D);
485
+ const g = C(D);
486
+ p.push(f ? Number(g) : g);
488
487
  }
489
488
  }
490
- e[o] = f;
489
+ e[u] = p;
491
490
  } else {
492
- const f = [];
493
- for (let m = 0; m < h; m++) {
494
- const y = N[m];
495
- y === "." ? f.push(void 0) : f.push(g ? Number(y) : y);
491
+ const p = [];
492
+ for (let h = 0; h < b; h++) {
493
+ const D = y[h];
494
+ D === "." ? p.push(void 0) : p.push(f ? Number(D) : D);
496
495
  }
497
- e[o] = f;
496
+ e[u] = p;
498
497
  }
499
498
  }
500
499
  }
501
500
  return e;
502
501
  }
503
502
  parseSamples(t, e) {
504
- var i;
505
503
  const r = {};
506
504
  if (t) {
507
- const a = e.split(" "), l = t.split(":"), s = this.metadata.FORMAT, n = [];
508
- for (let o = 0; o < l.length; o++) {
509
- const p = (i = s[l[o]]) == null ? void 0 : i.Type;
510
- n.push(p === "Integer" || p === "Float");
505
+ const o = e.split(" "), s = t.split(":"), c = this.metadata.FORMAT, i = [];
506
+ for (let u = 0; u < s.length; u++) {
507
+ const l = c[s[u]]?.Type;
508
+ i.push(l === "Integer" || l === "Float");
511
509
  }
512
- const c = l.length, b = this.samples.length;
513
- for (let o = 0; o < b; o++) {
514
- const p = this.samples[o], u = {}, g = a[o], N = g.length;
515
- let h = 0, f = 0;
516
- for (let m = 0; m <= N; m++)
517
- if (m === N || g[m] === ":") {
518
- const y = g.slice(h, m);
519
- if (y === "" || y === ".")
520
- u[l[f]] = void 0;
510
+ const n = s.length, a = this.samples.length;
511
+ for (let u = 0; u < a; u++) {
512
+ const l = this.samples[u], d = {}, f = o[u], y = f.length;
513
+ let b = 0, p = 0;
514
+ for (let h = 0; h <= y; h++)
515
+ if (h === y || f[h] === ":") {
516
+ const D = f.slice(b, h);
517
+ if (D === "" || D === ".")
518
+ d[s[p]] = void 0;
521
519
  else {
522
- const D = y.split(","), I = [];
523
- if (n[f])
524
- for (let T = 0; T < D.length; T++) {
525
- const A = D[T];
526
- I.push(A === "." ? void 0 : +A);
520
+ const g = D.split(","), T = [];
521
+ if (i[p])
522
+ for (let N = 0; N < g.length; N++) {
523
+ const I = g[N];
524
+ T.push(I === "." ? void 0 : +I);
527
525
  }
528
526
  else
529
- for (let T = 0; T < D.length; T++) {
530
- const A = D[T];
531
- I.push(A === "." ? void 0 : A);
527
+ for (let N = 0; N < g.length; N++) {
528
+ const I = g[N];
529
+ T.push(I === "." ? void 0 : I);
532
530
  }
533
- u[l[f]] = I;
531
+ d[s[p]] = T;
534
532
  }
535
- if (h = m + 1, f += 1, f >= c)
533
+ if (b = h + 1, p += 1, p >= n)
536
534
  break;
537
535
  }
538
- r[p] = u;
536
+ r[l] = d;
539
537
  }
540
538
  }
541
539
  return r;
@@ -551,13 +549,13 @@ ${i}`);
551
549
  const e = /^##(.+?)=(.*)/.exec(t.trim());
552
550
  if (!e)
553
551
  throw new Error(`Line is not a valid metadata line: ${t}`);
554
- const [r, i] = e.slice(1, 3), a = r;
555
- if (i != null && i.startsWith("<")) {
556
- a in this.metadata || (this.metadata[a] = {});
557
- const [l, s] = this.parseStructuredMetaVal(i);
558
- l ? this.metadata[a][l] = s : this.metadata[a] = s;
552
+ const [r, o] = e.slice(1, 3), s = r;
553
+ if (o?.startsWith("<")) {
554
+ s in this.metadata || (this.metadata[s] = {});
555
+ const [c, i] = this.parseStructuredMetaVal(o);
556
+ c ? this.metadata[s][c] = i : this.metadata[s] = i;
559
557
  } else
560
- this.metadata[a] = i;
558
+ this.metadata[s] = o;
561
559
  }
562
560
  /**
563
561
  * Parse a VCF header structured meta string (i.e. a meta value that starts
@@ -569,7 +567,7 @@ ${i}`);
569
567
  * and 2) an object with the other key-value pairs in the metadata
570
568
  */
571
569
  parseStructuredMetaVal(t) {
572
- const e = C(t), r = e.ID;
570
+ const e = F(t), r = e.ID;
573
571
  return delete e.ID, "Number" in e && (Number.isNaN(Number(e.Number)) || (e.Number = Number(e.Number))), [r, e];
574
572
  }
575
573
  /**
@@ -584,8 +582,8 @@ ${i}`);
584
582
  getMetadata(...t) {
585
583
  let e = this.metadata;
586
584
  const r = t.length;
587
- for (let i = 0; i < r; i++)
588
- if (e = e[t[i]], !e)
585
+ for (let o = 0; o < r; o++)
586
+ if (e = e[t[o]], !e)
589
587
  return e;
590
588
  return e;
591
589
  }
@@ -635,25 +633,25 @@ ${i}`);
635
633
  let e = 0, r = 0;
636
634
  for (; e < t.length && r < 9; )
637
635
  t[e] === " " && (r += 1), e += 1;
638
- const i = r === 9 ? e - 1 : e, a = t.slice(0, i).split(" "), l = t.slice(i + 1), [s, n, c, b, o, p, u] = a, g = s, N = +n, h = c === "." ? void 0 : c.split(";"), f = b, m = o === "." ? void 0 : o.split(","), y = p === "." ? void 0 : +p, D = u === "." ? void 0 : u.split(";"), I = a[8];
639
- if (this.strict && !a[7])
636
+ const o = r === 9 ? e - 1 : e, s = t.slice(0, o).split(" "), c = t.slice(o + 1), [i, n, a, u, l, d, f] = s, y = i, b = +n, p = a === "." ? void 0 : a.split(";"), h = u, D = l === "." ? void 0 : l.split(","), g = d === "." ? void 0 : +d, T = f === "." ? void 0 : f.split(";"), N = s[8];
637
+ if (this.strict && !s[7])
640
638
  throw new Error("no INFO field specified, must contain at least a '.' (turn off strict mode to allow)");
641
- const T = a[7] === void 0 || a[7] === "." ? {} : this.parseInfo(a[7]);
639
+ const I = s[7] === void 0 || s[7] === "." ? {} : this.parseInfo(s[7]);
642
640
  return {
643
- CHROM: g,
644
- POS: N,
645
- ALT: m,
646
- INFO: T,
647
- REF: f,
648
- FILTER: (D == null ? void 0 : D.length) === 1 && D[0] === "PASS" ? "PASS" : D,
649
- ID: h,
650
- QUAL: y,
651
- FORMAT: I,
652
- SAMPLES: () => this.parseSamples(a[8] ?? "", l),
653
- GENOTYPES: () => R(a[8] ?? "", l, this.samples)
641
+ CHROM: y,
642
+ POS: b,
643
+ ALT: D,
644
+ INFO: I,
645
+ REF: h,
646
+ FILTER: T?.length === 1 && T[0] === "PASS" ? "PASS" : T,
647
+ ID: p,
648
+ QUAL: g,
649
+ FORMAT: N,
650
+ SAMPLES: () => this.parseSamples(s[8] ?? "", c),
651
+ GENOTYPES: () => S(s[8] ?? "", c, this.samples)
654
652
  };
655
653
  }
656
654
  }
657
655
  export {
658
- M as default
656
+ L as default
659
657
  };