jbrowse-plugin-tview 2.0.6 → 2.2.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 +222 -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 +106 -9
- package/dist/LaunchTView/align.js +349 -15
- package/dist/LaunchTView/align.js.map +1 -1
- package/dist/LaunchTView/alleles.d.ts +83 -0
- package/dist/LaunchTView/alleles.js +180 -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/repeatStats.d.ts +56 -0
- package/dist/LaunchTView/repeatStats.js +109 -0
- package/dist/LaunchTView/repeatStats.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 +193 -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 +109 -93
- 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 +25 -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 +9 -3
- package/src/LaunchTView/TviewGetPlanRpc/TviewGetPlan.ts +264 -0
- package/src/LaunchTView/TviewGetPlanRpc/index.ts +14 -0
- package/src/LaunchTView/align.ts +406 -17
- package/src/LaunchTView/alleles.ts +229 -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/repeatStats.ts +170 -0
- package/src/LaunchTView/repeats.ts +218 -0
- package/src/LaunchTView/sampleTree.ts +73 -0
- package/src/LaunchTView/tview.ts +265 -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
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { alignToUnit, unitIdentity } from './align';
|
|
2
|
+
const SPANNED_GAP = '-';
|
|
3
|
+
const ABSENT = '.';
|
|
4
|
+
/**
|
|
5
|
+
* What one row has between two reference positions: its matched bases, plus
|
|
6
|
+
* whatever it inserted inside, minus whatever it deleted.
|
|
7
|
+
*
|
|
8
|
+
* This is the measurement the insertion-anchored reading cannot make. An indel
|
|
9
|
+
* inside an array has no unique placement, so two reads carrying the same allele
|
|
10
|
+
* can disagree about which reference position it is inserted at and by how much;
|
|
11
|
+
* summed over the interval, those choices cancel and both come back the same
|
|
12
|
+
* length. Undefined when the row does not reach both edges — copies cannot be
|
|
13
|
+
* counted from a read that stops inside the array, and guessing from a partial
|
|
14
|
+
* one is how a truncated read reads as a contracted allele.
|
|
15
|
+
*/
|
|
16
|
+
export function extractAllele(read, start, end) {
|
|
17
|
+
const last = read.start + read.refChars.length;
|
|
18
|
+
if (read.start > start || last < end) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
let ret = '';
|
|
22
|
+
for (let pos = start; pos <= end; pos++) {
|
|
23
|
+
ret += read.insertions.get(pos) ?? '';
|
|
24
|
+
if (pos < end) {
|
|
25
|
+
const char = read.refChars[pos - read.start];
|
|
26
|
+
if (char === ABSENT) {
|
|
27
|
+
// an N op skips the position rather than deleting it, so the row has no
|
|
28
|
+
// allele here at all rather than a shorter one
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
if (char !== SPANNED_GAP) {
|
|
32
|
+
ret += char;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
/** Reference positions an array owns, including the insertion slot at its right edge. */
|
|
39
|
+
export function arrayInsertionKeys(array) {
|
|
40
|
+
const ret = [];
|
|
41
|
+
for (let pos = array.start; pos <= array.end; pos++) {
|
|
42
|
+
ret.push(pos);
|
|
43
|
+
}
|
|
44
|
+
return ret;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* How far outside an array an insertion of its own unit can be anchored, in
|
|
48
|
+
* copies. An indel made of repeat units has no unique placement inside the
|
|
49
|
+
* array, and the flanking bases let the aligner carry it a little further still
|
|
50
|
+
* — but only about a copy, because past that the sequence either side stops
|
|
51
|
+
* matching. Every misplaced repeat allele in the trio sits within one copy of
|
|
52
|
+
* the edge: ATXN3's at 1bp, FMR1's at 2bp of a 3bp unit, ABCA7's at 19bp of a
|
|
53
|
+
* 25bp one.
|
|
54
|
+
*/
|
|
55
|
+
const ABSORB_COPIES = 1;
|
|
56
|
+
/**
|
|
57
|
+
* How much of the inserted sequence the array's unit has to explain before the
|
|
58
|
+
* insertion counts as part of the array. The repeat alleles the aligner
|
|
59
|
+
* anchored just outside an array in the trio score 0.94-1.00 here and unrelated
|
|
60
|
+
* sequence scores 0.67 or below, so this sits in open space rather than on a
|
|
61
|
+
* boundary.
|
|
62
|
+
*/
|
|
63
|
+
const ABSORB_IDENTITY = 0.8;
|
|
64
|
+
/**
|
|
65
|
+
* Widen each array to cover the insertions the aligner anchored just outside it
|
|
66
|
+
* that are made of the array's own unit.
|
|
67
|
+
*
|
|
68
|
+
* An allele is measured over a reference interval, which fixes the "one array
|
|
69
|
+
* reports as several sites" problem for indels the aligner placed *inside* the
|
|
70
|
+
* interval. It does not fix the ones it placed just outside: an aligner is free
|
|
71
|
+
* to anchor an expansion at the base before the array starts, and there the
|
|
72
|
+
* insertion is not part of any allele — it is left to become its own run of
|
|
73
|
+
* insertion columns, and the read it belongs to is measured as if it carried
|
|
74
|
+
* the reference allele. Both halves of that are wrong, and they are not rare:
|
|
75
|
+
* at ATXN3 the aligner anchored 60 of 162 reads' expansions one base outside
|
|
76
|
+
* the array, and at ABCA7 a 1207bp allele 19 bases outside.
|
|
77
|
+
*
|
|
78
|
+
* What is absorbed is decided by the inserted sequence, not by the count of
|
|
79
|
+
* reads carrying it — a single read's expansion is as real as fifty, and the
|
|
80
|
+
* whole point of measuring over an interval is that it does not need a vote.
|
|
81
|
+
* Widening the interval costs every row the few reference bases in between,
|
|
82
|
+
* which they all pay equally, so the counts stay comparable.
|
|
83
|
+
*/
|
|
84
|
+
export function absorbAdjacentInsertions(reads, arrays) {
|
|
85
|
+
const ordered = [...arrays].sort((a, b) => a.start - b.start);
|
|
86
|
+
// the widened end of the array to the left, which the next one may not reach
|
|
87
|
+
let previousEnd = -Infinity;
|
|
88
|
+
return ordered.map((array, i) => {
|
|
89
|
+
const margin = ABSORB_COPIES * array.period;
|
|
90
|
+
// Two arrays that met at a position would read the same insertion slot
|
|
91
|
+
// twice — once as each one's allele — so they are held apart on both
|
|
92
|
+
// sides: leftwards off whatever the previous array grew to, rightwards off
|
|
93
|
+
// where the next one starts, which is as far left as that one can be
|
|
94
|
+
// pushed in turn. Neither bound can cross the array's own edges, since
|
|
95
|
+
// mergeArrays has already left a gap between every pair.
|
|
96
|
+
const floor = Math.max(array.start - margin, previousEnd + 1);
|
|
97
|
+
const ceiling = Math.min(array.end + margin, (ordered[i + 1]?.start ?? Infinity) - 1);
|
|
98
|
+
let { start, end } = array;
|
|
99
|
+
// memoized per distinct insert: one locus routinely has dozens of reads
|
|
100
|
+
// carrying the same allele at the same site
|
|
101
|
+
const belongs = new Map();
|
|
102
|
+
const isUnit = (ins) => {
|
|
103
|
+
let ret = belongs.get(ins);
|
|
104
|
+
if (ret === undefined) {
|
|
105
|
+
ret = unitIdentity(ins, array.unit) >= ABSORB_IDENTITY;
|
|
106
|
+
belongs.set(ins, ret);
|
|
107
|
+
}
|
|
108
|
+
return ret;
|
|
109
|
+
};
|
|
110
|
+
for (const read of reads) {
|
|
111
|
+
for (const [pos, ins] of read.insertions) {
|
|
112
|
+
// a whole copy at least: a base or two of read error next to an array
|
|
113
|
+
// says nothing about where the array ends, and moving the interval for
|
|
114
|
+
// it would lay flanking sequence out as repeat copies
|
|
115
|
+
if (ins.length < array.period ||
|
|
116
|
+
pos < floor ||
|
|
117
|
+
pos > ceiling ||
|
|
118
|
+
(pos >= array.start && pos <= array.end) ||
|
|
119
|
+
!isUnit(ins)) {
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
start = Math.min(start, pos);
|
|
123
|
+
// an insertion is keyed to the position it precedes, and extractAllele
|
|
124
|
+
// reads the slot at `end`, so covering it means reaching that position
|
|
125
|
+
end = Math.max(end, pos);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
previousEnd = end;
|
|
129
|
+
return { ...array, start, end };
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Lay every row's allele out unit-per-block, one block per array.
|
|
134
|
+
*
|
|
135
|
+
* Arrays whose alleles are all one length still get a block: squaring the copies
|
|
136
|
+
* up against each other is what turns "this row is 63 bases long" into "this row
|
|
137
|
+
* has 21 copies and the 12th one differs", and that is true whether or not the
|
|
138
|
+
* rows disagree.
|
|
139
|
+
*/
|
|
140
|
+
export function buildArrayBlocks(reads, arrays) {
|
|
141
|
+
const ret = [];
|
|
142
|
+
for (const array of arrays) {
|
|
143
|
+
const alleleByName = new Map();
|
|
144
|
+
for (const read of reads) {
|
|
145
|
+
const allele = extractAllele(read, array.start, array.end);
|
|
146
|
+
if (allele !== undefined) {
|
|
147
|
+
alleleByName.set(read.name, allele);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const aligned = alignToUnit([...alleleByName.values()], array.unit);
|
|
151
|
+
if (!aligned) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const rowByName = new Map();
|
|
155
|
+
const copiesByName = new Map();
|
|
156
|
+
const lengthByName = new Map();
|
|
157
|
+
for (const [name, allele] of alleleByName) {
|
|
158
|
+
const row = aligned.gapped.get(allele);
|
|
159
|
+
const copies = aligned.copies.get(allele);
|
|
160
|
+
if (row !== undefined && copies !== undefined) {
|
|
161
|
+
rowByName.set(name, row);
|
|
162
|
+
copiesByName.set(name, copies);
|
|
163
|
+
lengthByName.set(name, allele.length);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
ret.push({
|
|
167
|
+
start: array.start,
|
|
168
|
+
end: array.end,
|
|
169
|
+
period: aligned.period,
|
|
170
|
+
unit: array.unit,
|
|
171
|
+
width: aligned.unitWidths.reduce((a, b) => a + b, 0),
|
|
172
|
+
unitWidths: aligned.unitWidths,
|
|
173
|
+
rowByName,
|
|
174
|
+
copiesByName,
|
|
175
|
+
lengthByName,
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return ret;
|
|
179
|
+
}
|
|
180
|
+
//# sourceMappingURL=alleles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"alleles.js","sourceRoot":"","sources":["../../src/LaunchTView/alleles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAkCnD,MAAM,WAAW,GAAG,GAAG,CAAA;AACvB,MAAM,MAAM,GAAG,GAAG,CAAA;AAElB;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,aAAa,CAAC,IAAgB,EAAE,KAAa,EAAE,GAAW;IACxE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAA;IAC9C,IAAI,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,GAAG,EAAE,CAAC;QACrC,OAAO,SAAS,CAAA;IAClB,CAAC;IACD,IAAI,GAAG,GAAG,EAAE,CAAA;IACZ,KAAK,IAAI,GAAG,GAAG,KAAK,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC;QACxC,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAA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Y,GAAG,IAAI,GAAG,EAAkB,CAAA;QAC9C,KAAK,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;YAC1C,MAAM,GAAG,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACzC,IAAI,GAAG,KAAK,SAAS,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC9C,SAAS,CAAC,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;gBACxB,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;gBAC9B,YAAY,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAA;YACvC,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAI,CAAC;YACP,KAAK,EAAE,KAAK,CAAC,KAAK;YAClB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,KAAK,EAAE,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YACpD,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,SAAS;YACT,YAAY;YACZ,YAAY;SACb,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { TviewPlanResult } from '../TviewGetPlanRpc';
|
|
3
|
+
/**
|
|
4
|
+
* What the reads say about the arrays before the view is opened, since the
|
|
5
|
+
* number is often the whole reason for opening it and a picture of 400 columns
|
|
6
|
+
* is a slow way to read one off.
|
|
7
|
+
*/
|
|
8
|
+
export default function ArrayReport({ data }: {
|
|
9
|
+
data: TviewPlanResult;
|
|
10
|
+
}): React.JSX.Element | null;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Typography } from '@mui/material';
|
|
3
|
+
/** allele lengths seen, commonest first, as `63bp x12` */
|
|
4
|
+
function alleleTally(lengths) {
|
|
5
|
+
const counts = new Map();
|
|
6
|
+
for (const [, length] of lengths) {
|
|
7
|
+
counts.set(length, (counts.get(length) ?? 0) + 1);
|
|
8
|
+
}
|
|
9
|
+
return [...counts]
|
|
10
|
+
.sort((a, b) => b[1] - a[1] || a[0] - b[0])
|
|
11
|
+
.map(([length, n]) => `${length}bp x${n}`);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* What the reads say about the arrays before the view is opened, since the
|
|
15
|
+
* number is often the whole reason for opening it and a picture of 400 columns
|
|
16
|
+
* is a slow way to read one off.
|
|
17
|
+
*/
|
|
18
|
+
export default function ArrayReport({ data }) {
|
|
19
|
+
const { arrays, subjectIndex, region } = data;
|
|
20
|
+
const subject = subjectIndex === undefined ? undefined : arrays[subjectIndex];
|
|
21
|
+
if (!subject) {
|
|
22
|
+
return arrays.length ? null : (React.createElement(Typography, { variant: "body2" }, "No tandem array in the reference here, so the reads are laid out base by base."));
|
|
23
|
+
}
|
|
24
|
+
const copies = subject.copies;
|
|
25
|
+
return (React.createElement(React.Fragment, null,
|
|
26
|
+
React.createElement(Typography, { variant: "subtitle2" },
|
|
27
|
+
"Tandem array at ",
|
|
28
|
+
region.refName,
|
|
29
|
+
":",
|
|
30
|
+
subject.start.toLocaleString('en-US'),
|
|
31
|
+
"-",
|
|
32
|
+
subject.end.toLocaleString('en-US'),
|
|
33
|
+
", ",
|
|
34
|
+
subject.period,
|
|
35
|
+
"bp unit",
|
|
36
|
+
' ',
|
|
37
|
+
subject.unit),
|
|
38
|
+
React.createElement(Typography, { variant: "body2" },
|
|
39
|
+
copies.length,
|
|
40
|
+
" of ",
|
|
41
|
+
data.rowCount,
|
|
42
|
+
" rows span it end to end and carry",
|
|
43
|
+
' ',
|
|
44
|
+
Math.min(...copies.map(c => c[1])),
|
|
45
|
+
"\u2013",
|
|
46
|
+
Math.max(...copies.map(c => c[1])),
|
|
47
|
+
" copies. Allele lengths:",
|
|
48
|
+
' ',
|
|
49
|
+
alleleTally(subject.lengths).join(', '),
|
|
50
|
+
"."),
|
|
51
|
+
React.createElement(Typography, { variant: "body2" }, "Each copy gets its own block of columns, so one divergent copy shows up as a column rather than shifting every copy after it. Blocks are array order, not homology: copies are counted from the left edge, and arrays expand and contract anywhere inside themselves, so the 9th copy of one row need not be the 9th of another. Read down a row, not across two."),
|
|
52
|
+
arrays.length > 1 ? (React.createElement(Typography, { variant: "body2" },
|
|
53
|
+
arrays.length - 1,
|
|
54
|
+
" shorter",
|
|
55
|
+
' ',
|
|
56
|
+
arrays.length === 2 ? 'array is' : 'arrays are',
|
|
57
|
+
" also laid out per copy; rows are ordered by this one.")) : null));
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=ArrayReport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ArrayReport.js","sourceRoot":"","sources":["../../../src/LaunchTView/components/ArrayReport.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAI1C,0DAA0D;AAC1D,SAAS,WAAW,CAAC,OAA2B;IAC9C,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,KAAK,MAAM,CAAC,EAAE,MAAM,CAAC,IAAI,OAAO,EAAE,CAAC;QACjC,MAAM,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IACnD,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC;SACf,IAAI,CA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E,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;YAClC,IAAI,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;;YAA0B,GAAG;YAC/D,WAAW,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;gBAC7B;QACb,oBAAC,UAAU,IAAC,OAAO,EAAC,OAAO,wWAMd;QACZ,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CACnB,oBAAC,UAAU,IAAC,OAAO,EAAC,OAAO;YACxB,MAAM,CAAC,MAAM,GAAG,CAAC;;YAAU,GAAG;YAC9B,MAAM,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,YAAY;qEAErC,CACd,CAAC,CAAC,CAAC,IAAI,CACP,CACJ,CAAA;AACH,CAAC"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
2
|
import { getConf } from '@jbrowse/core/configuration';
|
|
3
3
|
import { Dialog, ErrorMessage } from '@jbrowse/core/ui';
|
|
4
4
|
import { assembleLocString, getContainingView, getSession, } from '@jbrowse/core/util';
|
|
5
|
-
import { Button, DialogActions, DialogContent } from '@mui/material';
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
5
|
+
import { Button, Checkbox, DialogActions, DialogContent, FormControlLabel, Typography, } from '@mui/material';
|
|
6
|
+
import ArrayReport from './ArrayReport';
|
|
7
|
+
import { MAX_BP } from '../limits';
|
|
8
8
|
import { useTviewMsa } from '../useTviewMsa';
|
|
9
|
+
// how much of the alignment the default column width aims to put on screen
|
|
10
|
+
const FIT_WIDTH_PX = 3000;
|
|
11
|
+
function trackLabel(track) {
|
|
12
|
+
return (getConf(track, 'name') || getConf(track, 'trackId'));
|
|
13
|
+
}
|
|
14
|
+
/** every alignments track open in the same view, the launching one first */
|
|
15
|
+
function peerTracks(view, model) {
|
|
16
|
+
const alignments = view.tracks.filter(track => track.displays.some((display) => display.type === 'LinearAlignmentsDisplay'));
|
|
17
|
+
return [model, ...alignments.filter(t => t.id !== model.id)];
|
|
18
|
+
}
|
|
9
19
|
export default function LaunchTViewDialog({ handleClose, model, }) {
|
|
10
20
|
const view = getContainingView(model);
|
|
11
21
|
const session = getSession(model);
|
|
12
22
|
const block = view.dynamicBlocks.contentBlocks[0];
|
|
13
|
-
// assemblyName is required: the RPC uses it to map the view's refName onto
|
|
14
|
-
// whatever the file calls that sequence (refNameAliases)
|
|
15
23
|
const region = block
|
|
16
24
|
? {
|
|
17
25
|
assemblyName: block.assemblyName,
|
|
@@ -22,60 +30,89 @@ export default function LaunchTViewDialog({ handleClose, model, }) {
|
|
|
22
30
|
: undefined;
|
|
23
31
|
const width = region ? region.end - region.start : 0;
|
|
24
32
|
const tooWide = width > MAX_BP;
|
|
33
|
+
const candidates = peerTracks(view, model);
|
|
34
|
+
// the launching track is always in; the others are opt-in, because pulling
|
|
35
|
+
// every open pileup into one alignment is a much bigger fetch than the menu
|
|
36
|
+
// item that got here suggests
|
|
37
|
+
const [extra, setExtra] = useState([]);
|
|
38
|
+
const chosen = candidates.filter(t => t.id === model.id || extra.includes(t.id));
|
|
39
|
+
// The dialog's whole output. Everything below either previews what this
|
|
40
|
+
// resolves to or hands it to a view, so what the button opens is the same
|
|
41
|
+
// blob a session could have been authored with.
|
|
42
|
+
const init = region
|
|
43
|
+
? {
|
|
44
|
+
assembly: region.assemblyName,
|
|
45
|
+
loc: assembleLocString(region),
|
|
46
|
+
tracks: chosen.map(t => ({
|
|
47
|
+
trackId: getConf(t, 'trackId'),
|
|
48
|
+
sample: trackLabel(t),
|
|
49
|
+
})),
|
|
50
|
+
}
|
|
51
|
+
: undefined;
|
|
25
52
|
const { data, error, isLoading } = useTviewMsa({
|
|
26
|
-
|
|
27
|
-
|
|
53
|
+
session,
|
|
54
|
+
init: tooWide ? undefined : init,
|
|
28
55
|
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
56
|
+
// 10 is comfortable for an ordinary pileup, but an unrolled tandem array runs
|
|
57
|
+
// to hundreds of columns and at 10 almost none of it is on screen at once.
|
|
58
|
+
// Fits the alignment to roughly two screen-widths; a no-op for the narrow
|
|
59
|
+
// regions that already fitted.
|
|
60
|
+
const totalColumns = data?.columnCount ?? 0;
|
|
61
|
+
const colWidth = totalColumns
|
|
62
|
+
? Math.max(1, Math.min(10, Math.floor(FIT_WIDTH_PX / totalColumns)))
|
|
63
|
+
: 10;
|
|
35
64
|
return (React.createElement(Dialog, { maxWidth: "xl", title: "Launch tview", onClose: () => {
|
|
36
65
|
handleClose();
|
|
37
66
|
}, open: true },
|
|
38
67
|
React.createElement(DialogContent, null,
|
|
39
|
-
React.createElement(
|
|
68
|
+
React.createElement(Typography, null,
|
|
40
69
|
"Create a view similar to \"samtools tview\" for the reads in the current region: ",
|
|
41
|
-
|
|
42
|
-
|
|
70
|
+
init?.loc ?? 'Unknown'),
|
|
71
|
+
candidates.length > 1 ? (React.createElement("div", null,
|
|
72
|
+
React.createElement(Typography, { variant: "subtitle2" }, "Include reads from other alignment tracks in this view"),
|
|
73
|
+
candidates.slice(1).map(track => (React.createElement(FormControlLabel, { key: track.id, control: React.createElement(Checkbox, { checked: extra.includes(track.id), onChange: event => {
|
|
74
|
+
setExtra(event.target.checked
|
|
75
|
+
? [...extra, track.id]
|
|
76
|
+
: extra.filter(id => id !== track.id));
|
|
77
|
+
} }), label: trackLabel(track) }))))) : null,
|
|
78
|
+
tooWide ? (React.createElement(Typography, null,
|
|
43
79
|
"Region is ",
|
|
44
80
|
width.toLocaleString('en-US'),
|
|
45
81
|
"bp, wider than the",
|
|
46
82
|
' ',
|
|
47
83
|
MAX_BP.toLocaleString('en-US'),
|
|
48
|
-
"bp limit. Zoom in and try again.")) : error ? (React.createElement(ErrorMessage, { error: error })) : isLoading ? (React.createElement(
|
|
84
|
+
"bp limit. Zoom in and try again.")) : error ? (React.createElement(ErrorMessage, { error: error })) : isLoading ? (React.createElement(Typography, null, "Loading...")) : data?.tooLarge ? (React.createElement(Typography, null,
|
|
49
85
|
data.rowCount.toLocaleString('en-US'),
|
|
50
|
-
"
|
|
86
|
+
" rows over",
|
|
51
87
|
' ',
|
|
52
|
-
data.
|
|
88
|
+
data.columnCount.toLocaleString('en-US'),
|
|
53
89
|
" columns is",
|
|
54
90
|
' ',
|
|
55
|
-
data.
|
|
56
|
-
" cells,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
91
|
+
data.cellCount.toLocaleString('en-US'),
|
|
92
|
+
" cells, which is too large to render. Zoom in and try again.")) : data ? (React.createElement(React.Fragment, null,
|
|
93
|
+
React.createElement(Typography, null,
|
|
94
|
+
data.rowCount,
|
|
95
|
+
" rows",
|
|
96
|
+
data.referenceName
|
|
97
|
+
? ' (the reference plus every read with sequence)'
|
|
98
|
+
: ' of reads with sequence data',
|
|
99
|
+
data.samples.length > 1
|
|
100
|
+
? `, from ${data.samples.length} tracks`
|
|
101
|
+
: ''),
|
|
102
|
+
React.createElement(ArrayReport, { data: data }))) : (React.createElement(Typography, null, "No region is currently visible."))),
|
|
62
103
|
React.createElement(DialogActions, null,
|
|
63
|
-
React.createElement(Button, { variant: "contained", color: "primary", disabled: !data?.
|
|
64
|
-
if (
|
|
104
|
+
React.createElement(Button, { variant: "contained", color: "primary", disabled: !data?.msa || !init, onClick: () => {
|
|
105
|
+
if (init) {
|
|
65
106
|
session.addView('TView', {
|
|
66
107
|
type: 'TView',
|
|
67
|
-
displayName,
|
|
68
|
-
|
|
108
|
+
displayName: init.loc,
|
|
109
|
+
init,
|
|
110
|
+
colWidth,
|
|
69
111
|
rowHeight: 12,
|
|
70
112
|
labelsAlignRight: true,
|
|
71
113
|
colorSchemeName: 'jbrowse_dna',
|
|
114
|
+
drawTree: init.tracks.length > 1,
|
|
72
115
|
connectedViewId: view.id,
|
|
73
|
-
msaRegion: data.plan.region,
|
|
74
|
-
insertionWidths: data.plan.insertionWidths,
|
|
75
|
-
msaSource,
|
|
76
|
-
data: {
|
|
77
|
-
msa: renderTviewMsa(data.plan),
|
|
78
|
-
},
|
|
79
116
|
});
|
|
80
117
|
}
|
|
81
118
|
handleClose();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LaunchTViewDialog.js","sourceRoot":"","sources":["../../../src/LaunchTView/components/LaunchTViewDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;
|
|
1
|
+
{"version":3,"file":"LaunchTViewDialog.js","sourceRoot":"","sources":["../../../src/LaunchTView/components/LaunchTViewDialog.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEvC,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAA;AACrD,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EACL,iBAAiB,EACjB,iBAAiB,EACjB,UAAU,GACX,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EACL,MAAM,EACN,QAAQ,EACR,aAAa,EACb,aAAa,EACb,gBAAgB,EAChB,UAAU,GACX,MAAM,eAAe,CAAA;AAEtB,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAM5C,2EAA2E;AAC3E,MAAM,YAAY,GAAG,IAAI,CAAA;AAEzB,SAAS,UAAU,CAAC,KAAyB;IAC3C,OAAO,CACJ,OAAO,CAAC,KAAK,EAAE,MAAM,CAAY,IAAK,OAAO,CAAC,KAAK,EAAE,SAAS,CAAY,CAC5E,CAAA;AACH,CAAC;AAED,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AAe,EAAE,IAAI,CAAC,EAAE;yBACzB,CAAC,CAAA;oBACJ,CAAC;oBACD,WAAW,EAAE,CAAA;gBACf,CAAC,aAGM;YACT,oBAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,WAAW,EACjB,OAAO,EAAE,GAAG,EAAE;oBACZ,WAAW,EAAE,CAAA;gBACf,CAAC,aAGM,CACK,CACT,CACV,CAAA;AACH,CAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import type { TviewPlanResult } from './TviewGetPlanRpc';
|
|
1
2
|
import type { AnyConfigurationModel } from '@jbrowse/core/configuration';
|
|
2
|
-
import type { AbstractSessionModel
|
|
3
|
+
import type { AbstractSessionModel } from '@jbrowse/core/util';
|
|
3
4
|
/** the RPC needs assemblyName to resolve refNameAliases for the file */
|
|
4
5
|
export interface FetchRegion {
|
|
5
6
|
assemblyName: string;
|
|
@@ -7,12 +8,13 @@ export interface FetchRegion {
|
|
|
7
8
|
start: number;
|
|
8
9
|
end: number;
|
|
9
10
|
}
|
|
10
|
-
/**
|
|
11
|
+
/** one track's worth of rows, and the name they are grouped under */
|
|
11
12
|
export interface TviewSource {
|
|
12
13
|
adapterConfig: unknown;
|
|
13
|
-
|
|
14
|
+
/** the label rows from this file carry; omitted when there is only one */
|
|
15
|
+
sample?: string;
|
|
16
|
+
trackId: string;
|
|
14
17
|
}
|
|
15
|
-
export declare function sourceFromTrack(track: AbstractTrackModel): TviewSource;
|
|
16
18
|
/**
|
|
17
19
|
* The trackId -> config index, whose shape has changed across hosts still in
|
|
18
20
|
* the wild: v4.0.0 exposes a `tracksById` getter, v4.1-v4.3 a `getTracksById()`
|
|
@@ -37,15 +39,20 @@ export declare function findTrackConf(session: SessionTrackLookup, trackId: stri
|
|
|
37
39
|
} & import("@jbrowse/mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>);
|
|
38
40
|
} & import("@jbrowse/mobx-state-tree").IStateTreeNode<import("@jbrowse/core/configuration").AnyConfigurationSchemaType>) | undefined;
|
|
39
41
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
+
* The assembly's own sequence adapter, which is what makes the reference a row
|
|
43
|
+
* and, through it, makes an array an interval rather than an insertion. An
|
|
44
|
+
* assembly that cannot supply one still works: the alignment is then reads only
|
|
45
|
+
* and no array is reported, which is the pre-reference behaviour.
|
|
42
46
|
*/
|
|
43
|
-
export declare function
|
|
44
|
-
|
|
47
|
+
export declare function sequenceAdapterConfig(session: AbstractSessionModel, assemblyName: string): Record<string, unknown> | undefined;
|
|
48
|
+
/**
|
|
49
|
+
* One RPC per launch, however many files it draws from. The session id is
|
|
50
|
+
* shared across the sources so the worker keeps one adapter cache for the view
|
|
51
|
+
* rather than one per file.
|
|
52
|
+
*/
|
|
53
|
+
export declare function fetchTviewPlan({ session, sources, region, maxCells, }: {
|
|
45
54
|
session: AbstractSessionModel;
|
|
46
|
-
|
|
55
|
+
sources: TviewSource[];
|
|
47
56
|
region: FetchRegion;
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
rowCount: number;
|
|
51
|
-
}>;
|
|
57
|
+
maxCells?: number;
|
|
58
|
+
}): Promise<TviewPlanResult>;
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { planTviewMsa } from './tview';
|
|
4
|
-
export function sourceFromTrack(track) {
|
|
5
|
-
return {
|
|
6
|
-
adapterConfig: getConf(track, 'adapter'),
|
|
7
|
-
rpcSessionId: getRpcSessionId(track),
|
|
8
|
-
};
|
|
9
|
-
}
|
|
1
|
+
import { readConfObject } from '@jbrowse/core/configuration';
|
|
2
|
+
import { MAX_CELLS } from './limits';
|
|
10
3
|
export function findTrackConf(session, trackId) {
|
|
11
4
|
return session.getTrackById
|
|
12
5
|
? session.getTrackById(trackId)
|
|
@@ -17,27 +10,34 @@ export function findTrackConf(session, trackId) {
|
|
|
17
10
|
: session.tracks.find(t => readConfObject(t, 'trackId') === trackId);
|
|
18
11
|
}
|
|
19
12
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
13
|
+
* The assembly's own sequence adapter, which is what makes the reference a row
|
|
14
|
+
* and, through it, makes an array an interval rather than an insertion. An
|
|
15
|
+
* assembly that cannot supply one still works: the alignment is then reads only
|
|
16
|
+
* and no array is reported, which is the pre-reference behaviour.
|
|
22
17
|
*/
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
export function sequenceAdapterConfig(session, assemblyName) {
|
|
19
|
+
const assembly = session.assemblyManager.get(assemblyName);
|
|
20
|
+
const conf = assembly?.configuration;
|
|
21
|
+
return conf
|
|
22
|
+
? readConfObject(conf, ['sequence', 'adapter'])
|
|
23
|
+
: undefined;
|
|
28
24
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
25
|
+
/**
|
|
26
|
+
* One RPC per launch, however many files it draws from. The session id is
|
|
27
|
+
* shared across the sources so the worker keeps one adapter cache for the view
|
|
28
|
+
* rather than one per file.
|
|
29
|
+
*/
|
|
30
|
+
export async function fetchTviewPlan({ session, sources, region, maxCells = MAX_CELLS, }) {
|
|
31
|
+
const rpcSessionId = `tview-${sources.map(s => s.trackId).join(',')}`;
|
|
32
|
+
return (await session.rpcManager.call(rpcSessionId, 'TviewGetPlan', {
|
|
33
33
|
sessionId: rpcSessionId,
|
|
34
|
-
|
|
34
|
+
sources: sources.map(s => ({
|
|
35
|
+
adapterConfig: s.adapterConfig,
|
|
36
|
+
sample: s.sample,
|
|
37
|
+
})),
|
|
38
|
+
sequenceAdapterConfig: sequenceAdapterConfig(session, region.assemblyName),
|
|
39
|
+
region,
|
|
40
|
+
maxCells,
|
|
35
41
|
}));
|
|
36
|
-
const features = feats.filter(f => !!f.get('seq'));
|
|
37
|
-
// only planned, not rendered: a caller may cancel, or find it too large
|
|
38
|
-
return {
|
|
39
|
-
plan: planTviewMsa({ features, ...region }),
|
|
40
|
-
rowCount: features.length,
|
|
41
|
-
};
|
|
42
42
|
}
|
|
43
43
|
//# sourceMappingURL=fetchTviewPlan.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchTviewPlan.js","sourceRoot":"","sources":["../../src/LaunchTView/fetchTviewPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fetchTviewPlan.js","sourceRoot":"","sources":["../../src/LaunchTView/fetchTviewPlan.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAqCpC,MAAM,UAAU,aAAa,CAAC,OAA2B,EAAE,OAAe;IACxE,OAAO,OAAO,CAAC,YAAY;QACzB,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,OAAO,CAAC;QAC/B,CAAC,CAAC,OAAO,CAAC,aAAa;YACrB,CAAC,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,OAAO,CAAC;YAClC,CAAC,CAAC,OAAO,CAAC,UAAU;gBAClB,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC;gBAC7B,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,OAAO,CAAC,CAAA;AAC5E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CACnC,OAA6B,EAC7B,YAAoB;IAEpB,MAAM,QAAQ,GAAG,OAAO,CAAC,eAAe,CAAC,GAAG,CAAC,YAAY,CAAC,CAAA;IAC1D,MAAM,IAAI,GAAG,QAAQ,EAAE,aAAa,CAAA;IACpC,OAAO,IAAI;QACT,CAAC,CAAE,cAAc,CAAC,IAAI,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,CACP;QACxC,CAAC,CAAC,SAAS,CAAA;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,EACnC,OAAO,EACP,OAAO,EACP,MAAM,EACN,QAAQ,GAAG,SAAS,GAMrB;IACC,MAAM,YAAY,GAAG,SAAS,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IACrE,OAAO,CAAC,MAAM,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,EAAE,cAAc,EAAE;QAClE,SAAS,EAAE,YAAY;QACvB,OAAO,EAAE,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YACzB,aAAa,EAAE,CAAC,CAAC,aAAa;YAC9B,MAAM,EAAE,CAAC,CAAC,MAAM;SACjB,CAAC,CAAC;QACH,qBAAqB,EAAE,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,YAAY,CAAC;QAC1E,MAAM;QACN,QAAQ;KACT,CAAC,CAAoB,CAAA;AACxB,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type PluginManager from '@jbrowse/core/PluginManager';
|
|
2
|
+
import type { AbstractSessionModel } from '@jbrowse/core/util';
|
|
3
|
+
/**
|
|
4
|
+
* `LaunchView-TView`, so a session spec URL can open one.
|
|
5
|
+
*
|
|
6
|
+
* The two ways of writing a view are not the same shape, and JBrowse's spec
|
|
7
|
+
* loader says so out loud: a spec view is **flat arguments** to this launcher,
|
|
8
|
+
* while a config or defaultSession view is MST state, where anything needing
|
|
9
|
+
* resolution on load lives under the view's own `init`. So the spec
|
|
10
|
+
*
|
|
11
|
+
* { type: 'TView', assembly: 'hg19', loc: 'chrX:1..2', tracks: ['HG002'] }
|
|
12
|
+
*
|
|
13
|
+
* and the config
|
|
14
|
+
*
|
|
15
|
+
* { type: 'TView', init: { assembly: 'hg19', loc: '…', tracks: […] } }
|
|
16
|
+
*
|
|
17
|
+
* are the same view, and this is the one line between them. Splitting on
|
|
18
|
+
* `initKeys` rather than listing the pass-through props means every react-msaview
|
|
19
|
+
* view prop — colWidth, rowHeight, colorSchemeName, the ones added next — rides
|
|
20
|
+
* along without being enumerated here.
|
|
21
|
+
*/
|
|
22
|
+
export type LaunchTViewArgs = {
|
|
23
|
+
session: AbstractSessionModel;
|
|
24
|
+
} & Record<string, unknown>;
|
|
25
|
+
export default function LaunchTViewF(pluginManager: PluginManager): void;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { initKeys } from '../TViewPanel/init';
|
|
2
|
+
export default function LaunchTViewF(pluginManager) {
|
|
3
|
+
/** #extensionPoint LaunchView-TView | async | Programmatically launch a tview */
|
|
4
|
+
pluginManager.addToExtensionPoint('LaunchView-TView', (args) => {
|
|
5
|
+
const { session, ...spec } = args;
|
|
6
|
+
const init = {};
|
|
7
|
+
const viewProps = {};
|
|
8
|
+
for (const [key, value] of Object.entries(spec)) {
|
|
9
|
+
;
|
|
10
|
+
(initKeys.has(key) ? init : viewProps)[key] = value;
|
|
11
|
+
}
|
|
12
|
+
session.addView('TView', {
|
|
13
|
+
type: 'TView',
|
|
14
|
+
...viewProps,
|
|
15
|
+
init: init,
|
|
16
|
+
});
|
|
17
|
+
return args;
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=launchView.js.map
|