jbrowse-plugin-mafviewer 1.4.3 → 1.4.5

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.
Files changed (73) hide show
  1. package/README.md +1 -1
  2. package/dist/LinearMafDisplay/components/InsertionSequenceDialog/InsertionSequenceDialog.d.ts +14 -0
  3. package/dist/LinearMafDisplay/components/InsertionSequenceDialog/InsertionSequenceDialog.js +69 -0
  4. package/dist/LinearMafDisplay/components/InsertionSequenceDialog/InsertionSequenceDialog.js.map +1 -0
  5. package/dist/LinearMafDisplay/components/LinearMafDisplayComponent.js +4 -4
  6. package/dist/LinearMafDisplay/components/LinearMafDisplayComponent.js.map +1 -1
  7. package/dist/LinearMafDisplay/components/Sidebar/ColorLegend.js +2 -2
  8. package/dist/LinearMafDisplay/components/Sidebar/ColorLegend.js.map +1 -1
  9. package/dist/LinearMafDisplay/components/Sidebar/RectBg.d.ts +1 -1
  10. package/dist/LinearMafDisplay/components/Sidebar/RectBg.js +2 -3
  11. package/dist/LinearMafDisplay/components/Sidebar/RectBg.js.map +1 -1
  12. package/dist/LinearMafDisplay/components/Sidebar/SvgWrapper.js +81 -11
  13. package/dist/LinearMafDisplay/components/Sidebar/SvgWrapper.js.map +1 -1
  14. package/dist/LinearMafDisplay/components/Sidebar/Tree.js +30 -9
  15. package/dist/LinearMafDisplay/components/Sidebar/Tree.js.map +1 -1
  16. package/dist/LinearMafDisplay/components/Sidebar/YScaleBars.d.ts +0 -1
  17. package/dist/LinearMafDisplay/components/Sidebar/YScaleBars.js.map +1 -1
  18. package/dist/LinearMafDisplay/renderSvg.js +1 -1
  19. package/dist/LinearMafDisplay/renderSvg.js.map +1 -1
  20. package/dist/LinearMafDisplay/stateModel.d.ts +69 -3
  21. package/dist/LinearMafDisplay/stateModel.js +96 -1
  22. package/dist/LinearMafDisplay/stateModel.js.map +1 -1
  23. package/dist/LinearMafDisplay/util.d.ts +1 -0
  24. package/dist/LinearMafDisplay/util.js +3 -2
  25. package/dist/LinearMafDisplay/util.js.map +1 -1
  26. package/dist/LinearMafRenderer/LinearMafRenderer.d.ts +4 -7
  27. package/dist/LinearMafRenderer/LinearMafRenderer.js.map +1 -1
  28. package/dist/LinearMafRenderer/components/LinearMafRendering.js +27 -9
  29. package/dist/LinearMafRenderer/components/LinearMafRendering.js.map +1 -1
  30. package/dist/LinearMafRenderer/makeImageData.js +6 -7
  31. package/dist/LinearMafRenderer/makeImageData.js.map +1 -1
  32. package/dist/LinearMafRenderer/rendering/features.d.ts +0 -1
  33. package/dist/LinearMafRenderer/rendering/features.js +1 -14
  34. package/dist/LinearMafRenderer/rendering/features.js.map +1 -1
  35. package/dist/LinearMafRenderer/rendering/insertions.js +8 -6
  36. package/dist/LinearMafRenderer/rendering/insertions.js.map +1 -1
  37. package/dist/LinearMafRenderer/rendering/matches.d.ts +1 -1
  38. package/dist/LinearMafRenderer/rendering/matches.js +3 -15
  39. package/dist/LinearMafRenderer/rendering/matches.js.map +1 -1
  40. package/dist/LinearMafRenderer/rendering/spatialIndex.js +8 -2
  41. package/dist/LinearMafRenderer/rendering/spatialIndex.js.map +1 -1
  42. package/dist/LinearMafRenderer/rendering/text.js +1 -3
  43. package/dist/LinearMafRenderer/rendering/text.js.map +1 -1
  44. package/dist/LinearMafRenderer/rendering/types.d.ts +5 -4
  45. package/dist/jbrowse-plugin-mafviewer.umd.production.min.js +7 -7
  46. package/dist/jbrowse-plugin-mafviewer.umd.production.min.js.map +4 -4
  47. package/dist/util/fastaUtils.js +23 -50
  48. package/dist/util/fastaUtils.js.map +1 -1
  49. package/package.json +7 -7
  50. package/src/LinearMafDisplay/components/InsertionSequenceDialog/InsertionSequenceDialog.tsx +105 -0
  51. package/src/LinearMafDisplay/components/LinearMafDisplayComponent.tsx +4 -4
  52. package/src/LinearMafDisplay/components/Sidebar/ColorLegend.tsx +2 -6
  53. package/src/LinearMafDisplay/components/Sidebar/RectBg.tsx +8 -3
  54. package/src/LinearMafDisplay/components/Sidebar/SvgWrapper.tsx +117 -15
  55. package/src/LinearMafDisplay/components/Sidebar/Tree.tsx +53 -8
  56. package/src/LinearMafDisplay/components/Sidebar/YScaleBars.tsx +0 -1
  57. package/src/LinearMafDisplay/renderSvg.tsx +1 -1
  58. package/src/LinearMafDisplay/stateModel.ts +109 -1
  59. package/src/LinearMafDisplay/util.ts +4 -2
  60. package/src/LinearMafRenderer/LinearMafRenderer.ts +2 -4
  61. package/src/LinearMafRenderer/components/LinearMafRendering.tsx +49 -29
  62. package/src/LinearMafRenderer/makeImageData.ts +5 -14
  63. package/src/LinearMafRenderer/rendering/features.ts +2 -36
  64. package/src/LinearMafRenderer/rendering/insertions.ts +11 -6
  65. package/src/LinearMafRenderer/rendering/matches.ts +2 -27
  66. package/src/LinearMafRenderer/rendering/spatialIndex.ts +9 -2
  67. package/src/LinearMafRenderer/rendering/text.ts +1 -2
  68. package/src/LinearMafRenderer/rendering/types.ts +7 -4
  69. package/src/util/fastaUtils.ts +28 -54
  70. package/dist/LinearMafRenderer/components/util.d.ts +0 -1
  71. package/dist/LinearMafRenderer/components/util.js +0 -13
  72. package/dist/LinearMafRenderer/components/util.js.map +0 -1
  73. package/src/LinearMafRenderer/components/util.ts +0 -13
@@ -25,72 +25,44 @@ export function processFeaturesToFasta({
25
25
  const region = regions[0]!
26
26
  const sampleToRowMap = new Map(samples.map((s, i) => [s.id, i]))
27
27
  const rlen = region.end - region.start
28
- const outputRows = samples.map(() => '-'.repeat(rlen))
28
+
29
+ // Use character arrays instead of strings for O(1) mutations
30
+ const outputRowsArrays = samples.map(() => new Array(rlen).fill('-'))
31
+
29
32
  for (const feature of features.values()) {
30
33
  const leftCoord = feature.get('start')
31
34
  const vals = feature.get('alignments') as Record<string, AlignmentRecord>
32
35
  const seq = feature.get('seq')
33
- for (const [sample, val] of Object.entries(vals)) {
34
- const origAlignment = val.seq
35
- const alignment = origAlignment
36
36
 
37
+ for (const [sample, val] of Object.entries(vals)) {
38
+ const alignment = val.seq
37
39
  const row = sampleToRowMap.get(sample)
38
40
  if (row === undefined) {
39
41
  continue
40
42
  }
41
43
 
42
- // gaps
43
- for (let i = 0, o = 0, l = alignment.length; i < l; i++) {
44
- if (seq[i] !== '-') {
45
- if (alignment[i] === '-') {
46
- const l = leftCoord + o - region.start
47
- if (l >= 0 && l < rlen) {
48
- outputRows[row] =
49
- outputRows[row]!.slice(0, l) +
50
- '-' +
51
- outputRows[row]!.slice(l + 1)
52
- }
53
- }
54
- o++
55
- }
56
- }
44
+ const rowArray = outputRowsArrays[row]!
57
45
 
58
- if (!showAllLetters) {
59
- // matches
60
- for (let i = 0, o = 0, l = alignment.length; i < l; i++) {
61
- if (seq[i] !== '-') {
62
- const c = alignment[i]
63
- const l = leftCoord + o - region.start
64
- if (l >= 0 && l < rlen) {
65
- if (seq[i] === c && c !== '-' && c !== ' ') {
66
- outputRows[row] =
67
- outputRows[row]!.slice(0, l) +
68
- '.' +
69
- outputRows[row]!.slice(l + 1)
70
- }
71
- }
72
- o++
73
- }
74
- }
75
- }
76
-
77
- // mismatches
46
+ // Single-pass processing: handle gaps, matches, and mismatches together
78
47
  for (let i = 0, o = 0, l = alignment.length; i < l; i++) {
79
- const c = alignment[i]
80
48
  if (seq[i] !== '-') {
81
- if (c !== '-') {
82
- const l = leftCoord + o - region.start
83
- if (l >= 0 && l < rlen) {
84
- if (seq[i] !== c && c !== ' ') {
85
- outputRows[row] =
86
- outputRows[row]!.slice(0, l) +
87
- c +
88
- outputRows[row]!.slice(l + 1)
89
- } else if (showAllLetters) {
90
- outputRows[row] =
91
- outputRows[row]!.slice(0, l) +
92
- c +
93
- outputRows[row]!.slice(l + 1)
49
+ const c = alignment[i]
50
+ const pos = leftCoord + o - region.start
51
+
52
+ if (pos >= 0 && pos < rlen) {
53
+ if (c === '-') {
54
+ // Gap
55
+ rowArray[pos] = '-'
56
+ } else if (c !== ' ') {
57
+ if (showAllLetters) {
58
+ // Show all letters mode: write character directly
59
+ rowArray[pos] = c
60
+ } else if (seq[i] === c) {
61
+ // Match: use dot notation
62
+ rowArray[pos] = '.'
63
+ } else {
64
+ // Mismatch: write character
65
+ rowArray[pos] = c
94
66
  }
95
67
  }
96
68
  }
@@ -99,5 +71,7 @@ export function processFeaturesToFasta({
99
71
  }
100
72
  }
101
73
  }
102
- return outputRows
74
+
75
+ // Convert character arrays back to strings
76
+ return outputRowsArrays.map(arr => arr.join(''))
103
77
  }
@@ -1 +0,0 @@
1
- export declare function minElt<T>(arr: Iterable<T>, cb: (arg: T) => number): T | undefined;
@@ -1,13 +0,0 @@
1
- export function minElt(arr, cb) {
2
- let min = Infinity;
3
- let minElement;
4
- for (const entry of arr) {
5
- const val = cb(entry);
6
- if (val < min) {
7
- min = val;
8
- minElement = entry;
9
- }
10
- }
11
- return minElement;
12
- }
13
- //# sourceMappingURL=util.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/LinearMafRenderer/components/util.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,MAAM,CAAI,GAAgB,EAAE,EAAsB;IAChE,IAAI,GAAG,GAAG,QAAQ,CAAA;IAClB,IAAI,UAAyB,CAAA;IAC7B,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC,CAAA;QAErB,IAAI,GAAG,GAAG,GAAG,EAAE,CAAC;YACd,GAAG,GAAG,GAAG,CAAA;YACT,UAAU,GAAG,KAAK,CAAA;QACpB,CAAC;IACH,CAAC;IACD,OAAO,UAAU,CAAA;AACnB,CAAC"}
@@ -1,13 +0,0 @@
1
- export function minElt<T>(arr: Iterable<T>, cb: (arg: T) => number) {
2
- let min = Infinity
3
- let minElement: T | undefined
4
- for (const entry of arr) {
5
- const val = cb(entry)
6
-
7
- if (val < min) {
8
- min = val
9
- minElement = entry
10
- }
11
- }
12
- return minElement
13
- }