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,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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AAC,EAAE,CACK;gBACb,oBAAC,WAAW,IAAC,IAAI,EAAE,IAAI,GAAI,CAC1B,CACJ,CAAC,CAAC,CAAC,CACF,oBAAC,UAAU,0CAA6C,CACzD,CACa;QAChB,oBAAC,aAAa;YACZ,oBAAC,MAAM,IACL,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,SAAS,EACf,QAAQ,EAAE,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC,IAAI,EAC7B,OAAO,EAAE,GAAG,EAAE;oBACZ,IAAI,IAAI,EAAE,CAAC;wBACT,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;4BACvB,IAAI,EAAE,OAAO;4BACb,WAAW,EAAE,IAAI,CAAC,GAAG;4BACrB,IAAI;4BACJ,QAAQ;4BACR,SAAS,EAAE,EAAE;4BACb,gBAAgB,EAAE,IAAI;4BACtB,eAAe,EAAE,aAAa;4BAC9B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;4BAChC,eAAe,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;YAC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AAY,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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"launchView.js","sourceRoot":"","sources":["../../src/LaunchTView/launchView.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AA8B7C,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,GAAG,IAAI,EAAE,GAAG,IAAI,CAAA;QACjC,MAAM,IAAI,GAA4B,EAAE,CAAA;QACxC,MAAM,SAAS,GAA4B,EAAE,CAAA;QAC7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAChD,CAAC;YAAA,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;QACtD,CAAC;QACD,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE;YACvB,IAAI,EAAE,OAAO;YACb,GAAG,SAAS;YACZ,IAAI,EAAE,IAA4B;SACnC,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACb,CAAC,CACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/** the subset of an @jbrowse/core Feature that the layout reads */
|
|
2
|
+
export interface AlignmentFeature {
|
|
3
|
+
get: (key: string) => any;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Only '-' and '.' are treated as gaps by react-msaview (anything else counts
|
|
7
|
+
* as a base in the conservation track and column stats), so the two of them
|
|
8
|
+
* carry the whole vocabulary for "no base here". They are split by meaning:
|
|
9
|
+
*
|
|
10
|
+
* - SPANNED_GAP: the read covers this reference position but aligns no base to
|
|
11
|
+
* it, i.e. a deletion, or padding in an insertion column
|
|
12
|
+
* - ABSENT: the read is not here at all, i.e. outside its bounds, or skipping
|
|
13
|
+
* over the position through an N (an intron, not a deleted allele)
|
|
14
|
+
*/
|
|
15
|
+
export declare const SPANNED_GAP = "-";
|
|
16
|
+
export declare const ABSENT = ".";
|
|
17
|
+
export interface ReadLayout {
|
|
18
|
+
/**
|
|
19
|
+
* Identity. Every per-row lookup is keyed by this — the array blocks, the
|
|
20
|
+
* tree — so it is fixed once, here, and nothing downstream rewrites it.
|
|
21
|
+
*/
|
|
22
|
+
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
|
+
*/
|
|
36
|
+
sample?: string;
|
|
37
|
+
start: number;
|
|
38
|
+
/** one char per reference position consumed: the aligned base, or a gap */
|
|
39
|
+
refChars: string;
|
|
40
|
+
/** reference position -> bases inserted immediately before that position */
|
|
41
|
+
insertions: Map<number, string>;
|
|
42
|
+
}
|
|
43
|
+
export declare const byStart: (a: ReadLayout, b: ReadLayout) => number;
|
|
44
|
+
export declare function parseCigar(cigar: string): string[];
|
|
45
|
+
export declare function parseRead(feature: AlignmentFeature, name: string, sample?: string): ReadLayout;
|
|
46
|
+
/**
|
|
47
|
+
* Reads are fetched by overlap, so they carry insertions on either side of the
|
|
48
|
+
* region. Those get no columns and are never rendered, so dropping them keeps
|
|
49
|
+
* the pairwise alignment below off the wasted sites entirely.
|
|
50
|
+
*/
|
|
51
|
+
export declare function clipInsertions(reads: ReadLayout[], start: number, end: number): {
|
|
52
|
+
insertions: Map<number, string>;
|
|
53
|
+
/**
|
|
54
|
+
* Identity. Every per-row lookup is keyed by this — the array blocks, the
|
|
55
|
+
* tree — so it is fixed once, here, and nothing downstream rewrites it.
|
|
56
|
+
*/
|
|
57
|
+
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
|
+
*/
|
|
71
|
+
sample?: string;
|
|
72
|
+
start: number;
|
|
73
|
+
/** one char per reference position consumed: the aligned base, or a gap */
|
|
74
|
+
refChars: string;
|
|
75
|
+
}[];
|
|
76
|
+
/**
|
|
77
|
+
* MSA rows are keyed by name, so mates and duplicate names need disambiguating.
|
|
78
|
+
* With several samples loaded at once the same read name can also arrive twice
|
|
79
|
+
* from two files, which the sample prefix separates before the counter has to.
|
|
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.
|
|
84
|
+
*/
|
|
85
|
+
export declare function getReadNames(features: AlignmentFeature[], sampleOf?: (index: number) => string | undefined): string[];
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { newickSafe } from './sampleTree';
|
|
2
|
+
/**
|
|
3
|
+
* Only '-' and '.' are treated as gaps by react-msaview (anything else counts
|
|
4
|
+
* as a base in the conservation track and column stats), so the two of them
|
|
5
|
+
* carry the whole vocabulary for "no base here". They are split by meaning:
|
|
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
|
+
export const SPANNED_GAP = '-';
|
|
13
|
+
export const ABSENT = '.';
|
|
14
|
+
const cigarRegex = /([MIDNSHPX=])/;
|
|
15
|
+
export 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, sample) {
|
|
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
|
+
// 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
|
+
return {
|
|
54
|
+
name,
|
|
55
|
+
sample: sample === undefined ? undefined : newickSafe(sample),
|
|
56
|
+
start,
|
|
57
|
+
refChars,
|
|
58
|
+
insertions,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Reads are fetched by overlap, so they carry insertions on either side of the
|
|
63
|
+
* region. Those get no columns and are never rendered, so dropping them keeps
|
|
64
|
+
* the pairwise alignment below off the wasted sites entirely.
|
|
65
|
+
*/
|
|
66
|
+
export function clipInsertions(reads, start, end) {
|
|
67
|
+
return reads.map(read => ({
|
|
68
|
+
...read,
|
|
69
|
+
insertions: new Map([...read.insertions].filter(([pos]) => pos >= start && pos < end)),
|
|
70
|
+
}));
|
|
71
|
+
}
|
|
72
|
+
function mateSuffix(flags) {
|
|
73
|
+
return flags === undefined || !(flags & 1) ? '' : flags & 64 ? '/1' : '/2';
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* MSA rows are keyed by name, so mates and duplicate names need disambiguating.
|
|
77
|
+
* With several samples loaded at once the same read name can also arrive twice
|
|
78
|
+
* from two files, which the sample prefix separates before the counter has to.
|
|
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.
|
|
83
|
+
*/
|
|
84
|
+
export function getReadNames(features, sampleOf) {
|
|
85
|
+
const counts = new Map();
|
|
86
|
+
return features.map((f, i) => {
|
|
87
|
+
const sample = sampleOf?.(i);
|
|
88
|
+
const prefix = sample ? `${newickSafe(sample)}|` : '';
|
|
89
|
+
const name = newickSafe(String(f.get('name')));
|
|
90
|
+
const base = `${prefix}${name}${mateSuffix(f.get('flags'))}`;
|
|
91
|
+
const n = (counts.get(base) ?? 0) + 1;
|
|
92
|
+
counts.set(base, n);
|
|
93
|
+
return n === 1 ? base : `${base}_${n}`;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
//# sourceMappingURL=readLayout.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readLayout.js","sourceRoot":"","sources":["../../src/LaunchTView/readLayout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAOzC;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,CAAA;AAC9B,MAAM,CAAC,MAAM,MAAM,GAAG,GAAG,CAAA;AA6BzB,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,OAAO,CAAC,GAAG,CAAC,KAAK,CAAW,CAAA;IACxC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AG,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;QAC5B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAA;QACrD,MAAM,IAAI,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;QAC9C,MAAM,IAAI,GAAG,GAAG,MAAM,GAAG,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,CAAA;QAC5D,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAA;QACrC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC,CAAA;QACnB,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,EAAE,CAAA;IACxC,CAAC,CAAC,CAAA;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finding tandem arrays in the *reference*, rather than in what the reads
|
|
3
|
+
* inserted.
|
|
4
|
+
*
|
|
5
|
+
* The insertion-anchored reading — "an array is the sequence some read inserted
|
|
6
|
+
* at one reference position" — is what the aligner happens to produce, not what
|
|
7
|
+
* is there. Measured against the GIAB trio at HTT, ATXN3 and TCF4 it fails in
|
|
8
|
+
* three ways at once:
|
|
9
|
+
*
|
|
10
|
+
* - **The array is already in the reference.** A read's insertion is only its
|
|
11
|
+
* allele's *excess* over the reference copy count, so `n=5` at HTT means five
|
|
12
|
+
* copies more than hg19's, not a five-copy allele. A contracted allele inserts
|
|
13
|
+
* nothing at all and vanishes from the site.
|
|
14
|
+
* - **One array reports as several sites.** An indel inside an array has no
|
|
15
|
+
* unique placement, so the aligner anchors different reads at different
|
|
16
|
+
* positions: ATXN3 in HG002 came back as four separate arrays at 92537353,
|
|
17
|
+
* ...354, ...358 and ...372, splitting one locus's alleles across four counts.
|
|
18
|
+
* - **A read that spans the array without an insertion is invisible**, so the
|
|
19
|
+
* reference-length allele — usually the commonest one — is never counted.
|
|
20
|
+
*
|
|
21
|
+
* Anchoring on a reference interval fixes all three: the interval is the same
|
|
22
|
+
* for every read, so an allele is "what this read has between here and here",
|
|
23
|
+
* however the aligner chose to write it, and the reference is just another
|
|
24
|
+
* allele.
|
|
25
|
+
*/
|
|
26
|
+
export declare const MIN_PERIOD = 2;
|
|
27
|
+
export declare const MAX_PERIOD = 300;
|
|
28
|
+
export declare const MIN_COPIES = 3;
|
|
29
|
+
export interface ReferenceArray {
|
|
30
|
+
/** reference position the array starts at, inclusive */
|
|
31
|
+
start: number;
|
|
32
|
+
/** reference position the array ends at, exclusive */
|
|
33
|
+
end: number;
|
|
34
|
+
/** repeat unit length in bp */
|
|
35
|
+
period: number;
|
|
36
|
+
/** the reference's own first copy, used as the alignment consensus */
|
|
37
|
+
unit: string;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Tandem arrays in `seq`, which is the reference over the viewed region
|
|
41
|
+
* starting at `offset`.
|
|
42
|
+
*
|
|
43
|
+
* Scanning periods upward and refusing to start an array inside one already
|
|
44
|
+
* found is what reports a 3bp array as 3bp rather than as 6bp or 9bp: every
|
|
45
|
+
* multiple of a real period scores just as well, and the smallest one is the
|
|
46
|
+
* unit. It also means a long array with a short unit hides a spurious long-unit
|
|
47
|
+
* one inside it, which is the failure mode of scanning periods independently.
|
|
48
|
+
*/
|
|
49
|
+
export declare function findReferenceArrays(seq: string, offset?: number): ReferenceArray[];
|
|
50
|
+
/**
|
|
51
|
+
* Merge arrays that touch or overlap into one interval, named by the shortest
|
|
52
|
+
* period that describes most of it.
|
|
53
|
+
*
|
|
54
|
+
* An allele is measured over an interval, so two intervals sharing reference
|
|
55
|
+
* positions would measure the same read bases twice. Overlaps are the norm
|
|
56
|
+
* rather than an edge case, because one locus is genuinely periodic at more
|
|
57
|
+
* than one lag: the ABCA7 VNTR's copies are 25 and 26 bases long, so it scans
|
|
58
|
+
* as a 25mer array, a 26mer array and — over the stretch where the two
|
|
59
|
+
* alternate — a 77mer one, all describing the same 466 bases. Taking the
|
|
60
|
+
* shortest period among the rivals reports it as the 25bp unit it is known by,
|
|
61
|
+
* rather than as a 77bp unit that is three copies wearing one name.
|
|
62
|
+
*/
|
|
63
|
+
export declare function mergeArrays(arrays: ReferenceArray[], gap?: number): {
|
|
64
|
+
start: number;
|
|
65
|
+
end: number;
|
|
66
|
+
period: number;
|
|
67
|
+
unit: string;
|
|
68
|
+
}[];
|