jbrowse-plugin-tview 2.2.1 → 2.2.3
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.
- package/README.md +71 -3
- package/dist/LaunchTView/align.d.ts +7 -0
- package/dist/LaunchTView/align.js +9 -2
- package/dist/LaunchTView/align.js.map +1 -1
- package/dist/LaunchTView/alleles.js +4 -3
- package/dist/LaunchTView/alleles.js.map +1 -1
- package/dist/LaunchTView/repeatStats.js +18 -3
- package/dist/LaunchTView/repeatStats.js.map +1 -1
- package/dist/LaunchTView/repeats.js +6 -4
- package/dist/LaunchTView/repeats.js.map +1 -1
- package/dist/LaunchTView/tview.d.ts +13 -1
- package/dist/LaunchTView/tview.js +65 -25
- package/dist/LaunchTView/tview.js.map +1 -1
- package/dist/TViewPanel/model.d.ts +162 -90
- package/dist/jbrowse-plugin-tview.umd.production.min.js +24 -25
- package/dist/jbrowse-plugin-tview.umd.production.min.js.map +4 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +16 -13
- package/src/LaunchTView/align.ts +9 -2
- package/src/LaunchTView/alleles.ts +4 -4
- package/src/LaunchTView/repeatStats.ts +19 -3
- package/src/LaunchTView/repeats.ts +6 -4
- package/src/LaunchTView/tview.ts +75 -26
- package/src/version.ts +1 -1
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "2.2.
|
|
1
|
+
export declare const version = "2.2.3";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export const version = '2.2.
|
|
1
|
+
export const version = '2.2.3';
|
|
2
2
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "2.2.
|
|
2
|
+
"version": "2.2.3",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"name": "jbrowse-plugin-tview",
|
|
5
5
|
"repository": {
|
|
@@ -38,31 +38,34 @@
|
|
|
38
38
|
"figures:repeats": "node scripts/repeat-figures.mjs",
|
|
39
39
|
"prefigures:repeats": "pnpm pretest:e2e",
|
|
40
40
|
"report:repeats": "tsx scripts/repeat-report.mjs",
|
|
41
|
-
"readme:repeats": "tsx scripts/repeat-readme.mjs"
|
|
41
|
+
"readme:repeats": "tsx scripts/repeat-readme.mjs",
|
|
42
|
+
"demos": "node scripts/demo-links.mjs",
|
|
43
|
+
"demos:upload": "node scripts/demo-upload.mjs",
|
|
44
|
+
"predemos:upload": "pnpm build && pnpm demos"
|
|
42
45
|
},
|
|
43
46
|
"jbrowse-plugin": {
|
|
44
47
|
"name": "TView"
|
|
45
48
|
},
|
|
46
49
|
"dependencies": {
|
|
47
50
|
"@emotion/styled": "^11.14.1",
|
|
48
|
-
"swr": "^2.5.
|
|
51
|
+
"swr": "^2.5.1"
|
|
49
52
|
},
|
|
50
53
|
"devDependencies": {
|
|
51
54
|
"@emotion/react": "^11.14.0",
|
|
52
55
|
"@eslint/js": "^10.0.1",
|
|
53
56
|
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
|
|
54
|
-
"@gmod/bam": "^8.
|
|
55
|
-
"@gmod/indexedfasta": "^5.0.
|
|
57
|
+
"@gmod/bam": "^8.11.1",
|
|
58
|
+
"@gmod/indexedfasta": "^5.0.11",
|
|
56
59
|
"@jbrowse/core": "^4.3.0",
|
|
57
60
|
"@jbrowse/mobx-state-tree": "^6.1.0",
|
|
58
61
|
"@jbrowse/plugin-linear-genome-view": "^4.3.0",
|
|
59
62
|
"@mui/icons-material": "^9.3.1",
|
|
60
63
|
"@mui/material": "^9.3.1",
|
|
61
64
|
"@mui/system": "^9.3.0",
|
|
62
|
-
"@types/node": "^26.
|
|
65
|
+
"@types/node": "^26.3.0",
|
|
63
66
|
"@types/react": "^19.2.18",
|
|
64
|
-
"esbuild": "^0.28.
|
|
65
|
-
"eslint": "^10.
|
|
67
|
+
"esbuild": "^0.28.2",
|
|
68
|
+
"eslint": "^10.9.1",
|
|
66
69
|
"eslint-plugin-import-x": "^4.17.1",
|
|
67
70
|
"eslint-plugin-react": "^7.37.5",
|
|
68
71
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
@@ -70,15 +73,15 @@
|
|
|
70
73
|
"mobx-react": "^10.0.0",
|
|
71
74
|
"prettier": "^3.9.6",
|
|
72
75
|
"pretty-bytes": "^7.1.1",
|
|
73
|
-
"puppeteer": "^25.
|
|
76
|
+
"puppeteer": "^25.9.0",
|
|
74
77
|
"react": "^19.2.8",
|
|
75
78
|
"react-dom": "^19.2.8",
|
|
76
|
-
"react-msaview": "^
|
|
79
|
+
"react-msaview": "^6.4.2",
|
|
77
80
|
"rimraf": "^6.1.3",
|
|
78
81
|
"tss-react": "^4.9.21",
|
|
79
|
-
"tsx": "^4.
|
|
82
|
+
"tsx": "^4.23.12",
|
|
80
83
|
"typescript": "^6.0.2",
|
|
81
|
-
"typescript-eslint": "^8.
|
|
82
|
-
"vitest": "^4.1.
|
|
84
|
+
"typescript-eslint": "^8.68.0",
|
|
85
|
+
"vitest": "^4.1.11"
|
|
83
86
|
}
|
|
84
87
|
}
|
package/src/LaunchTView/align.ts
CHANGED
|
@@ -442,14 +442,21 @@ export function alignPeriodicInsertions(
|
|
|
442
442
|
* which is a guess that one chimeric read overturns for the whole site. Measured
|
|
443
443
|
* off the reference, it is a property of the locus, so every read is laid out
|
|
444
444
|
* against the same unit whatever the reads happen to be.
|
|
445
|
+
*
|
|
446
|
+
* An empty sequence is one of the alleles, not a missing one: a row that
|
|
447
|
+
* deletes the whole array carries nought copies of it, which is a measurement
|
|
448
|
+
* and the most extreme contraction there is. It splits into no units and so
|
|
449
|
+
* lays out as a row of gaps the width of the block, which is what a deletion
|
|
450
|
+
* should look like. Dropping it instead left that row indistinguishable from
|
|
451
|
+
* one that never reached the array at all.
|
|
445
452
|
*/
|
|
446
453
|
export function alignToUnit(
|
|
447
454
|
seqs: string[],
|
|
448
455
|
consensus: string,
|
|
449
456
|
): PeriodicAlignment | undefined {
|
|
450
|
-
const distinct = [...new Set(seqs)]
|
|
457
|
+
const distinct = [...new Set(seqs)]
|
|
451
458
|
const period = consensus.length
|
|
452
|
-
if (!distinct.length || period < MIN_UNIT_PERIOD) {
|
|
459
|
+
if (!distinct.some(s => s.length) || period < MIN_UNIT_PERIOD) {
|
|
453
460
|
return undefined
|
|
454
461
|
}
|
|
455
462
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { alignToUnit, unitIdentity } from './align'
|
|
2
|
+
import { ABSENT, SPANNED_GAP } from './readLayout'
|
|
2
3
|
|
|
3
4
|
import type { ReadLayout } from './readLayout'
|
|
4
5
|
import type { ReferenceArray } from './repeats'
|
|
@@ -32,9 +33,6 @@ export interface ArrayBlock {
|
|
|
32
33
|
lengthByName: Map<string, number>
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
const SPANNED_GAP = '-'
|
|
36
|
-
const ABSENT = '.'
|
|
37
|
-
|
|
38
36
|
/**
|
|
39
37
|
* What one row has between two reference positions: its matched bases, plus
|
|
40
38
|
* whatever it inserted inside, minus whatever it deleted.
|
|
@@ -277,7 +275,9 @@ export function reanchorInsertions(
|
|
|
277
275
|
const at = target ?? pos
|
|
278
276
|
moved ||= target !== undefined
|
|
279
277
|
const seq =
|
|
280
|
-
target === undefined
|
|
278
|
+
target === undefined
|
|
279
|
+
? ins
|
|
280
|
+
: (shiftInsertion(read, pos, target, ins) ?? ins)
|
|
281
281
|
next.set(at, (next.get(at) ?? '') + seq)
|
|
282
282
|
}
|
|
283
283
|
return moved ? { ...read, insertions: next } : read
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
* back counts, which is what makes it testable without the network.
|
|
9
9
|
*/
|
|
10
10
|
import { ABSENT, SPANNED_GAP } from './readLayout'
|
|
11
|
+
import { newickSafe } from './sampleTree'
|
|
11
12
|
import { renderRow } from './tview'
|
|
12
13
|
|
|
13
14
|
import type { ArrayBlock } from './alleles'
|
|
@@ -143,6 +144,23 @@ function sampleOfRow(name: string) {
|
|
|
143
144
|
return i < 0 ? undefined : name.slice(0, i)
|
|
144
145
|
}
|
|
145
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Rows are prefixed with the Newick-safe form of their sample's name, so a
|
|
149
|
+
* caller naming the samples it wants reported has to be met there rather than
|
|
150
|
+
* taken at its word. A track called `HG004 (mother)` otherwise matched no row
|
|
151
|
+
* and came back with nought spanning reads and no alleles — which is what a
|
|
152
|
+
* locus nobody sequenced looks like, not what a misspelt name should.
|
|
153
|
+
*
|
|
154
|
+
* The name the caller gave is what gets reported back; only the matching is
|
|
155
|
+
* sanitized.
|
|
156
|
+
*/
|
|
157
|
+
function rowsOfSample(copiesByName: Map<string, number>, sample: string) {
|
|
158
|
+
const key = newickSafe(sample)
|
|
159
|
+
return [...copiesByName]
|
|
160
|
+
.filter(([name]) => sampleOfRow(name) === key)
|
|
161
|
+
.map(([, n]) => n)
|
|
162
|
+
}
|
|
163
|
+
|
|
146
164
|
function arrayStats(
|
|
147
165
|
array: ArrayBlock,
|
|
148
166
|
plan: TviewPlan,
|
|
@@ -160,9 +178,7 @@ function arrayStats(
|
|
|
160
178
|
: undefined,
|
|
161
179
|
subject: array === plan.subject,
|
|
162
180
|
samples: samples.map(sample => {
|
|
163
|
-
const copies =
|
|
164
|
-
.filter(([name]) => sampleOfRow(name) === sample)
|
|
165
|
-
.map(([, n]) => n)
|
|
181
|
+
const copies = rowsOfSample(array.copiesByName, sample)
|
|
166
182
|
const modes = alleleModes(copies)
|
|
167
183
|
return {
|
|
168
184
|
sample,
|
|
@@ -194,14 +194,16 @@ const RIVAL_SPAN_FRACTION = 0.5
|
|
|
194
194
|
*/
|
|
195
195
|
export function mergeArrays(arrays: ReferenceArray[], gap = 0) {
|
|
196
196
|
const groups: ReferenceArray[][] = []
|
|
197
|
+
// how far right the open group reaches, which is not its last member's end:
|
|
198
|
+
// sorting by start lets a long array be followed by one that ends inside it
|
|
199
|
+
let reach = -Infinity
|
|
197
200
|
for (const array of [...arrays].sort((a, b) => a.start - b.start)) {
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
if (last && array.start <= end + gap) {
|
|
201
|
-
last.push(array)
|
|
201
|
+
if (array.start <= reach + gap) {
|
|
202
|
+
groups.at(-1)!.push(array)
|
|
202
203
|
} else {
|
|
203
204
|
groups.push([array])
|
|
204
205
|
}
|
|
206
|
+
reach = Math.max(reach, array.end)
|
|
205
207
|
}
|
|
206
208
|
return groups.map(group => {
|
|
207
209
|
const span = (a: ReferenceArray) => a.end - a.start
|
package/src/LaunchTView/tview.ts
CHANGED
|
@@ -85,10 +85,16 @@ export interface ColumnLayout {
|
|
|
85
85
|
*/
|
|
86
86
|
offsets: number[]
|
|
87
87
|
totalColumns: number
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
88
|
+
/** the array beginning at a position, for the positions one begins at */
|
|
89
|
+
arrayByStart: Map<number, ArrayBlock>
|
|
90
|
+
/**
|
|
91
|
+
* Ascending, the positions a row cannot be laid out in bulk over: an array
|
|
92
|
+
* block starts here, or some read inserts here. Between two of them every
|
|
93
|
+
* position is one reference column, so that stretch of a row is a slice of
|
|
94
|
+
* the read's own bases rather than a walk over them — which is what keeps
|
|
95
|
+
* rendering proportional to the indels in a region rather than to its width.
|
|
96
|
+
*/
|
|
97
|
+
breaks: number[]
|
|
92
98
|
}
|
|
93
99
|
|
|
94
100
|
/**
|
|
@@ -103,15 +109,17 @@ export function buildColumnLayout(
|
|
|
103
109
|
insWidths: Map<number, number>,
|
|
104
110
|
arrays: ArrayBlock[] = [],
|
|
105
111
|
): ColumnLayout {
|
|
106
|
-
const
|
|
112
|
+
const arrayByStart = new Map(arrays.map(a => [a.start, a]))
|
|
107
113
|
const offsets: number[] = []
|
|
114
|
+
const breaks: number[] = []
|
|
108
115
|
let col = 0
|
|
109
116
|
let pos = start
|
|
110
117
|
while (pos < end) {
|
|
111
|
-
const array =
|
|
118
|
+
const array = arrayByStart.get(pos)
|
|
112
119
|
if (array) {
|
|
113
120
|
const stop = Math.min(array.end, end)
|
|
114
121
|
offsets.push(col)
|
|
122
|
+
breaks.push(pos)
|
|
115
123
|
col += array.width
|
|
116
124
|
for (let p = pos + 1; p < stop; p++) {
|
|
117
125
|
offsets.push(col)
|
|
@@ -119,12 +127,40 @@ export function buildColumnLayout(
|
|
|
119
127
|
pos = stop
|
|
120
128
|
} else {
|
|
121
129
|
offsets.push(col)
|
|
122
|
-
|
|
130
|
+
const width = insWidths.get(pos) ?? 0
|
|
131
|
+
if (width) {
|
|
132
|
+
breaks.push(pos)
|
|
133
|
+
}
|
|
134
|
+
col += width + 1
|
|
123
135
|
pos++
|
|
124
136
|
}
|
|
125
137
|
}
|
|
126
138
|
offsets.push(col)
|
|
127
|
-
return {
|
|
139
|
+
return {
|
|
140
|
+
start,
|
|
141
|
+
end,
|
|
142
|
+
insWidths,
|
|
143
|
+
arrays,
|
|
144
|
+
offsets,
|
|
145
|
+
totalColumns: col,
|
|
146
|
+
arrayByStart,
|
|
147
|
+
breaks,
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** index of the first break at or after `pos` */
|
|
152
|
+
function breakIndex(breaks: number[], pos: number) {
|
|
153
|
+
let lo = 0
|
|
154
|
+
let hi = breaks.length
|
|
155
|
+
while (lo < hi) {
|
|
156
|
+
const mid = (lo + hi) >> 1
|
|
157
|
+
if (breaks[mid]! < pos) {
|
|
158
|
+
lo = mid + 1
|
|
159
|
+
} else {
|
|
160
|
+
hi = mid
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return lo
|
|
128
164
|
}
|
|
129
165
|
|
|
130
166
|
/** the array covering `pos`, when `pos` is strictly inside one */
|
|
@@ -136,14 +172,17 @@ function arrayContaining(arrays: ArrayBlock[], pos: number) {
|
|
|
136
172
|
* Lays a single row out across the whole region. Rows are typically a tiny
|
|
137
173
|
* fraction of the region, so the columns on either side are filled in one shot
|
|
138
174
|
* from the offsets rather than walked position by position — which works over
|
|
139
|
-
* array blocks too, since the offsets already carry their width.
|
|
175
|
+
* array blocks too, since the offsets already carry their width. Inside its own
|
|
176
|
+
* span a row is walked only at the layout's breaks, and copied straight out of
|
|
177
|
+
* `refChars` between them.
|
|
140
178
|
*/
|
|
141
179
|
export function renderRow(read: ReadLayout, layout: ColumnLayout) {
|
|
142
180
|
const { start, end, insWidths, arrays, offsets, totalColumns } = layout
|
|
143
|
-
const
|
|
181
|
+
const { arrayByStart, breaks } = layout
|
|
144
182
|
// a trailing insertion is keyed one past the last position the read spans
|
|
183
|
+
const lastPos = read.start + read.refChars.length
|
|
145
184
|
let from = Math.max(start, read.start)
|
|
146
|
-
let to = Math.min(end,
|
|
185
|
+
let to = Math.min(end, lastPos + 1)
|
|
147
186
|
// a row that begins or ends inside an array does not span it, so it gets no
|
|
148
187
|
// block; snapping past the block keeps the walk from emitting part of one
|
|
149
188
|
const startsInside = arrayContaining(arrays, from)
|
|
@@ -160,26 +199,36 @@ export function renderRow(read: ReadLayout, layout: ColumnLayout) {
|
|
|
160
199
|
|
|
161
200
|
let ret = ABSENT.repeat(offsets[from - start]!)
|
|
162
201
|
let pos = from
|
|
202
|
+
let next = breakIndex(breaks, from)
|
|
163
203
|
while (pos < to) {
|
|
164
|
-
|
|
204
|
+
while (next < breaks.length && breaks[next]! < pos) {
|
|
205
|
+
next++
|
|
206
|
+
}
|
|
207
|
+
const stop = Math.min(next < breaks.length ? breaks[next]! : to, to)
|
|
208
|
+
if (stop > pos) {
|
|
209
|
+
// the walk never leaves the read's own bases except at its very last
|
|
210
|
+
// position, which is the slot a trailing insertion is keyed in
|
|
211
|
+
const cut = Math.min(stop, lastPos)
|
|
212
|
+
ret += read.refChars.slice(pos - read.start, cut - read.start)
|
|
213
|
+
ret += ABSENT.repeat(stop - cut)
|
|
214
|
+
pos = stop
|
|
215
|
+
continue
|
|
216
|
+
}
|
|
217
|
+
const array = arrayByStart.get(pos)
|
|
165
218
|
if (array) {
|
|
166
|
-
|
|
167
|
-
|
|
219
|
+
// a row with no allele here did not reach both edges of the array, or
|
|
220
|
+
// skipped it through an N — either way it is not here, and a block of
|
|
221
|
+
// deletion gaps would read as an allele it does not have
|
|
222
|
+
ret += array.rowByName.get(read.name) ?? ABSENT.repeat(array.width)
|
|
168
223
|
pos = Math.min(array.end, to)
|
|
169
224
|
continue
|
|
170
225
|
}
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
const
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
// pads the reference column, so an intron reads as one absence
|
|
178
|
-
const pad = refChar === ABSENT ? ABSENT : SPANNED_GAP
|
|
179
|
-
const ins = read.insertions.get(pos) ?? ''
|
|
180
|
-
ret += ins + pad.repeat(width - ins.length)
|
|
181
|
-
}
|
|
182
|
-
ret += refChar
|
|
226
|
+
const refChar = pos < lastPos ? read.refChars[pos - read.start]! : ABSENT
|
|
227
|
+
// a read that is not really here pads the insertion the same way it pads
|
|
228
|
+
// the reference column, so an intron reads as one absence
|
|
229
|
+
const pad = refChar === ABSENT ? ABSENT : SPANNED_GAP
|
|
230
|
+
const ins = read.insertions.get(pos) ?? ''
|
|
231
|
+
ret += ins + pad.repeat(insWidths.get(pos)! - ins.length) + refChar
|
|
183
232
|
pos++
|
|
184
233
|
}
|
|
185
234
|
return ret + ABSENT.repeat(totalColumns - offsets[to - start]!)
|
package/src/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.2.
|
|
1
|
+
export const version = '2.2.3'
|