@jbrowse/plugin-sv-inspector 2.6.1
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/LICENSE +201 -0
- package/dist/LaunchSvInspectorView/index.d.ts +3 -0
- package/dist/LaunchSvInspectorView/index.js +27 -0
- package/dist/LaunchSvInspectorView/index.js.map +1 -0
- package/dist/SvInspectorView/components/CircularViewOptions.d.ts +6 -0
- package/dist/SvInspectorView/components/CircularViewOptions.js +22 -0
- package/dist/SvInspectorView/components/CircularViewOptions.js.map +1 -0
- package/dist/SvInspectorView/components/SvInspectorView.d.ts +6 -0
- package/dist/SvInspectorView/components/SvInspectorView.js +51 -0
- package/dist/SvInspectorView/components/SvInspectorView.js.map +1 -0
- package/dist/SvInspectorView/index.d.ts +3 -0
- package/dist/SvInspectorView/index.js +35 -0
- package/dist/SvInspectorView/index.js.map +1 -0
- package/dist/SvInspectorView/models/SvInspectorView.d.ts +881 -0
- package/dist/SvInspectorView/models/SvInspectorView.js +317 -0
- package/dist/SvInspectorView/models/SvInspectorView.js.map +1 -0
- package/dist/SvInspectorView/models/adhocFeatureUtils.d.ts +44 -0
- package/dist/SvInspectorView/models/adhocFeatureUtils.js +97 -0
- package/dist/SvInspectorView/models/adhocFeatureUtils.js.map +1 -0
- package/dist/SvInspectorView/models/breakpointSplitViewFromTableRow.d.ts +4 -0
- package/dist/SvInspectorView/models/breakpointSplitViewFromTableRow.js +49 -0
- package/dist/SvInspectorView/models/breakpointSplitViewFromTableRow.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/esm/LaunchSvInspectorView/index.d.ts +3 -0
- package/esm/LaunchSvInspectorView/index.js +25 -0
- package/esm/LaunchSvInspectorView/index.js.map +1 -0
- package/esm/SvInspectorView/components/CircularViewOptions.d.ts +6 -0
- package/esm/SvInspectorView/components/CircularViewOptions.js +17 -0
- package/esm/SvInspectorView/components/CircularViewOptions.js.map +1 -0
- package/esm/SvInspectorView/components/SvInspectorView.d.ts +6 -0
- package/esm/SvInspectorView/components/SvInspectorView.js +46 -0
- package/esm/SvInspectorView/components/SvInspectorView.js.map +1 -0
- package/esm/SvInspectorView/index.d.ts +3 -0
- package/esm/SvInspectorView/index.js +30 -0
- package/esm/SvInspectorView/index.js.map +1 -0
- package/esm/SvInspectorView/models/SvInspectorView.d.ts +881 -0
- package/esm/SvInspectorView/models/SvInspectorView.js +312 -0
- package/esm/SvInspectorView/models/SvInspectorView.js.map +1 -0
- package/esm/SvInspectorView/models/adhocFeatureUtils.d.ts +44 -0
- package/esm/SvInspectorView/models/adhocFeatureUtils.js +90 -0
- package/esm/SvInspectorView/models/adhocFeatureUtils.js.map +1 -0
- package/esm/SvInspectorView/models/breakpointSplitViewFromTableRow.d.ts +4 -0
- package/esm/SvInspectorView/models/breakpointSplitViewFromTableRow.js +42 -0
- package/esm/SvInspectorView/models/breakpointSplitViewFromTableRow.js.map +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.js +29 -0
- package/esm/index.js.map +1 -0
- package/package.json +62 -0
- package/src/LaunchSvInspectorView/index.ts +41 -0
- package/src/SvInspectorView/components/CircularViewOptions.tsx +47 -0
- package/src/SvInspectorView/components/SvInspectorView.tsx +81 -0
- package/src/SvInspectorView/index.ts +41 -0
- package/src/SvInspectorView/models/SvInspectorView.ts +406 -0
- package/src/SvInspectorView/models/adhocFeatureUtils.js +152 -0
- package/src/SvInspectorView/models/breakpointSplitViewFromTableRow.js +84 -0
- package/src/index.ts +34 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// this file contains the rather verbose functions for
|
|
2
|
+
// creating features from CSV/TSV lines
|
|
3
|
+
import { parseLocString } from '@jbrowse/core/util'
|
|
4
|
+
|
|
5
|
+
export function makeAdHocFeature(
|
|
6
|
+
columns,
|
|
7
|
+
columnsAlreadyUsedInLocations,
|
|
8
|
+
row,
|
|
9
|
+
loc1,
|
|
10
|
+
loc2,
|
|
11
|
+
rowNumber,
|
|
12
|
+
) {
|
|
13
|
+
// load all the other data in the row into an `otherData` object
|
|
14
|
+
const otherData = {}
|
|
15
|
+
columns.forEach((column, columnNumber) => {
|
|
16
|
+
if (columnsAlreadyUsedInLocations.includes(columnNumber)) {
|
|
17
|
+
return
|
|
18
|
+
}
|
|
19
|
+
let { text } = row.cells[columnNumber]
|
|
20
|
+
if (column.dataType.type === 'Number') {
|
|
21
|
+
text = parseFloat(text)
|
|
22
|
+
}
|
|
23
|
+
otherData[column.name] = text
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
// make the final feature data out of otherData + the parsed locations
|
|
27
|
+
return {
|
|
28
|
+
...otherData,
|
|
29
|
+
uniqueId: `sv-inspector-adhoc-${rowNumber}`,
|
|
30
|
+
refName: loc1.refName,
|
|
31
|
+
start: loc1.start,
|
|
32
|
+
end: loc1.end,
|
|
33
|
+
mate: {
|
|
34
|
+
refName: loc2.refName,
|
|
35
|
+
start: loc2.start,
|
|
36
|
+
end: loc2.end,
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function makeAdHocSvFeatureFromTwoLocations(
|
|
42
|
+
columns,
|
|
43
|
+
locationColumnNumbers,
|
|
44
|
+
row,
|
|
45
|
+
rowNumber,
|
|
46
|
+
isValidRefName,
|
|
47
|
+
) {
|
|
48
|
+
// use the first two locations we found (first according to *displayed* order)
|
|
49
|
+
const loc1 = parseLocString(
|
|
50
|
+
row.cells[locationColumnNumbers[0]].text,
|
|
51
|
+
isValidRefName,
|
|
52
|
+
)
|
|
53
|
+
const loc2 = parseLocString(
|
|
54
|
+
row.cells[locationColumnNumbers[1]].text,
|
|
55
|
+
isValidRefName,
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const columnsAlreadyUsedInLocations = [
|
|
59
|
+
locationColumnNumbers[0],
|
|
60
|
+
locationColumnNumbers[1],
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
return makeAdHocFeature(
|
|
64
|
+
columns,
|
|
65
|
+
columnsAlreadyUsedInLocations,
|
|
66
|
+
row,
|
|
67
|
+
loc1,
|
|
68
|
+
loc2,
|
|
69
|
+
rowNumber,
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function makeAdHocSvFeatureFromTwoRefStartEndSets(
|
|
74
|
+
columns,
|
|
75
|
+
locRefColumnNumbers,
|
|
76
|
+
locStartColumnNumbers,
|
|
77
|
+
locEndColumnNumbers,
|
|
78
|
+
row,
|
|
79
|
+
rowNumber,
|
|
80
|
+
) {
|
|
81
|
+
const textOf = colno => row.cells[colno].text
|
|
82
|
+
const loc1 = {
|
|
83
|
+
refName: textOf(locRefColumnNumbers[0]),
|
|
84
|
+
start: parseInt(textOf(locStartColumnNumbers[0]), 10) - 1,
|
|
85
|
+
end: parseInt(textOf(locEndColumnNumbers[0]), 10),
|
|
86
|
+
}
|
|
87
|
+
const loc2 = {
|
|
88
|
+
refName: textOf(locRefColumnNumbers[1]),
|
|
89
|
+
start: parseInt(textOf(locStartColumnNumbers[1]), 10) - 1,
|
|
90
|
+
end: parseInt(textOf(locEndColumnNumbers[1]), 10),
|
|
91
|
+
}
|
|
92
|
+
const columnsAlreadyUsedInLocations = [
|
|
93
|
+
locRefColumnNumbers[0],
|
|
94
|
+
locStartColumnNumbers[0],
|
|
95
|
+
locEndColumnNumbers[0],
|
|
96
|
+
locRefColumnNumbers[1],
|
|
97
|
+
locStartColumnNumbers[1],
|
|
98
|
+
locEndColumnNumbers[1],
|
|
99
|
+
]
|
|
100
|
+
return makeAdHocFeature(
|
|
101
|
+
columns,
|
|
102
|
+
columnsAlreadyUsedInLocations,
|
|
103
|
+
row,
|
|
104
|
+
loc1,
|
|
105
|
+
loc2,
|
|
106
|
+
rowNumber,
|
|
107
|
+
)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// makes a feature data object (passed as `data` to a SimpleFeature constructor)
|
|
111
|
+
// out of table row if the row has 2 location columns. undefined if not
|
|
112
|
+
export function makeAdHocSvFeature(sheet, rowNumber, row, isValidRefName) {
|
|
113
|
+
const { columns, columnDisplayOrder } = sheet
|
|
114
|
+
const columnTypes = {}
|
|
115
|
+
columnDisplayOrder.forEach(columnNumber => {
|
|
116
|
+
const columnDefinition = columns[columnNumber]
|
|
117
|
+
if (!columnTypes[columnDefinition.dataType.type]) {
|
|
118
|
+
columnTypes[columnDefinition.dataType.type] = []
|
|
119
|
+
}
|
|
120
|
+
columnTypes[columnDefinition.dataType.type].push(columnNumber)
|
|
121
|
+
})
|
|
122
|
+
const locationColumnNumbers = columnTypes.LocString || []
|
|
123
|
+
const locStartColumnNumbers = columnTypes.LocStart || []
|
|
124
|
+
const locEndColumnNumbers = columnTypes.LocEnd || []
|
|
125
|
+
const locRefColumnNumbers = columnTypes.LocRef || []
|
|
126
|
+
|
|
127
|
+
// if we have 2 or more columns of type location, make a feature from them
|
|
128
|
+
if (locationColumnNumbers.length >= 2) {
|
|
129
|
+
return makeAdHocSvFeatureFromTwoLocations(
|
|
130
|
+
columns,
|
|
131
|
+
locationColumnNumbers,
|
|
132
|
+
row,
|
|
133
|
+
rowNumber,
|
|
134
|
+
isValidRefName,
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
if (
|
|
138
|
+
locRefColumnNumbers.length >= 2 &&
|
|
139
|
+
locStartColumnNumbers.length >= 2 &&
|
|
140
|
+
locEndColumnNumbers.length >= 2
|
|
141
|
+
) {
|
|
142
|
+
return makeAdHocSvFeatureFromTwoRefStartEndSets(
|
|
143
|
+
columns,
|
|
144
|
+
locRefColumnNumbers,
|
|
145
|
+
locStartColumnNumbers,
|
|
146
|
+
locEndColumnNumbers,
|
|
147
|
+
row,
|
|
148
|
+
rowNumber,
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
return undefined
|
|
152
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { SimpleFeature, getEnv, getSession } from '@jbrowse/core/util'
|
|
2
|
+
import { makeAdHocSvFeature } from './adhocFeatureUtils'
|
|
3
|
+
|
|
4
|
+
export function getFeatureForRow(session, spreadsheetView, row, rowNumber) {
|
|
5
|
+
return (
|
|
6
|
+
row.extendedData?.vcfFeature ||
|
|
7
|
+
row.extendedData?.feature ||
|
|
8
|
+
makeAdHocSvFeature(
|
|
9
|
+
spreadsheetView.spreadsheet,
|
|
10
|
+
rowNumber,
|
|
11
|
+
row,
|
|
12
|
+
session.assemblyManager.isValidRefName,
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function breakpointSplitViewSnapshotFromTableRow(
|
|
18
|
+
svInspectorView,
|
|
19
|
+
spreadsheetView,
|
|
20
|
+
spreadsheet,
|
|
21
|
+
row,
|
|
22
|
+
rowNumber,
|
|
23
|
+
) {
|
|
24
|
+
const { pluginManager } = getEnv(svInspectorView)
|
|
25
|
+
const session = getSession(spreadsheetView)
|
|
26
|
+
const featureData = getFeatureForRow(session, spreadsheet, row, rowNumber)
|
|
27
|
+
|
|
28
|
+
if (featureData) {
|
|
29
|
+
const feature = new SimpleFeature(featureData)
|
|
30
|
+
session.setSelection(feature)
|
|
31
|
+
return pluginManager
|
|
32
|
+
.getViewType('BreakpointSplitView')
|
|
33
|
+
.snapshotFromBreakendFeature(feature, svInspectorView.circularView)
|
|
34
|
+
}
|
|
35
|
+
return undefined
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function openBreakpointSplitViewFromTableRow(
|
|
39
|
+
svInspectorView,
|
|
40
|
+
spreadsheetView,
|
|
41
|
+
spreadsheet,
|
|
42
|
+
row,
|
|
43
|
+
rowNumber,
|
|
44
|
+
) {
|
|
45
|
+
const viewSnapshot = breakpointSplitViewSnapshotFromTableRow(
|
|
46
|
+
svInspectorView,
|
|
47
|
+
spreadsheetView,
|
|
48
|
+
spreadsheet,
|
|
49
|
+
row,
|
|
50
|
+
rowNumber,
|
|
51
|
+
)
|
|
52
|
+
if (viewSnapshot) {
|
|
53
|
+
// try to center the offsetPx
|
|
54
|
+
const { circularView } = svInspectorView
|
|
55
|
+
viewSnapshot.views[0].offsetPx -= circularView.width / 2 + 100
|
|
56
|
+
viewSnapshot.views[1].offsetPx -= circularView.width / 2 + 100
|
|
57
|
+
|
|
58
|
+
const session = getSession(spreadsheetView)
|
|
59
|
+
session.addView('BreakpointSplitView', viewSnapshot)
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function canOpenBreakpointSplitViewFromTableRow(
|
|
64
|
+
svInspectorView,
|
|
65
|
+
spreadsheetView,
|
|
66
|
+
spreadsheet,
|
|
67
|
+
row,
|
|
68
|
+
rowNumber,
|
|
69
|
+
) {
|
|
70
|
+
try {
|
|
71
|
+
return Boolean(
|
|
72
|
+
breakpointSplitViewSnapshotFromTableRow(
|
|
73
|
+
svInspectorView,
|
|
74
|
+
spreadsheetView,
|
|
75
|
+
spreadsheet,
|
|
76
|
+
row,
|
|
77
|
+
rowNumber,
|
|
78
|
+
),
|
|
79
|
+
)
|
|
80
|
+
} catch (e) {
|
|
81
|
+
console.error('Unable to open breakpoint split view from table row', e)
|
|
82
|
+
return false
|
|
83
|
+
}
|
|
84
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import Plugin from '@jbrowse/core/Plugin'
|
|
3
|
+
import {
|
|
4
|
+
AbstractSessionModel,
|
|
5
|
+
isAbstractMenuManager,
|
|
6
|
+
} from '@jbrowse/core/util/types'
|
|
7
|
+
|
|
8
|
+
// icons
|
|
9
|
+
import TableChartIcon from '@mui/icons-material/TableChart'
|
|
10
|
+
|
|
11
|
+
// locals
|
|
12
|
+
import SvInspectorViewF from './SvInspectorView'
|
|
13
|
+
import LaunchSvInspectorViewF from './LaunchSvInspectorView'
|
|
14
|
+
|
|
15
|
+
export default class SvInspectorViewPlugin extends Plugin {
|
|
16
|
+
name = 'SvInspectorViewPlugin'
|
|
17
|
+
|
|
18
|
+
install(pluginManager: PluginManager) {
|
|
19
|
+
SvInspectorViewF(pluginManager)
|
|
20
|
+
LaunchSvInspectorViewF(pluginManager)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
configure(pluginManager: PluginManager) {
|
|
24
|
+
if (isAbstractMenuManager(pluginManager.rootModel)) {
|
|
25
|
+
pluginManager.rootModel.appendToSubMenu(['Add'], {
|
|
26
|
+
label: 'SV inspector',
|
|
27
|
+
icon: TableChartIcon,
|
|
28
|
+
onClick: (session: AbstractSessionModel) => {
|
|
29
|
+
session.addView('SvInspectorView', {})
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|