jbrowse-plugin-tview 2.0.4 → 2.1.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.
- package/README.md +157 -4
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.d.ts +132 -0
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js +152 -0
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js.map +1 -0
- package/dist/LaunchTView/TviewGetPlanRpc/index.d.ts +3 -0
- package/dist/LaunchTView/TviewGetPlanRpc/index.js +5 -0
- package/dist/LaunchTView/TviewGetPlanRpc/index.js.map +1 -0
- package/dist/LaunchTView/align.d.ts +93 -9
- package/dist/LaunchTView/align.js +290 -15
- package/dist/LaunchTView/align.js.map +1 -1
- package/dist/LaunchTView/alleles.d.ts +57 -0
- package/dist/LaunchTView/alleles.js +94 -0
- package/dist/LaunchTView/alleles.js.map +1 -0
- package/dist/LaunchTView/components/ArrayReport.d.ts +10 -0
- package/dist/LaunchTView/components/ArrayReport.js +59 -0
- package/dist/LaunchTView/components/ArrayReport.js.map +1 -0
- package/dist/LaunchTView/components/LaunchTViewDialog.js +74 -37
- package/dist/LaunchTView/components/LaunchTViewDialog.js.map +1 -1
- package/dist/LaunchTView/fetchTviewPlan.d.ts +20 -13
- package/dist/LaunchTView/fetchTviewPlan.js +27 -27
- package/dist/LaunchTView/fetchTviewPlan.js.map +1 -1
- package/dist/LaunchTView/launchView.d.ts +25 -0
- package/dist/LaunchTView/launchView.js +20 -0
- package/dist/LaunchTView/launchView.js.map +1 -0
- package/dist/LaunchTView/readLayout.d.ts +85 -0
- package/dist/LaunchTView/readLayout.js +96 -0
- package/dist/LaunchTView/readLayout.js.map +1 -0
- package/dist/LaunchTView/repeats.d.ts +68 -0
- package/dist/LaunchTView/repeats.js +200 -0
- package/dist/LaunchTView/repeats.js.map +1 -0
- package/dist/LaunchTView/sampleTree.d.ts +37 -0
- package/dist/LaunchTView/sampleTree.js +65 -0
- package/dist/LaunchTView/sampleTree.js.map +1 -0
- package/dist/LaunchTView/tview.d.ts +67 -44
- package/dist/LaunchTView/tview.js +190 -121
- package/dist/LaunchTView/tview.js.map +1 -1
- package/dist/LaunchTView/useTviewMsa.d.ts +13 -9
- package/dist/LaunchTView/useTviewMsa.js +15 -11
- package/dist/LaunchTView/useTviewMsa.js.map +1 -1
- package/dist/TViewPanel/coords.d.ts +9 -1
- package/dist/TViewPanel/coords.js +22 -2
- package/dist/TViewPanel/coords.js.map +1 -1
- package/dist/TViewPanel/init.d.ts +56 -0
- package/dist/TViewPanel/init.js +59 -0
- package/dist/TViewPanel/init.js.map +1 -0
- package/dist/TViewPanel/model.d.ts +56 -40
- package/dist/TViewPanel/model.js +73 -51
- package/dist/TViewPanel/model.js.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/jbrowse-plugin-tview.umd.production.min.js +59 -21
- 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 +7 -3
- package/src/LaunchTView/TviewGetPlanRpc/TviewGetPlan.ts +264 -0
- package/src/LaunchTView/TviewGetPlanRpc/index.ts +14 -0
- package/src/LaunchTView/align.ts +343 -17
- package/src/LaunchTView/alleles.ts +132 -0
- package/src/LaunchTView/components/ArrayReport.tsx +64 -0
- package/src/LaunchTView/components/LaunchTViewDialog.tsx +122 -39
- package/src/LaunchTView/fetchTviewPlan.ts +42 -42
- package/src/LaunchTView/launchView.ts +50 -0
- package/src/LaunchTView/readLayout.ts +145 -0
- package/src/LaunchTView/repeats.ts +218 -0
- package/src/LaunchTView/sampleTree.ts +73 -0
- package/src/LaunchTView/tview.ts +259 -157
- package/src/LaunchTView/useTviewMsa.ts +20 -17
- package/src/TViewPanel/coords.ts +23 -1
- package/src/TViewPanel/init.ts +127 -0
- package/src/TViewPanel/model.ts +82 -61
- package/src/index.ts +5 -1
- package/src/version.ts +1 -1
|
@@ -1,75 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* - SPANNED_GAP: the read covers this reference position but aligns no base to
|
|
8
|
-
* it, i.e. a deletion, or padding in an insertion column
|
|
9
|
-
* - ABSENT: the read is not here at all, i.e. outside its bounds, or skipping
|
|
10
|
-
* over the position through an N (an intron, not a deleted allele)
|
|
11
|
-
*/
|
|
12
|
-
const SPANNED_GAP = '-';
|
|
13
|
-
const ABSENT = '.';
|
|
14
|
-
const cigarRegex = /([MIDNSHPX=])/;
|
|
15
|
-
const byStart = (a, b) => a.start - b.start;
|
|
16
|
-
export function parseCigar(cigar) {
|
|
17
|
-
return cigar.split(cigarRegex).slice(0, -1);
|
|
18
|
-
}
|
|
19
|
-
export function parseRead(feature, name) {
|
|
20
|
-
const seq = feature.get('seq');
|
|
21
|
-
const ops = parseCigar(feature.get('CIGAR'));
|
|
22
|
-
const start = feature.get('start');
|
|
23
|
-
const insertions = new Map();
|
|
24
|
-
let refChars = '';
|
|
25
|
-
let seqOffset = 0;
|
|
26
|
-
for (let i = 0; i < ops.length; i += 2) {
|
|
27
|
-
const len = +ops[i];
|
|
28
|
-
const op = ops[i + 1];
|
|
29
|
-
if (op === 'S') {
|
|
30
|
-
seqOffset += len;
|
|
31
|
-
}
|
|
32
|
-
else if (op === 'I') {
|
|
33
|
-
// consecutive I ops (e.g. 3M2I3I3M) land on the same reference position
|
|
34
|
-
const pos = start + refChars.length;
|
|
35
|
-
const prev = insertions.get(pos) ?? '';
|
|
36
|
-
insertions.set(pos, prev + seq.slice(seqOffset, seqOffset + len));
|
|
37
|
-
seqOffset += len;
|
|
38
|
-
}
|
|
39
|
-
else if (op === 'D') {
|
|
40
|
-
refChars += SPANNED_GAP.repeat(len);
|
|
41
|
-
}
|
|
42
|
-
else if (op === 'N') {
|
|
43
|
-
refChars += ABSENT.repeat(len);
|
|
44
|
-
}
|
|
45
|
-
else if (op === 'M' || op === 'X' || op === '=') {
|
|
46
|
-
refChars += seq.slice(seqOffset, seqOffset + len);
|
|
47
|
-
seqOffset += len;
|
|
48
|
-
}
|
|
49
|
-
// H and P consume neither the read sequence nor the reference
|
|
50
|
-
}
|
|
51
|
-
return { name, start, refChars, insertions };
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Reads are fetched by overlap, so they carry insertions on either side of the
|
|
55
|
-
* region. Those get no columns and are never rendered, so dropping them keeps
|
|
56
|
-
* the pairwise alignment below off the wasted sites entirely.
|
|
57
|
-
*/
|
|
58
|
-
export function clipInsertions(reads, start, end) {
|
|
59
|
-
return reads.map(read => ({
|
|
60
|
-
...read,
|
|
61
|
-
insertions: new Map([...read.insertions].filter(([pos]) => pos >= start && pos < end)),
|
|
62
|
-
}));
|
|
63
|
-
}
|
|
1
|
+
import { alignInsertionSite } from './align';
|
|
2
|
+
import { buildArrayBlocks } from './alleles';
|
|
3
|
+
import { ABSENT, SPANNED_GAP, byStart, clipInsertions, getReadNames, parseRead, } from './readLayout';
|
|
4
|
+
import { findReferenceArrays, mergeArrays } from './repeats';
|
|
5
|
+
import { newickSafe } from './sampleTree';
|
|
6
|
+
export { clipInsertions, parseCigar, parseRead } from './readLayout';
|
|
64
7
|
/**
|
|
65
8
|
* Mutually aligns the sequences inserted at each reference position, so reads
|
|
66
|
-
* sharing an insertion event line up inside it.
|
|
67
|
-
*
|
|
9
|
+
* sharing an insertion event line up inside it. Positions an array block has
|
|
10
|
+
* taken over are left alone: those bases are part of an allele the block
|
|
11
|
+
* already laid out, and giving them insertion columns as well would render
|
|
12
|
+
* them twice.
|
|
68
13
|
*/
|
|
69
|
-
export function alignInsertionColumns(reads) {
|
|
14
|
+
export function alignInsertionColumns(reads, ownedByArray) {
|
|
70
15
|
const byPos = new Map();
|
|
71
16
|
for (const read of reads) {
|
|
72
17
|
for (const [pos, ins] of read.insertions) {
|
|
18
|
+
if (ownedByArray.has(pos)) {
|
|
19
|
+
continue;
|
|
20
|
+
}
|
|
73
21
|
const seqs = byPos.get(pos);
|
|
74
22
|
if (seqs) {
|
|
75
23
|
seqs.push(ins);
|
|
@@ -79,113 +27,234 @@ export function alignInsertionColumns(reads) {
|
|
|
79
27
|
}
|
|
80
28
|
}
|
|
81
29
|
}
|
|
82
|
-
const
|
|
30
|
+
const aligned = new Map([...byPos].map(([pos, seqs]) => [pos, alignInsertionSite(seqs)]));
|
|
83
31
|
return reads.map(read => ({
|
|
84
32
|
...read,
|
|
85
33
|
insertions: new Map([...read.insertions].map(([pos, ins]) => [
|
|
86
34
|
pos,
|
|
87
|
-
|
|
35
|
+
aligned.get(pos)?.gapped.get(ins) ?? ins,
|
|
88
36
|
])),
|
|
89
37
|
}));
|
|
90
38
|
}
|
|
91
39
|
/** widest insertion any read has at each reference position (sparse) */
|
|
92
|
-
export function maxInsertionWidths(reads) {
|
|
40
|
+
export function maxInsertionWidths(reads, ownedByArray) {
|
|
93
41
|
const ret = new Map();
|
|
94
42
|
for (const read of reads) {
|
|
95
43
|
for (const [pos, ins] of read.insertions) {
|
|
96
|
-
|
|
44
|
+
if (!ownedByArray.has(pos)) {
|
|
45
|
+
ret.set(pos, Math.max(ret.get(pos) ?? 0, ins.length));
|
|
46
|
+
}
|
|
97
47
|
}
|
|
98
48
|
}
|
|
99
49
|
return ret;
|
|
100
50
|
}
|
|
51
|
+
function arrayStartIndex(arrays) {
|
|
52
|
+
return new Map(arrays.map(a => [a.start, a]));
|
|
53
|
+
}
|
|
101
54
|
/**
|
|
102
55
|
* Each reference position contributes its insertion columns (widest across all
|
|
103
56
|
* reads) followed by one reference column, so every row comes out the same
|
|
104
|
-
* length and stays aligned
|
|
57
|
+
* length and stays aligned — except where an array block takes over, and
|
|
58
|
+
* contributes one run of columns for the whole interval it covers.
|
|
105
59
|
*/
|
|
106
|
-
export function buildColumnLayout(start, end, insWidths) {
|
|
107
|
-
const
|
|
60
|
+
export function buildColumnLayout(start, end, insWidths, arrays = []) {
|
|
61
|
+
const byStartPos = arrayStartIndex(arrays);
|
|
62
|
+
const offsets = [];
|
|
108
63
|
let col = 0;
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
64
|
+
let pos = start;
|
|
65
|
+
while (pos < end) {
|
|
66
|
+
const array = byStartPos.get(pos);
|
|
67
|
+
if (array) {
|
|
68
|
+
const stop = Math.min(array.end, end);
|
|
69
|
+
offsets.push(col);
|
|
70
|
+
col += array.width;
|
|
71
|
+
for (let p = pos + 1; p < stop; p++) {
|
|
72
|
+
offsets.push(col);
|
|
73
|
+
}
|
|
74
|
+
pos = stop;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
offsets.push(col);
|
|
78
|
+
col += (insWidths.get(pos) ?? 0) + 1;
|
|
79
|
+
pos++;
|
|
80
|
+
}
|
|
112
81
|
}
|
|
113
|
-
|
|
82
|
+
offsets.push(col);
|
|
83
|
+
return { start, end, insWidths, arrays, offsets, totalColumns: col };
|
|
84
|
+
}
|
|
85
|
+
/** the array covering `pos`, when `pos` is strictly inside one */
|
|
86
|
+
function arrayContaining(arrays, pos) {
|
|
87
|
+
return arrays.find(a => a.start < pos && pos < a.end);
|
|
114
88
|
}
|
|
115
89
|
/**
|
|
116
|
-
* Lays a single
|
|
117
|
-
* fraction of the region, so the columns on either side
|
|
118
|
-
*
|
|
90
|
+
* Lays a single row out across the whole region. Rows are typically a tiny
|
|
91
|
+
* fraction of the region, so the columns on either side are filled in one shot
|
|
92
|
+
* from the offsets rather than walked position by position — which works over
|
|
93
|
+
* array blocks too, since the offsets already carry their width.
|
|
119
94
|
*/
|
|
120
95
|
export function renderRow(read, layout) {
|
|
121
|
-
const { start, end, insWidths, offsets, totalColumns } = layout;
|
|
96
|
+
const { start, end, insWidths, arrays, offsets, totalColumns } = layout;
|
|
97
|
+
const byStartPos = arrayStartIndex(arrays);
|
|
122
98
|
// a trailing insertion is keyed one past the last position the read spans
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const spanned = idx >= 0 && idx < read.refChars.length;
|
|
131
|
-
const refChar = spanned ? read.refChars[idx] : ABSENT;
|
|
132
|
-
const width = insWidths.get(pos) ?? 0;
|
|
133
|
-
if (width) {
|
|
134
|
-
// a read that is not really here pads the insertion the same way it
|
|
135
|
-
// pads the reference column, so an intron reads as one absence
|
|
136
|
-
const pad = refChar === ABSENT ? ABSENT : SPANNED_GAP;
|
|
137
|
-
const ins = read.insertions.get(pos) ?? '';
|
|
138
|
-
ret += ins + pad.repeat(width - ins.length);
|
|
139
|
-
}
|
|
140
|
-
ret += refChar;
|
|
141
|
-
}
|
|
142
|
-
ret += ABSENT.repeat(totalColumns - offsets[to - start]);
|
|
99
|
+
let from = Math.max(start, read.start);
|
|
100
|
+
let to = Math.min(end, read.start + read.refChars.length + 1);
|
|
101
|
+
// a row that begins or ends inside an array does not span it, so it gets no
|
|
102
|
+
// block; snapping past the block keeps the walk from emitting part of one
|
|
103
|
+
const startsInside = arrayContaining(arrays, from);
|
|
104
|
+
if (startsInside) {
|
|
105
|
+
from = Math.min(end, startsInside.end);
|
|
143
106
|
}
|
|
144
|
-
|
|
145
|
-
|
|
107
|
+
const endsInside = arrayContaining(arrays, to);
|
|
108
|
+
if (endsInside) {
|
|
109
|
+
to = endsInside.start;
|
|
146
110
|
}
|
|
147
|
-
|
|
111
|
+
if (to <= from) {
|
|
112
|
+
return ABSENT.repeat(totalColumns);
|
|
113
|
+
}
|
|
114
|
+
let ret = ABSENT.repeat(offsets[from - start]);
|
|
115
|
+
let pos = from;
|
|
116
|
+
while (pos < to) {
|
|
117
|
+
const array = byStartPos.get(pos);
|
|
118
|
+
if (array) {
|
|
119
|
+
const row = array.rowByName.get(read.name);
|
|
120
|
+
ret += row ?? SPANNED_GAP.repeat(array.width);
|
|
121
|
+
pos = Math.min(array.end, to);
|
|
122
|
+
continue;
|
|
123
|
+
}
|
|
124
|
+
const idx = pos - read.start;
|
|
125
|
+
const spanned = idx >= 0 && idx < read.refChars.length;
|
|
126
|
+
const refChar = spanned ? read.refChars[idx] : ABSENT;
|
|
127
|
+
const width = insWidths.get(pos) ?? 0;
|
|
128
|
+
if (width) {
|
|
129
|
+
// a read that is not really here pads the insertion the same way it
|
|
130
|
+
// pads the reference column, so an intron reads as one absence
|
|
131
|
+
const pad = refChar === ABSENT ? ABSENT : SPANNED_GAP;
|
|
132
|
+
const ins = read.insertions.get(pos) ?? '';
|
|
133
|
+
ret += ins + pad.repeat(width - ins.length);
|
|
134
|
+
}
|
|
135
|
+
ret += refChar;
|
|
136
|
+
pos++;
|
|
137
|
+
}
|
|
138
|
+
return ret + ABSENT.repeat(totalColumns - offsets[to - start]);
|
|
148
139
|
}
|
|
149
|
-
|
|
150
|
-
|
|
140
|
+
// A defline is truncated at its first space (msa-parsers' FastaMSA), so the
|
|
141
|
+
// count is joined on. `labelsAlignRight` puts it flush against the sequence.
|
|
142
|
+
const COPY_COUNT_SEPARATOR = '|';
|
|
143
|
+
/**
|
|
144
|
+
* What a row is called on screen. The one place `label` falls back to `name`,
|
|
145
|
+
* so the defline and the tree leaf cannot disagree about it — react-msaview
|
|
146
|
+
* joins them by string, and a row the tree names differently renders blank.
|
|
147
|
+
*/
|
|
148
|
+
export function rowLabel(read) {
|
|
149
|
+
return read.label ?? read.name;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Rows ordered longest-allele-first and labelled with their copy count.
|
|
153
|
+
*
|
|
154
|
+
* Copy number is the measurement at a tandem array, and reading it off where a
|
|
155
|
+
* row runs out is the thing the unit-per-block layout exists to avoid, so it is
|
|
156
|
+
* stated in the label. Ordering by it puts the alleles in a ladder, which is
|
|
157
|
+
* what makes one row's array comparable to the next at a glance. Rows that do
|
|
158
|
+
* not span the array keep genomic order, below the ones that do; the reference
|
|
159
|
+
* stays on top whatever its allele, since it is what the columns are named
|
|
160
|
+
* after rather than one of the observations.
|
|
161
|
+
*/
|
|
162
|
+
export function labelAndOrderByCopies(reads, array, referenceName) {
|
|
163
|
+
const rank = (read) => (read.name === referenceName ? 1 : 0);
|
|
164
|
+
return reads
|
|
165
|
+
.map(read => ({ read, copies: array.copiesByName.get(read.name) }))
|
|
166
|
+
.sort((a, b) => {
|
|
167
|
+
const byRef = rank(b.read) - rank(a.read);
|
|
168
|
+
if (byRef) {
|
|
169
|
+
return byRef;
|
|
170
|
+
}
|
|
171
|
+
if (a.copies === undefined || b.copies === undefined) {
|
|
172
|
+
return a.copies === b.copies
|
|
173
|
+
? byStart(a.read, b.read)
|
|
174
|
+
: a.copies === undefined
|
|
175
|
+
? 1
|
|
176
|
+
: -1;
|
|
177
|
+
}
|
|
178
|
+
return b.copies - a.copies || byStart(a.read, b.read);
|
|
179
|
+
})
|
|
180
|
+
.map(({ read, copies }) => copies === undefined
|
|
181
|
+
? read
|
|
182
|
+
: { ...read, label: `${read.name}${COPY_COUNT_SEPARATOR}n=${copies}` });
|
|
151
183
|
}
|
|
152
|
-
/**
|
|
153
|
-
function
|
|
154
|
-
const
|
|
155
|
-
return
|
|
156
|
-
const base = `${f.get('name')}${mateSuffix(f.get('flags'))}`;
|
|
157
|
-
const n = (counts.get(base) ?? 0) + 1;
|
|
158
|
-
counts.set(base, n);
|
|
159
|
-
return n === 1 ? base : `${base}_${n}`;
|
|
160
|
-
});
|
|
184
|
+
/** Widest spread of allele lengths, i.e. the array the reads disagree most about. */
|
|
185
|
+
function alleleSpread(array) {
|
|
186
|
+
const lengths = [...array.lengthByName.values()];
|
|
187
|
+
return lengths.length ? Math.max(...lengths) - Math.min(...lengths) : 0;
|
|
161
188
|
}
|
|
162
189
|
/**
|
|
163
190
|
* Works out the shape of the alignment without materializing it. Everything
|
|
164
191
|
* here is proportional to the sequence data, unlike the render, which is
|
|
165
192
|
* proportional to rows x columns and can be far larger.
|
|
166
193
|
*/
|
|
167
|
-
export function planTviewMsa({ features, refName, start, end, }) {
|
|
168
|
-
const names = getReadNames(features);
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
194
|
+
export function planTviewMsa({ features, refName, start, end, sequence, sampleOf, }) {
|
|
195
|
+
const names = getReadNames(features, sampleOf);
|
|
196
|
+
const parsed = features
|
|
197
|
+
.map((f, i) => parseRead(f, names[i], sampleOf?.(i)))
|
|
198
|
+
.sort(byStart);
|
|
199
|
+
// The reference is laid out as a row like any other, which is what lets it be
|
|
200
|
+
// one of the alleles an array block squares up rather than a thing the block
|
|
201
|
+
// has to be compared against afterwards.
|
|
202
|
+
const referenceName = sequence ? newickSafe(refName) : undefined;
|
|
203
|
+
const referenceRead = sequence
|
|
204
|
+
? {
|
|
205
|
+
name: referenceName,
|
|
206
|
+
start,
|
|
207
|
+
refChars: sequence.toUpperCase(),
|
|
208
|
+
insertions: new Map(),
|
|
209
|
+
}
|
|
210
|
+
: undefined;
|
|
211
|
+
const clipped = clipInsertions(referenceRead ? [referenceRead, ...parsed] : parsed, start, end);
|
|
212
|
+
const arrays = sequence
|
|
213
|
+
? buildArrayBlocks(clipped, mergeArrays(findReferenceArrays(sequence, start)))
|
|
214
|
+
: [];
|
|
215
|
+
const ownedByArray = new Set();
|
|
216
|
+
for (const array of arrays) {
|
|
217
|
+
for (let pos = array.start; pos <= array.end; pos++) {
|
|
218
|
+
ownedByArray.add(pos);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const aligned = alignInsertionColumns(clipped, ownedByArray);
|
|
222
|
+
// With several arrays in view the subject is the one the rows disagree most
|
|
223
|
+
// about, since ordering rows by two copy numbers at once is not a thing rows
|
|
224
|
+
// can do and an array every row agrees on orders nothing.
|
|
225
|
+
const subject = arrays.reduce((best, array) => best && alleleSpread(best) >= alleleSpread(array) ? best : array, undefined);
|
|
226
|
+
const reads = subject
|
|
227
|
+
? labelAndOrderByCopies(aligned, subject, referenceName)
|
|
228
|
+
: aligned;
|
|
229
|
+
const insWidths = maxInsertionWidths(reads, ownedByArray);
|
|
230
|
+
const layout = buildColumnLayout(start, end, insWidths, arrays);
|
|
172
231
|
return {
|
|
173
232
|
reads,
|
|
174
233
|
layout,
|
|
175
234
|
insertionWidths: [...insWidths.entries()].sort((a, b) => a[0] - b[0]),
|
|
235
|
+
arraySpans: arrays.map(a => [a.start, a.end, a.width]),
|
|
176
236
|
region: { refName, start, end },
|
|
177
237
|
cellCount: reads.length * layout.totalColumns,
|
|
238
|
+
arrays,
|
|
239
|
+
subject,
|
|
240
|
+
referenceName,
|
|
241
|
+
samples: [
|
|
242
|
+
...new Set(parsed.map(r => r.sample).filter(s => s !== undefined)),
|
|
243
|
+
],
|
|
178
244
|
};
|
|
179
245
|
}
|
|
180
246
|
export function renderTviewMsa({ reads, layout }) {
|
|
181
|
-
return reads.map(r => `>${r
|
|
247
|
+
return reads.map(r => `>${rowLabel(r)}\n${renderRow(r, layout)}\n`).join('');
|
|
182
248
|
}
|
|
183
249
|
export function buildTviewMsa(args) {
|
|
184
250
|
const plan = planTviewMsa(args);
|
|
185
251
|
return {
|
|
186
252
|
msa: renderTviewMsa(plan),
|
|
187
253
|
insertionWidths: plan.insertionWidths,
|
|
254
|
+
arraySpans: plan.arraySpans,
|
|
188
255
|
region: plan.region,
|
|
256
|
+
arrays: plan.arrays,
|
|
257
|
+
subject: plan.subject,
|
|
189
258
|
};
|
|
190
259
|
}
|
|
191
260
|
//# sourceMappingURL=tview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tview.js","sourceRoot":"","sources":["../../src/LaunchTView/tview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"tview.js","sourceRoot":"","sources":["../../src/LaunchTView/tview.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EACL,MAAM,EACN,WAAW,EACX,OAAO,EACP,cAAc,EACd,YAAY,EACZ,SAAS,GACV,MAAM,cAAc,C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,CAAA;AACH,CAAC"}
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import type { TviewInit } from '../TViewPanel/init';
|
|
2
|
+
import type { AbstractSessionModel } from '@jbrowse/core/util';
|
|
3
|
+
/**
|
|
4
|
+
* A preview of what a `TviewInit` resolves to, for the dialog to report before
|
|
5
|
+
* the view is opened.
|
|
6
|
+
*
|
|
7
|
+
* Resolved through the same two functions the view itself uses, so what the
|
|
8
|
+
* dialog states and what the view then builds cannot disagree.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useTviewMsa({ session, init, }: {
|
|
11
|
+
session: AbstractSessionModel;
|
|
12
|
+
init?: TviewInit;
|
|
13
|
+
}): import("swr").SWRResponse<import("./TviewGetPlanRpc").TviewPlanResult, any, {
|
|
10
14
|
revalidateOnFocus: boolean;
|
|
11
15
|
revalidateOnReconnect: boolean;
|
|
12
16
|
revalidateIfStale: boolean;
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
import { assembleLocString, getSession } from '@jbrowse/core/util';
|
|
2
1
|
import useSWR from 'swr';
|
|
3
|
-
import { fetchTviewPlan
|
|
2
|
+
import { fetchTviewPlan } from './fetchTviewPlan';
|
|
3
|
+
import { initRegion, initSources } from '../TViewPanel/init';
|
|
4
4
|
const staticSwrConfig = {
|
|
5
5
|
revalidateOnFocus: false,
|
|
6
6
|
revalidateOnReconnect: false,
|
|
7
7
|
revalidateIfStale: false,
|
|
8
8
|
shouldRetryOnError: false,
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A preview of what a `TviewInit` resolves to, for the dialog to report before
|
|
12
|
+
* the view is opened.
|
|
13
|
+
*
|
|
14
|
+
* Resolved through the same two functions the view itself uses, so what the
|
|
15
|
+
* dialog states and what the view then builds cannot disagree.
|
|
16
|
+
*/
|
|
17
|
+
export function useTviewMsa({ session, init, }) {
|
|
18
|
+
const region = init ? initRegion(session, init) : undefined;
|
|
19
|
+
const sources = init ? initSources(session, init) : undefined;
|
|
20
|
+
return useSWR(region && sources
|
|
21
|
+
? { tag: 'tview', loc: init.loc, tracks: init.tracks, region, sources }
|
|
22
|
+
: null, ({ region, sources }) => fetchTviewPlan({ session, sources, region }), staticSwrConfig);
|
|
19
23
|
}
|
|
20
24
|
//# sourceMappingURL=useTviewMsa.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTviewMsa.js","sourceRoot":"","sources":["../../src/LaunchTView/useTviewMsa.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"useTviewMsa.js","sourceRoot":"","sources":["../../src/LaunchTView/useTviewMsa.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,KAAK,CAAA;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAK5D,MAAM,eAAe,GAAG;IACtB,iBAAiB,EAAE,KAAK;IACxB,qBAAqB,EAAE,KAAK;IAC5B,iBAAiB,EAAE,KAAK;IACxB,kBAAkB,EAAE,KAAK;CAC1B,CAAA;AAED;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAC,EAC1B,OAAO,EACP,IAAI,GAIL;IACC,MAAM,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC3D,MAAM,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;IAC7D,OAAO,MAAM,CACX,MAAM,IAAI,OAAO;QACf,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,IAAK,CAAC,GAAG,EAAE,MAAM,EAAE,IAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE;QACzE,CAAC,CAAC,IAAI,EACR,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EACrE,eAAe,CAChB,CAAA;AACH,CAAC"}
|
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
* Inverse of the column layout built by buildTviewMsa: the alignment emits each
|
|
3
3
|
* reference position's insertion columns followed by its reference column, so a
|
|
4
4
|
* flat column -> reference position array recovers the mapping.
|
|
5
|
+
*
|
|
6
|
+
* An array block is the exception. Its columns are copies rather than positions,
|
|
7
|
+
* and a copy is not at any one reference base — the whole point of the block is
|
|
8
|
+
* that reads disagree about where the bases are. Its columns therefore ramp
|
|
9
|
+
* evenly across the interval the array covers, which is right at the two edges
|
|
10
|
+
* and an interpolation in between; hovering a copy lands in the array, which is
|
|
11
|
+
* the honest answer.
|
|
5
12
|
*/
|
|
6
|
-
export declare function buildColumnToRefPos({ start, end, insertionWidths, }: {
|
|
13
|
+
export declare function buildColumnToRefPos({ start, end, insertionWidths, arraySpans, }: {
|
|
7
14
|
start: number;
|
|
8
15
|
end: number;
|
|
9
16
|
insertionWidths: [number, number][];
|
|
17
|
+
arraySpans?: [number, number, number][];
|
|
10
18
|
}): number[];
|
|
11
19
|
/**
|
|
12
20
|
* react-msaview drops all-gap columns from the rendering when hideGaps is
|
|
@@ -2,16 +2,36 @@
|
|
|
2
2
|
* Inverse of the column layout built by buildTviewMsa: the alignment emits each
|
|
3
3
|
* reference position's insertion columns followed by its reference column, so a
|
|
4
4
|
* flat column -> reference position array recovers the mapping.
|
|
5
|
+
*
|
|
6
|
+
* An array block is the exception. Its columns are copies rather than positions,
|
|
7
|
+
* and a copy is not at any one reference base — the whole point of the block is
|
|
8
|
+
* that reads disagree about where the bases are. Its columns therefore ramp
|
|
9
|
+
* evenly across the interval the array covers, which is right at the two edges
|
|
10
|
+
* and an interpolation in between; hovering a copy lands in the array, which is
|
|
11
|
+
* the honest answer.
|
|
5
12
|
*/
|
|
6
|
-
export function buildColumnToRefPos({ start, end, insertionWidths, }) {
|
|
13
|
+
export function buildColumnToRefPos({ start, end, insertionWidths, arraySpans = [], }) {
|
|
7
14
|
const widths = new Map(insertionWidths);
|
|
15
|
+
const arrayAt = new Map(arraySpans.map(([s, e, w]) => [s, { end: e, w }]));
|
|
8
16
|
const ret = [];
|
|
9
|
-
|
|
17
|
+
let pos = start;
|
|
18
|
+
while (pos < end) {
|
|
19
|
+
const array = arrayAt.get(pos);
|
|
20
|
+
if (array) {
|
|
21
|
+
const stop = Math.min(array.end, end);
|
|
22
|
+
const span = stop - pos;
|
|
23
|
+
for (let i = 0; i < array.w; i++) {
|
|
24
|
+
ret.push(pos + Math.min(span - 1, Math.floor((i * span) / array.w)));
|
|
25
|
+
}
|
|
26
|
+
pos = stop;
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
10
29
|
const width = widths.get(pos) ?? 0;
|
|
11
30
|
for (let i = 0; i < width; i++) {
|
|
12
31
|
ret.push(pos);
|
|
13
32
|
}
|
|
14
33
|
ret.push(pos);
|
|
34
|
+
pos++;
|
|
15
35
|
}
|
|
16
36
|
return ret;
|
|
17
37
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"coords.js","sourceRoot":"","sources":["../../src/TViewPanel/coords.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"coords.js","sourceRoot":"","sources":["../../src/TViewPanel/coords.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,EAClC,KAAK,EACL,GAAG,EACH,eAAe,EACf,UAAU,GAAG,EAAE,GA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,IAAI,CAAC,GAAG,CAAC,CAAA;QACb,GAAG,EAAE,CAAA;IACP,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CAAC,MAAgB,EAAE,GAAW;IAC/D,IAAI,GAAG,GAAG,GAAG,CAAA;IACb,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;YACjB,GAAG,EAAE,CAAA;QACP,CAAC;aAAM,CAAC;YACN,MAAK;QACP,CAAC;IACH,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TviewSource } from '../LaunchTView/fetchTviewPlan';
|
|
2
|
+
import type { AbstractSessionModel } from '@jbrowse/core/util';
|
|
3
|
+
/**
|
|
4
|
+
* One alignment file the view reads, and optionally the name to group its rows
|
|
5
|
+
* under. A bare trackId is the same thing with the name left to the track.
|
|
6
|
+
*/
|
|
7
|
+
export type TviewTrackInit = string | {
|
|
8
|
+
trackId: string;
|
|
9
|
+
sample?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Everything a tview is: a locus, an assembly, and the alignment files to read
|
|
13
|
+
* it from.
|
|
14
|
+
*
|
|
15
|
+
* The view is declared with this and derives the rest, in the shape
|
|
16
|
+
* LinearGenomeView's `init` uses. Two things follow from that which are worth
|
|
17
|
+
* saying out loud:
|
|
18
|
+
*
|
|
19
|
+
* - A session can **author** a tview. `{ type: 'TView', init: { … } }` in a
|
|
20
|
+
* defaultSession opens one with no click path — as does the flat form of the
|
|
21
|
+
* same keys in a session spec URL, which is what makes a repeat locus a link.
|
|
22
|
+
* - There is one code path. Launching from the track menu, restoring a saved
|
|
23
|
+
* session and following a link all end up applying the same blob, so the
|
|
24
|
+
* launch dialog does not build the view — it names it.
|
|
25
|
+
*
|
|
26
|
+
* Unlike LinearGenomeView's, this init is **kept, not cleared**. What it
|
|
27
|
+
* resolves to is a multiple alignment held as one string, which react-msaview
|
|
28
|
+
* drops from snapshots past 50kb and has no file to reload from; the blob is
|
|
29
|
+
* both smaller than what it produces and the only durable statement of what the
|
|
30
|
+
* view is.
|
|
31
|
+
*/
|
|
32
|
+
export interface TviewInit {
|
|
33
|
+
/** assembly the locus and the tracks belong to */
|
|
34
|
+
assembly: string;
|
|
35
|
+
/** locstring, e.g. `chrX:146,993,530..146,993,670` */
|
|
36
|
+
loc: string;
|
|
37
|
+
/** the alignment files to draw rows from, in order */
|
|
38
|
+
tracks: TviewTrackInit[];
|
|
39
|
+
}
|
|
40
|
+
export declare const initKeys: Set<string>;
|
|
41
|
+
/** the region `init.loc` names, or undefined until the assembly can parse it */
|
|
42
|
+
export declare function initRegion(session: AbstractSessionModel, init: TviewInit): {
|
|
43
|
+
assemblyName: string;
|
|
44
|
+
refName: string;
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
} | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* The sources `init.tracks` names, or undefined until every one of them
|
|
50
|
+
* resolves. All or nothing: a partial set comes back with samples missing and
|
|
51
|
+
* nothing on screen says any were.
|
|
52
|
+
*
|
|
53
|
+
* Whether the names are *used* is decided here and only here — one file's rows
|
|
54
|
+
* need no prefix, and would gain a tree of one clade drawn beside a list.
|
|
55
|
+
*/
|
|
56
|
+
export declare function initSources(session: AbstractSessionModel, init: TviewInit): TviewSource[] | undefined;
|