jbrowse-plugin-tview 2.2.3 → 3.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 +325 -106
- package/dist/AddHighlightModel/index.js +2 -13
- package/dist/AddHighlightModel/index.js.map +1 -1
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.d.ts +44 -64
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js +57 -81
- package/dist/LaunchTView/TviewGetPlanRpc/TviewGetPlan.js.map +1 -1
- package/dist/LaunchTView/TviewGetPlanRpc/index.d.ts +1 -1
- package/dist/LaunchTView/align.d.ts +11 -17
- package/dist/LaunchTView/align.js +190 -150
- package/dist/LaunchTView/align.js.map +1 -1
- package/dist/LaunchTView/alleles.d.ts +51 -0
- package/dist/LaunchTView/alleles.js +213 -0
- package/dist/LaunchTView/alleles.js.map +1 -1
- package/dist/LaunchTView/fetchTviewPlan.d.ts +5 -37
- package/dist/LaunchTView/fetchTviewPlan.js +7 -28
- package/dist/LaunchTView/fetchTviewPlan.js.map +1 -1
- package/dist/LaunchTView/index.js +45 -16
- package/dist/LaunchTView/index.js.map +1 -1
- package/dist/LaunchTView/launch.d.ts +50 -0
- package/dist/LaunchTView/launch.js +48 -0
- package/dist/LaunchTView/launch.js.map +1 -0
- package/dist/LaunchTView/launchView.d.ts +3 -8
- package/dist/LaunchTView/launchView.js +18 -12
- package/dist/LaunchTView/launchView.js.map +1 -1
- package/dist/LaunchTView/modifications.d.ts +64 -0
- package/dist/LaunchTView/modifications.js +131 -0
- package/dist/LaunchTView/modifications.js.map +1 -0
- package/dist/LaunchTView/readLayout.d.ts +35 -39
- package/dist/LaunchTView/readLayout.js +44 -24
- package/dist/LaunchTView/readLayout.js.map +1 -1
- package/dist/LaunchTView/repeatStats.d.ts +1 -1
- package/dist/LaunchTView/repeatStats.js +6 -21
- package/dist/LaunchTView/repeatStats.js.map +1 -1
- package/dist/LaunchTView/tview.d.ts +34 -23
- package/dist/LaunchTView/tview.js +133 -78
- package/dist/LaunchTView/tview.js.map +1 -1
- package/dist/TViewPanel/components/TViewPanel.js +9 -4
- package/dist/TViewPanel/components/TViewPanel.js.map +1 -1
- package/dist/TViewPanel/genome.d.ts +11 -0
- package/dist/TViewPanel/genome.js +32 -0
- package/dist/TViewPanel/genome.js.map +1 -0
- package/dist/TViewPanel/init.d.ts +38 -19
- package/dist/TViewPanel/init.js +66 -39
- package/dist/TViewPanel/init.js.map +1 -1
- package/dist/TViewPanel/initMenu.d.ts +28 -0
- package/dist/TViewPanel/initMenu.js +79 -0
- package/dist/TViewPanel/initMenu.js.map +1 -0
- package/dist/TViewPanel/model.d.ts +1090 -334
- package/dist/TViewPanel/model.js +295 -89
- package/dist/TViewPanel/model.js.map +1 -1
- package/dist/TViewPanel/modifications.d.ts +25 -0
- package/dist/TViewPanel/modifications.js +94 -0
- package/dist/TViewPanel/modifications.js.map +1 -0
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/jbrowse-plugin-tview.umd.production.min.js +125 -88
- 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 +8 -8
- package/src/AddHighlightModel/index.tsx +8 -14
- package/src/LaunchTView/TviewGetPlanRpc/TviewGetPlan.ts +119 -157
- package/src/LaunchTView/TviewGetPlanRpc/index.ts +0 -1
- package/src/LaunchTView/align.ts +225 -176
- package/src/LaunchTView/alleles.ts +272 -0
- package/src/LaunchTView/fetchTviewPlan.ts +11 -54
- package/src/LaunchTView/index.ts +74 -16
- package/src/LaunchTView/launch.ts +98 -0
- package/src/LaunchTView/launchView.ts +28 -20
- package/src/LaunchTView/modifications.ts +200 -0
- package/src/LaunchTView/readLayout.ts +65 -41
- package/src/LaunchTView/repeatStats.ts +7 -23
- package/src/LaunchTView/tview.ts +165 -91
- package/src/TViewPanel/components/TViewPanel.tsx +30 -5
- package/src/TViewPanel/genome.ts +41 -0
- package/src/TViewPanel/init.ts +104 -51
- package/src/TViewPanel/initMenu.ts +126 -0
- package/src/TViewPanel/model.ts +346 -97
- package/src/TViewPanel/modifications.ts +132 -0
- package/src/index.ts +0 -2
- package/src/version.ts +1 -1
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.d.ts +0 -6
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js +0 -23
- package/dist/AddHighlightModel/GenomeMouseoverHighlight.js.map +0 -1
- package/dist/AddHighlightModel/HighlightComponents.d.ts +0 -7
- package/dist/AddHighlightModel/HighlightComponents.js +0 -11
- package/dist/AddHighlightModel/HighlightComponents.js.map +0 -1
- package/dist/LaunchTView/components/ArrayReport.d.ts +0 -10
- package/dist/LaunchTView/components/ArrayReport.js +0 -59
- package/dist/LaunchTView/components/ArrayReport.js.map +0 -1
- package/dist/LaunchTView/components/LaunchTViewDialog.d.ts +0 -6
- package/dist/LaunchTView/components/LaunchTViewDialog.js +0 -124
- package/dist/LaunchTView/components/LaunchTViewDialog.js.map +0 -1
- package/dist/LaunchTView/sampleTree.d.ts +0 -37
- package/dist/LaunchTView/sampleTree.js +0 -65
- package/dist/LaunchTView/sampleTree.js.map +0 -1
- package/dist/LaunchTView/useTviewMsa.d.ts +0 -18
- package/dist/LaunchTView/useTviewMsa.js +0 -24
- package/dist/LaunchTView/useTviewMsa.js.map +0 -1
- package/dist/TViewPanel/coords.d.ts +0 -25
- package/dist/TViewPanel/coords.js +0 -56
- package/dist/TViewPanel/coords.js.map +0 -1
- package/src/AddHighlightModel/GenomeMouseoverHighlight.tsx +0 -46
- package/src/AddHighlightModel/HighlightComponents.tsx +0 -25
- package/src/LaunchTView/components/ArrayReport.tsx +0 -64
- package/src/LaunchTView/components/LaunchTViewDialog.tsx +0 -212
- package/src/LaunchTView/sampleTree.ts +0 -73
- package/src/LaunchTView/useTviewMsa.ts +0 -39
- package/src/TViewPanel/coords.ts +0 -65
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { launchTView } from './launch';
|
|
2
|
+
function isTrackInit(entry) {
|
|
3
|
+
return (typeof entry === 'string' ||
|
|
4
|
+
(typeof entry === 'object' &&
|
|
5
|
+
entry !== null &&
|
|
6
|
+
'trackId' in entry &&
|
|
7
|
+
typeof entry.trackId === 'string' &&
|
|
8
|
+
(!('sample' in entry) || typeof entry.sample === 'string')));
|
|
9
|
+
}
|
|
2
10
|
export default function LaunchTViewF(pluginManager) {
|
|
3
11
|
/** #extensionPoint LaunchView-TView | async | Programmatically launch a tview */
|
|
4
12
|
pluginManager.addToExtensionPoint('LaunchView-TView', (args) => {
|
|
5
|
-
const { session, ...
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
(
|
|
13
|
+
const { session, assembly, loc, tracks, ...viewProps } = args;
|
|
14
|
+
if (typeof assembly === 'string' &&
|
|
15
|
+
typeof loc === 'string' &&
|
|
16
|
+
Array.isArray(tracks) &&
|
|
17
|
+
tracks.every(isTrackInit)) {
|
|
18
|
+
launchTView(session, { assembly, loc, tracks }, viewProps);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
throw new Error('A TView spec needs an assembly name, a loc string and a tracks array of trackIds');
|
|
11
22
|
}
|
|
12
|
-
session.addView('TView', {
|
|
13
|
-
type: 'TView',
|
|
14
|
-
...viewProps,
|
|
15
|
-
init: init,
|
|
16
|
-
});
|
|
17
23
|
return args;
|
|
18
24
|
});
|
|
19
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launchView.js","sourceRoot":"","sources":["../../src/LaunchTView/launchView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"launchView.js","sourceRoot":"","sources":["../../src/LaunchTView/launchView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAyBtC,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,OAAO,KAAK,KAAK,QAAQ;YACxB,KAAK,KAAK,IAAI;YACd,SAAS,IAAI,KAAK;YAClB,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;YACjC,CAAC,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAAC,CAC9D,CAAA;AACH,CAAC;AAED,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,aAA4B;IAC/D,iFAAiF;IACjF,aAAa,CAAC,mBAAmB,CAC/B,kBAAkB,EAClB,CAAC,IAAqB,EAAE,EAAE;QACxB,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,IAAI,CAAA;QAC7D,IACE,OAAO,QAAQ,KAAK,QAAQ;YAC5B,OAAO,GAAG,KAAK,QAAQ;YACvB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC;YACrB,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,EACzB,CAAC;YACD,WAAW,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,CAAA;QAC5D,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAA;QACH,CAAC;QACD,OAAO,IAAI,CAAA;IACb,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { ReadLayout } from './readLayout';
|
|
2
|
+
import type { TviewPlan } from './tview';
|
|
3
|
+
import type { Feature } from '@jbrowse/core/util';
|
|
4
|
+
/**
|
|
5
|
+
* The most probable call on each modified base, as parallel arrays rather than
|
|
6
|
+
* one object per call to keep the worker's reply small: the row it is on, the
|
|
7
|
+
* 1-based index into that row's ungapped letters, its type and its ML byte.
|
|
8
|
+
*/
|
|
9
|
+
export interface TviewModifications {
|
|
10
|
+
rows: string[];
|
|
11
|
+
/** the MM codes, `m`, `h`, `a` or a ChEBI number */
|
|
12
|
+
types: string[];
|
|
13
|
+
row: Uint32Array;
|
|
14
|
+
residue: Uint32Array;
|
|
15
|
+
type: Uint8Array;
|
|
16
|
+
prob: Uint8Array;
|
|
17
|
+
/** calls left out for being past the cap, the least probable first */
|
|
18
|
+
dropped: number;
|
|
19
|
+
/** rows with calls whose letters are not one run of the read's sequence */
|
|
20
|
+
unplaced: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Every call costs react-msaview on each load and each change of the row table,
|
|
24
|
+
* with no spatial index to skip the ones off screen: over 916 rows that was
|
|
25
|
+
* +90ms at 50k calls, +160ms at 100k and +415ms at 200k. A 20kb read carries
|
|
26
|
+
* ~200 CpG calls at the genome's average density, so 50k is ~250 reads across
|
|
27
|
+
* the widest window; 6mA called on every A does not fit.
|
|
28
|
+
*/
|
|
29
|
+
export declare const MAX_MODIFICATION_CALLS = 50000;
|
|
30
|
+
/**
|
|
31
|
+
* The query index of a row's first letter, when its letters are one unbroken
|
|
32
|
+
* run of the read's own sequence. They are, unless the layout moved bases of
|
|
33
|
+
* the read past each other (an insertion re-filed into an array without an
|
|
34
|
+
* exact rewrite) or left some out (an array block the row has no allele for),
|
|
35
|
+
* and a call projected onto such a row would land on the wrong base.
|
|
36
|
+
*/
|
|
37
|
+
export declare function rowInRead(read: ReadLayout, row: string, layout: TviewPlan['layout']): {
|
|
38
|
+
seq: string;
|
|
39
|
+
first: number;
|
|
40
|
+
length: number;
|
|
41
|
+
} | undefined;
|
|
42
|
+
interface ProjectArgs {
|
|
43
|
+
features: Feature[];
|
|
44
|
+
plan: TviewPlan;
|
|
45
|
+
/** each read's rendered row, parallel to `plan.reads` */
|
|
46
|
+
rows: string[];
|
|
47
|
+
maxCalls?: number;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Each modified base the rendered rows show, as an index into its row's
|
|
51
|
+
* letters. Undefined when no read in the window has an MM tag, so a file
|
|
52
|
+
* without modifications pays for one tag lookup per read.
|
|
53
|
+
*/
|
|
54
|
+
export declare function planModifications(args: ProjectArgs): {
|
|
55
|
+
rows: string[];
|
|
56
|
+
types: string[];
|
|
57
|
+
row: Uint32Array<ArrayBuffer>;
|
|
58
|
+
residue: Uint32Array<ArrayBuffer>;
|
|
59
|
+
type: Uint8Array<ArrayBuffer>;
|
|
60
|
+
prob: Uint8Array<ArrayBuffer>;
|
|
61
|
+
dropped: number;
|
|
62
|
+
unplaced: number;
|
|
63
|
+
} | undefined;
|
|
64
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { getModPositions, getModProbabilityBytes, getModTag, modProbAt, } from '@jbrowse/modifications-utils';
|
|
2
|
+
import { GAPS, queryIndexAt } from './readLayout';
|
|
3
|
+
import { rowSpan } from './tview';
|
|
4
|
+
/**
|
|
5
|
+
* Every call costs react-msaview on each load and each change of the row table,
|
|
6
|
+
* with no spatial index to skip the ones off screen: over 916 rows that was
|
|
7
|
+
* +90ms at 50k calls, +160ms at 100k and +415ms at 200k. A 20kb read carries
|
|
8
|
+
* ~200 CpG calls at the genome's average density, so 50k is ~250 reads across
|
|
9
|
+
* the widest window; 6mA called on every A does not fit.
|
|
10
|
+
*/
|
|
11
|
+
export const MAX_MODIFICATION_CALLS = 50_000;
|
|
12
|
+
/**
|
|
13
|
+
* The query index of a row's first letter, when its letters are one unbroken
|
|
14
|
+
* run of the read's own sequence. They are, unless the layout moved bases of
|
|
15
|
+
* the read past each other (an insertion re-filed into an array without an
|
|
16
|
+
* exact rewrite) or left some out (an array block the row has no allele for),
|
|
17
|
+
* and a call projected onto such a row would land on the wrong base.
|
|
18
|
+
*/
|
|
19
|
+
export function rowInRead(read, row, layout) {
|
|
20
|
+
const { query } = read;
|
|
21
|
+
const first = query
|
|
22
|
+
? queryIndexAt(read, query, rowSpan(read, layout).from)
|
|
23
|
+
: 0;
|
|
24
|
+
const letters = row.replaceAll(GAPS, '');
|
|
25
|
+
return query?.seq.startsWith(letters, first)
|
|
26
|
+
? { seq: query.seq, first, length: letters.length }
|
|
27
|
+
: undefined;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The most probable call at each base of `seq` in [from, from + length), packed
|
|
31
|
+
* as `(type + 1) << 8 | ML byte`, 0 where nothing is called.
|
|
32
|
+
*/
|
|
33
|
+
function bestCalls(feature, mm, { seq, first: from, length }, typeIndex) {
|
|
34
|
+
const strand = feature.get('strand') ?? 0;
|
|
35
|
+
const bytes = getModProbabilityBytes(feature);
|
|
36
|
+
const ml = bytes ? Array.from(bytes) : undefined;
|
|
37
|
+
const best = new Uint16Array(length);
|
|
38
|
+
for (const mod of getModPositions(mm, seq, strand, from, from + length)) {
|
|
39
|
+
const tag = (typeIndex(mod.type) + 1) << 8;
|
|
40
|
+
const { positions, probStart, probStride } = mod;
|
|
41
|
+
for (const [idx, pos] of positions.entries()) {
|
|
42
|
+
const at = pos - from;
|
|
43
|
+
const prob = modProbAt(ml, probStart, probStride, strand === -1, idx, positions.length);
|
|
44
|
+
const prev = best[at];
|
|
45
|
+
if (prev !== undefined && (prev === 0 || (prev & 0xff) < prob)) {
|
|
46
|
+
best[at] = tag | prob;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return best;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* The lowest probability byte whose calls all fit in `keep` together with every
|
|
54
|
+
* more probable one, and how many calls of the byte below it still fit.
|
|
55
|
+
*/
|
|
56
|
+
function keepThreshold(probs, keep) {
|
|
57
|
+
const counts = new Array(256).fill(0);
|
|
58
|
+
for (const p of probs) {
|
|
59
|
+
counts[p]++;
|
|
60
|
+
}
|
|
61
|
+
let threshold = 256;
|
|
62
|
+
let kept = 0;
|
|
63
|
+
while (threshold > 0 && kept + counts[threshold - 1] <= keep) {
|
|
64
|
+
threshold--;
|
|
65
|
+
kept += counts[threshold];
|
|
66
|
+
}
|
|
67
|
+
return { threshold, room: keep - kept };
|
|
68
|
+
}
|
|
69
|
+
function projectModifications(tags, { features, plan, rows, maxCalls = MAX_MODIFICATION_CALLS }) {
|
|
70
|
+
const rowOf = new Map(plan.reads.map((read, i) => [read.name, { read, row: rows[i] }]));
|
|
71
|
+
const types = [];
|
|
72
|
+
const typeIndex = (type) => {
|
|
73
|
+
const i = types.indexOf(type);
|
|
74
|
+
return i >= 0 ? i : types.push(type) - 1;
|
|
75
|
+
};
|
|
76
|
+
const callRows = [];
|
|
77
|
+
const row = [];
|
|
78
|
+
const residue = [];
|
|
79
|
+
const type = [];
|
|
80
|
+
const prob = [];
|
|
81
|
+
let unplaced = 0;
|
|
82
|
+
for (const [i, mm] of tags.entries()) {
|
|
83
|
+
const rendered = mm ? rowOf.get(plan.featureNames[i]) : undefined;
|
|
84
|
+
if (mm && rendered) {
|
|
85
|
+
const slice = rowInRead(rendered.read, rendered.row, plan.layout);
|
|
86
|
+
if (slice) {
|
|
87
|
+
const before = row.length;
|
|
88
|
+
for (const [at, packed] of bestCalls(features[i], mm, slice, typeIndex).entries()) {
|
|
89
|
+
if (packed) {
|
|
90
|
+
row.push(callRows.length);
|
|
91
|
+
residue.push(at + 1);
|
|
92
|
+
type.push((packed >> 8) - 1);
|
|
93
|
+
prob.push(packed & 0xff);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (row.length > before) {
|
|
97
|
+
callRows.push(rendered.read.name);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
unplaced++;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
const { threshold, room } = keepThreshold(prob, maxCalls);
|
|
106
|
+
let tiesLeft = room;
|
|
107
|
+
const keep = prob.map(p => p >= threshold ? true : p === threshold - 1 && tiesLeft-- > 0);
|
|
108
|
+
const kept = (values) => values.filter((_, i) => keep[i]);
|
|
109
|
+
return {
|
|
110
|
+
rows: callRows,
|
|
111
|
+
types,
|
|
112
|
+
row: Uint32Array.from(kept(row)),
|
|
113
|
+
residue: Uint32Array.from(kept(residue)),
|
|
114
|
+
type: Uint8Array.from(kept(type)),
|
|
115
|
+
prob: Uint8Array.from(kept(prob)),
|
|
116
|
+
dropped: keep.filter(k => !k).length,
|
|
117
|
+
unplaced,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Each modified base the rendered rows show, as an index into its row's
|
|
122
|
+
* letters. Undefined when no read in the window has an MM tag, so a file
|
|
123
|
+
* without modifications pays for one tag lookup per read.
|
|
124
|
+
*/
|
|
125
|
+
export function planModifications(args) {
|
|
126
|
+
const tags = args.features.map(f => getModTag(f));
|
|
127
|
+
return tags.some(t => t !== undefined)
|
|
128
|
+
? projectModifications(tags, args)
|
|
129
|
+
: undefined;
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=modifications.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifications.js","sourceRoot":"","sources":["../../src/LaunchTView/modifications.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,SAAS,EACT,SAAS,GACV,MAAM,8BAA8B,CAAA;AAErC,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAyBjC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,MAAM,CAAA;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CACvB,IAAgB,EAChB,GAAW,EACX,MAA2B;IAE3B,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAA;IACtB,MAAM,KAAK,GAAG,KAAK;QACjB,CAAC,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC;QACvD,CAAC,CAAC,CAAC,CAA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CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM;QACpC,QAAQ;KACT,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,IAAiB;IACjD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;QACpC,CAAC,CAAC,oBAAoB,CAAC,IAAI,EAAE,IAAI,CAAC;QAClC,CAAC,CAAC,SAAS,CAAA;AACf,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** the subset of an @jbrowse/core Feature that the layout reads */
|
|
2
2
|
export interface AlignmentFeature {
|
|
3
|
-
get: (key: string) =>
|
|
3
|
+
get: (key: string) => unknown;
|
|
4
4
|
}
|
|
5
5
|
/**
|
|
6
6
|
* Only '-' and '.' are treated as gaps by react-msaview (anything else counts
|
|
@@ -14,35 +14,43 @@ export interface AlignmentFeature {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare const SPANNED_GAP = "-";
|
|
16
16
|
export declare const ABSENT = ".";
|
|
17
|
+
export declare const GAPS: RegExp;
|
|
17
18
|
export interface ReadLayout {
|
|
18
19
|
/**
|
|
19
|
-
* Identity. Every per-row lookup is
|
|
20
|
-
*
|
|
20
|
+
* Identity, and the row's name in the alignment. Every per-row lookup is
|
|
21
|
+
* keyed by this — the array blocks, the row table — so it is fixed once,
|
|
22
|
+
* here, and nothing downstream rewrites it.
|
|
21
23
|
*/
|
|
22
24
|
name: string;
|
|
23
|
-
/**
|
|
24
|
-
* What the row is called on screen, when that is not just its name. Kept
|
|
25
|
-
* apart from `name` because the copy-number label is added after the array
|
|
26
|
-
* blocks are built and keyed: renaming in place instead left every labelled
|
|
27
|
-
* row unable to find its own block, and the block fell back to gaps — a row
|
|
28
|
-
* that silently loses its sequence while keeping its label.
|
|
29
|
-
*/
|
|
30
|
-
label?: string;
|
|
31
|
-
/**
|
|
32
|
-
* The sample the row belongs to, when several were loaded at once. Already
|
|
33
|
-
* Newick-safe, and the same string the row's own name is prefixed with, so
|
|
34
|
-
* the clade label and its leaves agree.
|
|
35
|
-
*/
|
|
25
|
+
/** the sample the row belongs to, as the caller named it */
|
|
36
26
|
sample?: string;
|
|
37
27
|
start: number;
|
|
38
28
|
/** one char per reference position consumed: the aligned base, or a gap */
|
|
39
29
|
refChars: string;
|
|
40
30
|
/** reference position -> bases inserted immediately before that position */
|
|
41
31
|
insertions: Map<number, string>;
|
|
32
|
+
/** where the row's bases came from in the read, for a row parsed from one */
|
|
33
|
+
query?: ReadQuery;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The read's own sequence, SEQ as the file stores it, and enough of its CIGAR
|
|
37
|
+
* to find any base of the row in it: the query index of the first base at
|
|
38
|
+
* `start`, and how many bases the aligner inserted before each position. Kept
|
|
39
|
+
* as parsed, since the layout later moves and drops insertions.
|
|
40
|
+
*/
|
|
41
|
+
export interface ReadQuery {
|
|
42
|
+
seq: string;
|
|
43
|
+
offset: number;
|
|
44
|
+
inserted: Map<number, number>;
|
|
42
45
|
}
|
|
43
46
|
export declare const byStart: (a: ReadLayout, b: ReadLayout) => number;
|
|
44
47
|
export declare function parseCigar(cigar: string): string[];
|
|
45
48
|
export declare function parseRead(feature: AlignmentFeature, name: string, sample?: string): ReadLayout;
|
|
49
|
+
/**
|
|
50
|
+
* The query index of the first base a parsed read has at or after reference
|
|
51
|
+
* position `pos`, counting what it inserted at `pos` itself as coming first.
|
|
52
|
+
*/
|
|
53
|
+
export declare function queryIndexAt(read: ReadLayout, query: ReadQuery, pos: number): number;
|
|
46
54
|
/**
|
|
47
55
|
* Reads are fetched by overlap, so they carry insertions on either side of the
|
|
48
56
|
* region. Those get no columns and are never rendered, so dropping them keeps
|
|
@@ -51,35 +59,23 @@ export declare function parseRead(feature: AlignmentFeature, name: string, sampl
|
|
|
51
59
|
export declare function clipInsertions(reads: ReadLayout[], start: number, end: number): {
|
|
52
60
|
insertions: Map<number, string>;
|
|
53
61
|
/**
|
|
54
|
-
* Identity. Every per-row lookup is
|
|
55
|
-
*
|
|
62
|
+
* Identity, and the row's name in the alignment. Every per-row lookup is
|
|
63
|
+
* keyed by this — the array blocks, the row table — so it is fixed once,
|
|
64
|
+
* here, and nothing downstream rewrites it.
|
|
56
65
|
*/
|
|
57
66
|
name: string;
|
|
58
|
-
/**
|
|
59
|
-
* What the row is called on screen, when that is not just its name. Kept
|
|
60
|
-
* apart from `name` because the copy-number label is added after the array
|
|
61
|
-
* blocks are built and keyed: renaming in place instead left every labelled
|
|
62
|
-
* row unable to find its own block, and the block fell back to gaps — a row
|
|
63
|
-
* that silently loses its sequence while keeping its label.
|
|
64
|
-
*/
|
|
65
|
-
label?: string;
|
|
66
|
-
/**
|
|
67
|
-
* The sample the row belongs to, when several were loaded at once. Already
|
|
68
|
-
* Newick-safe, and the same string the row's own name is prefixed with, so
|
|
69
|
-
* the clade label and its leaves agree.
|
|
70
|
-
*/
|
|
67
|
+
/** the sample the row belongs to, as the caller named it */
|
|
71
68
|
sample?: string;
|
|
72
69
|
start: number;
|
|
73
70
|
/** one char per reference position consumed: the aligned base, or a gap */
|
|
74
71
|
refChars: string;
|
|
72
|
+
/** where the row's bases came from in the read, for a row parsed from one */
|
|
73
|
+
query?: ReadQuery;
|
|
75
74
|
}[];
|
|
76
75
|
/**
|
|
77
|
-
* MSA rows are keyed by name,
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* The name is made Newick-safe here rather than where the tree is written,
|
|
82
|
-
* because the tree names the same rows the FASTA does and the two have to agree
|
|
83
|
-
* exactly. '|' separates the parts because ':' opens a branch length.
|
|
76
|
+
* MSA rows are keyed by name, and a FASTA defline names its row by the first
|
|
77
|
+
* whitespace-delimited word, dropping any later row whose word repeats. So a
|
|
78
|
+
* name loses its whitespace, mates are told apart by flag, and whatever still
|
|
79
|
+
* collides (the same read in two files, or a name in `reserved`) is numbered.
|
|
84
80
|
*/
|
|
85
|
-
export declare function getReadNames(features: AlignmentFeature[],
|
|
81
|
+
export declare function getReadNames(features: AlignmentFeature[], reserved?: string[]): string[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const text = (value) => (typeof value === 'string' ? value : '');
|
|
2
2
|
/**
|
|
3
3
|
* Only '-' and '.' are treated as gaps by react-msaview (anything else counts
|
|
4
4
|
* as a base in the conservation track and column stats), so the two of them
|
|
@@ -11,21 +11,27 @@ import { newickSafe } from './sampleTree';
|
|
|
11
11
|
*/
|
|
12
12
|
export const SPANNED_GAP = '-';
|
|
13
13
|
export const ABSENT = '.';
|
|
14
|
+
export const GAPS = /[-.]/g;
|
|
14
15
|
const cigarRegex = /([MIDNSHPX=])/;
|
|
15
16
|
export const byStart = (a, b) => a.start - b.start;
|
|
16
17
|
export function parseCigar(cigar) {
|
|
17
18
|
return cigar.split(cigarRegex).slice(0, -1);
|
|
18
19
|
}
|
|
19
20
|
export function parseRead(feature, name, sample) {
|
|
20
|
-
const seq = feature.get('seq');
|
|
21
|
-
const ops = parseCigar(feature.get('CIGAR'));
|
|
22
|
-
const start = feature.get('start');
|
|
21
|
+
const seq = text(feature.get('seq'));
|
|
22
|
+
const ops = parseCigar(text(feature.get('CIGAR')));
|
|
23
|
+
const start = Number(feature.get('start'));
|
|
23
24
|
const insertions = new Map();
|
|
25
|
+
const inserted = new Map();
|
|
24
26
|
let refChars = '';
|
|
25
27
|
let seqOffset = 0;
|
|
28
|
+
let offset;
|
|
26
29
|
for (let i = 0; i < ops.length; i += 2) {
|
|
27
30
|
const len = +ops[i];
|
|
28
31
|
const op = ops[i + 1];
|
|
32
|
+
if (op !== 'S' && op !== 'H' && op !== 'P') {
|
|
33
|
+
offset ??= seqOffset;
|
|
34
|
+
}
|
|
29
35
|
if (op === 'S') {
|
|
30
36
|
seqOffset += len;
|
|
31
37
|
}
|
|
@@ -34,6 +40,7 @@ export function parseRead(feature, name, sample) {
|
|
|
34
40
|
const pos = start + refChars.length;
|
|
35
41
|
const prev = insertions.get(pos) ?? '';
|
|
36
42
|
insertions.set(pos, prev + seq.slice(seqOffset, seqOffset + len));
|
|
43
|
+
inserted.set(pos, (inserted.get(pos) ?? 0) + len);
|
|
37
44
|
seqOffset += len;
|
|
38
45
|
}
|
|
39
46
|
else if (op === 'D') {
|
|
@@ -48,16 +55,31 @@ export function parseRead(feature, name, sample) {
|
|
|
48
55
|
}
|
|
49
56
|
// H and P consume neither the read sequence nor the reference
|
|
50
57
|
}
|
|
51
|
-
// sanitized here, the same way getReadNames sanitizes the prefix it builds
|
|
52
|
-
// from it, so the clade label and the leaves inside it are one string
|
|
53
58
|
return {
|
|
54
59
|
name,
|
|
55
|
-
sample
|
|
60
|
+
sample,
|
|
56
61
|
start,
|
|
57
62
|
refChars,
|
|
58
63
|
insertions,
|
|
64
|
+
query: { seq, offset: offset ?? seqOffset, inserted },
|
|
59
65
|
};
|
|
60
66
|
}
|
|
67
|
+
/**
|
|
68
|
+
* The query index of the first base a parsed read has at or after reference
|
|
69
|
+
* position `pos`, counting what it inserted at `pos` itself as coming first.
|
|
70
|
+
*/
|
|
71
|
+
export function queryIndexAt(read, query, pos) {
|
|
72
|
+
const aligned = read.refChars
|
|
73
|
+
.slice(0, Math.max(0, pos - read.start))
|
|
74
|
+
.replaceAll(GAPS, '').length;
|
|
75
|
+
let insertedBefore = 0;
|
|
76
|
+
for (const [at, len] of query.inserted) {
|
|
77
|
+
if (at < pos) {
|
|
78
|
+
insertedBefore += len;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
return query.offset + aligned + insertedBefore;
|
|
82
|
+
}
|
|
61
83
|
/**
|
|
62
84
|
* Reads are fetched by overlap, so they carry insertions on either side of the
|
|
63
85
|
* region. Those get no columns and are never rendered, so dropping them keeps
|
|
@@ -73,24 +95,22 @@ function mateSuffix(flags) {
|
|
|
73
95
|
return flags === undefined || !(flags & 1) ? '' : flags & 64 ? '/1' : '/2';
|
|
74
96
|
}
|
|
75
97
|
/**
|
|
76
|
-
* MSA rows are keyed by name,
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* The name is made Newick-safe here rather than where the tree is written,
|
|
81
|
-
* because the tree names the same rows the FASTA does and the two have to agree
|
|
82
|
-
* exactly. '|' separates the parts because ':' opens a branch length.
|
|
98
|
+
* MSA rows are keyed by name, and a FASTA defline names its row by the first
|
|
99
|
+
* whitespace-delimited word, dropping any later row whose word repeats. So a
|
|
100
|
+
* name loses its whitespace, mates are told apart by flag, and whatever still
|
|
101
|
+
* collides (the same read in two files, or a name in `reserved`) is numbered.
|
|
83
102
|
*/
|
|
84
|
-
export function getReadNames(features,
|
|
85
|
-
const
|
|
86
|
-
return features.map(
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
103
|
+
export function getReadNames(features, reserved = []) {
|
|
104
|
+
const taken = new Set(reserved);
|
|
105
|
+
return features.map(f => {
|
|
106
|
+
const flags = f.get('flags');
|
|
107
|
+
const base = `${String(f.get('name')).replaceAll(/\s+/g, '_')}${mateSuffix(typeof flags === 'number' ? flags : undefined)}`;
|
|
108
|
+
let name = base;
|
|
109
|
+
for (let n = 2; taken.has(name); n++) {
|
|
110
|
+
name = `${base}_${n}`;
|
|
111
|
+
}
|
|
112
|
+
taken.add(name);
|
|
113
|
+
return name;
|
|
94
114
|
});
|
|
95
115
|
}
|
|
96
116
|
//# sourceMappingURL=readLayout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"readLayout.js","sourceRoot":"","sources":["../../src/LaunchTView/readLayout.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"readLayout.js","sourceRoot":"","sources":["../../src/LaunchTView/readLayout.ts"],"names":[],"mappings":"AAKA,MAAM,IAAI,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAA;AAEzE;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;AAC9B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;AACzB,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAA;AAgC3B,MAAM,UAAU,GAAG,eAAe,CAAA;AAElC,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAa,EAAE,CAAa,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAA;AAE1E,MAAM,UAAU,UAAU,CAAC,KAAa;IACtC,OAAO,KAAK,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;AAC7C,CAAC;AAED,MAAM,UAAU,SAAS,CACvB,OAAyB,EACzB,IAAY,EACZ,MAAe;IAEf,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAA;IACpC,MAAM,GAAG,GAAG,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAClD,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAA;IAC1C,MAAM,UAAU,GAAG,IAAI,GAAG,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QACf,OAAO,IAAI,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -43,7 +43,7 @@ export interface ArrayStats {
|
|
|
43
43
|
width: number;
|
|
44
44
|
/** the reference's own copy count, when the reference was a row */
|
|
45
45
|
referenceCopies?: number;
|
|
46
|
-
/** whether the rows were ordered
|
|
46
|
+
/** whether the rows were ordered by this array */
|
|
47
47
|
subject: boolean;
|
|
48
48
|
samples: SampleArrayStats[];
|
|
49
49
|
}
|
|
@@ -8,7 +8,6 @@
|
|
|
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';
|
|
12
11
|
import { renderRow } from './tview';
|
|
13
12
|
/**
|
|
14
13
|
* Least support an allele needs before it is reported as one of a sample's,
|
|
@@ -92,25 +91,11 @@ export function alleleModes(copies) {
|
|
|
92
91
|
}
|
|
93
92
|
return peaks.filter(p => p.reads >= floor).sort((a, b) => a.value - b.value);
|
|
94
93
|
}
|
|
95
|
-
function
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
* Rows are prefixed with the Newick-safe form of their sample's name, so a
|
|
101
|
-
* caller naming the samples it wants reported has to be met there rather than
|
|
102
|
-
* taken at its word. A track called `HG004 (mother)` otherwise matched no row
|
|
103
|
-
* and came back with nought spanning reads and no alleles — which is what a
|
|
104
|
-
* locus nobody sequenced looks like, not what a misspelt name should.
|
|
105
|
-
*
|
|
106
|
-
* The name the caller gave is what gets reported back; only the matching is
|
|
107
|
-
* sanitized.
|
|
108
|
-
*/
|
|
109
|
-
function rowsOfSample(copiesByName, sample) {
|
|
110
|
-
const key = newickSafe(sample);
|
|
111
|
-
return [...copiesByName]
|
|
112
|
-
.filter(([name]) => sampleOfRow(name) === key)
|
|
113
|
-
.map(([, n]) => n);
|
|
94
|
+
function rowsOfSample(array, plan, sample) {
|
|
95
|
+
return plan.reads
|
|
96
|
+
.filter(read => read.sample === sample)
|
|
97
|
+
.map(read => array.copiesByName.get(read.name))
|
|
98
|
+
.filter(copies => copies !== undefined);
|
|
114
99
|
}
|
|
115
100
|
function arrayStats(array, plan, samples) {
|
|
116
101
|
return {
|
|
@@ -125,7 +110,7 @@ function arrayStats(array, plan, samples) {
|
|
|
125
110
|
: undefined,
|
|
126
111
|
subject: array === plan.subject,
|
|
127
112
|
samples: samples.map(sample => {
|
|
128
|
-
const copies = rowsOfSample(array
|
|
113
|
+
const copies = rowsOfSample(array, plan, sample);
|
|
129
114
|
const modes = alleleModes(copies);
|
|
130
115
|
return {
|
|
131
116
|
sample,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repeatStats.js","sourceRoot":"","sources":["../../src/LaunchTView/repeatStats.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"repeatStats.js","sourceRoot":"","sources":["../../src/LaunchTView/repeatStats.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAKnC;;;GAGG;AACH,MAAM,mBAAmB,GAAG,IAAI,CAAA;AAEhC,iDAAiD;AACjD,MAAM,gBAAgB,GAAG,CAAC,CAAA;AAE1B;;;;;;;;;;;;;GAaG;AACH,MAAM,eAAe,GAAG,GAAG,CAAA;AAE3B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,gBAAgB,GAAG,GAAG,CAAA;AAO5B,+EAA+E;AAC/E,MAAM,UAAU,KAAK,CAAC,MAAgB;IACpC,MAAM,MAAM,GAAG,IAAI,GAAG,EAAkB,CAAA;IACxC,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,M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