@jbrowse/plugin-dotplot-view 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/ComparativeRenderer/index.d.ts +27 -0
- package/dist/ComparativeRenderer/index.js +59 -0
- package/dist/ComparativeRenderer/index.js.map +1 -0
- package/dist/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
- package/dist/DotplotDisplay/components/DotplotDisplay.js +24 -0
- package/dist/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
- package/dist/DotplotDisplay/index.d.ts +12 -0
- package/dist/DotplotDisplay/index.js +48 -0
- package/dist/DotplotDisplay/index.js.map +1 -0
- package/dist/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
- package/dist/DotplotDisplay/renderDotplotBlock.js +57 -0
- package/dist/DotplotDisplay/renderDotplotBlock.js.map +1 -0
- package/dist/DotplotDisplay/stateModelFactory.d.ts +138 -0
- package/dist/DotplotDisplay/stateModelFactory.js +165 -0
- package/dist/DotplotDisplay/stateModelFactory.js.map +1 -0
- package/dist/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
- package/dist/DotplotReadVsRef/DotplotReadVsRef.js +102 -0
- package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
- package/dist/DotplotReadVsRef/index.d.ts +2 -0
- package/dist/DotplotReadVsRef/index.js +42 -0
- package/dist/DotplotReadVsRef/index.js.map +1 -0
- package/dist/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
- package/dist/DotplotRenderer/ComparativeRenderRpc.js +59 -0
- package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
- package/dist/DotplotRenderer/DotplotRenderer.d.ts +69 -0
- package/dist/DotplotRenderer/DotplotRenderer.js +274 -0
- package/dist/DotplotRenderer/DotplotRenderer.js.map +1 -0
- package/dist/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
- package/dist/DotplotRenderer/components/DotplotRendering.js +13 -0
- package/dist/DotplotRenderer/components/DotplotRendering.js.map +1 -0
- package/dist/DotplotRenderer/configSchema.d.ts +61 -0
- package/dist/DotplotRenderer/configSchema.js +83 -0
- package/dist/DotplotRenderer/configSchema.js.map +1 -0
- package/dist/DotplotRenderer/index.d.ts +3 -0
- package/dist/DotplotRenderer/index.js +17 -0
- package/dist/DotplotRenderer/index.js.map +1 -0
- package/dist/DotplotView/1dview.d.ts +307 -0
- package/dist/DotplotView/1dview.js +95 -0
- package/dist/DotplotView/1dview.js.map +1 -0
- package/dist/DotplotView/blockTypes.d.ts +61 -0
- package/dist/DotplotView/blockTypes.js +117 -0
- package/dist/DotplotView/blockTypes.js.map +1 -0
- package/dist/DotplotView/components/Axes.d.ts +14 -0
- package/dist/DotplotView/components/Axes.js +127 -0
- package/dist/DotplotView/components/Axes.js.map +1 -0
- package/dist/DotplotView/components/CursorIcon.d.ts +4 -0
- package/dist/DotplotView/components/CursorIcon.js +19 -0
- package/dist/DotplotView/components/CursorIcon.js.map +1 -0
- package/dist/DotplotView/components/DotplotTooltip.d.ts +19 -0
- package/dist/DotplotView/components/DotplotTooltip.js +128 -0
- package/dist/DotplotView/components/DotplotTooltip.js.map +1 -0
- package/dist/DotplotView/components/DotplotView.d.ts +6 -0
- package/dist/DotplotView/components/DotplotView.js +272 -0
- package/dist/DotplotView/components/DotplotView.js.map +1 -0
- package/dist/DotplotView/components/DotplotWarnings.d.ts +6 -0
- package/dist/DotplotView/components/DotplotWarnings.js +40 -0
- package/dist/DotplotView/components/DotplotWarnings.js.map +1 -0
- package/dist/DotplotView/components/ExportSvgDialog.d.ts +8 -0
- package/dist/DotplotView/components/ExportSvgDialog.js +76 -0
- package/dist/DotplotView/components/ExportSvgDialog.js.map +1 -0
- package/dist/DotplotView/components/Grid.d.ts +10 -0
- package/dist/DotplotView/components/Grid.js +60 -0
- package/dist/DotplotView/components/Grid.js.map +1 -0
- package/dist/DotplotView/components/Header.d.ts +10 -0
- package/dist/DotplotView/components/Header.js +168 -0
- package/dist/DotplotView/components/Header.js.map +1 -0
- package/dist/DotplotView/components/ImportCustomTrack.d.ts +11 -0
- package/dist/DotplotView/components/ImportCustomTrack.js +180 -0
- package/dist/DotplotView/components/ImportCustomTrack.js.map +1 -0
- package/dist/DotplotView/components/ImportForm.d.ts +6 -0
- package/dist/DotplotView/components/ImportForm.js +121 -0
- package/dist/DotplotView/components/ImportForm.js.map +1 -0
- package/dist/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
- package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +69 -0
- package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
- package/dist/DotplotView/components/PanButtons.d.ts +6 -0
- package/dist/DotplotView/components/PanButtons.js +60 -0
- package/dist/DotplotView/components/PanButtons.js.map +1 -0
- package/dist/DotplotView/components/WarningDialog.d.ts +16 -0
- package/dist/DotplotView/components/WarningDialog.js +41 -0
- package/dist/DotplotView/components/WarningDialog.js.map +1 -0
- package/dist/DotplotView/components/util.d.ts +19 -0
- package/dist/DotplotView/components/util.js +90 -0
- package/dist/DotplotView/components/util.js.map +1 -0
- package/dist/DotplotView/index.d.ts +2 -0
- package/dist/DotplotView/index.js +44 -0
- package/dist/DotplotView/index.js.map +1 -0
- package/dist/DotplotView/model.d.ts +616 -0
- package/dist/DotplotView/model.js +647 -0
- package/dist/DotplotView/model.js.map +1 -0
- package/dist/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
- package/dist/DotplotView/svgcomponents/SVGBackground.js +13 -0
- package/dist/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
- package/dist/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
- package/dist/DotplotView/svgcomponents/SVGDotplotView.js +47 -0
- package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
- package/dist/LaunchDotplotView.d.ts +2 -0
- package/dist/LaunchDotplotView.js +45 -0
- package/dist/LaunchDotplotView.js.map +1 -0
- package/dist/ServerSideRenderedBlockContent.d.ts +12 -0
- package/dist/ServerSideRenderedBlockContent.js +87 -0
- package/dist/ServerSideRenderedBlockContent.js.map +1 -0
- package/dist/ServerSideSyntenyRendering.d.ts +23 -0
- package/dist/ServerSideSyntenyRendering.js +54 -0
- package/dist/ServerSideSyntenyRendering.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/util.d.ts +9 -0
- package/dist/util.js +9 -0
- package/dist/util.js.map +1 -0
- package/esm/ComparativeRenderer/index.d.ts +27 -0
- package/esm/ComparativeRenderer/index.js +53 -0
- package/esm/ComparativeRenderer/index.js.map +1 -0
- package/esm/DotplotDisplay/components/DotplotDisplay.d.ts +8 -0
- package/esm/DotplotDisplay/components/DotplotDisplay.js +19 -0
- package/esm/DotplotDisplay/components/DotplotDisplay.js.map +1 -0
- package/esm/DotplotDisplay/index.d.ts +12 -0
- package/esm/DotplotDisplay/index.js +41 -0
- package/esm/DotplotDisplay/index.js.map +1 -0
- package/esm/DotplotDisplay/renderDotplotBlock.d.ts +11 -0
- package/esm/DotplotDisplay/renderDotplotBlock.js +49 -0
- package/esm/DotplotDisplay/renderDotplotBlock.js.map +1 -0
- package/esm/DotplotDisplay/stateModelFactory.d.ts +138 -0
- package/esm/DotplotDisplay/stateModelFactory.js +158 -0
- package/esm/DotplotDisplay/stateModelFactory.js.map +1 -0
- package/esm/DotplotReadVsRef/DotplotReadVsRef.d.ts +3 -0
- package/esm/DotplotReadVsRef/DotplotReadVsRef.js +98 -0
- package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +1 -0
- package/esm/DotplotReadVsRef/index.d.ts +2 -0
- package/esm/DotplotReadVsRef/index.js +36 -0
- package/esm/DotplotReadVsRef/index.js.map +1 -0
- package/esm/DotplotRenderer/ComparativeRenderRpc.d.ts +27 -0
- package/esm/DotplotRenderer/ComparativeRenderRpc.js +53 -0
- package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +1 -0
- package/esm/DotplotRenderer/DotplotRenderer.d.ts +69 -0
- package/esm/DotplotRenderer/DotplotRenderer.js +268 -0
- package/esm/DotplotRenderer/DotplotRenderer.js.map +1 -0
- package/esm/DotplotRenderer/components/DotplotRendering.d.ts +5 -0
- package/esm/DotplotRenderer/components/DotplotRendering.js +8 -0
- package/esm/DotplotRenderer/components/DotplotRendering.js.map +1 -0
- package/esm/DotplotRenderer/configSchema.d.ts +61 -0
- package/esm/DotplotRenderer/configSchema.js +81 -0
- package/esm/DotplotRenderer/configSchema.js.map +1 -0
- package/esm/DotplotRenderer/index.d.ts +3 -0
- package/esm/DotplotRenderer/index.js +12 -0
- package/esm/DotplotRenderer/index.js.map +1 -0
- package/esm/DotplotView/1dview.d.ts +307 -0
- package/esm/DotplotView/1dview.js +87 -0
- package/esm/DotplotView/1dview.js.map +1 -0
- package/esm/DotplotView/blockTypes.d.ts +61 -0
- package/esm/DotplotView/blockTypes.js +109 -0
- package/esm/DotplotView/blockTypes.js.map +1 -0
- package/esm/DotplotView/components/Axes.d.ts +14 -0
- package/esm/DotplotView/components/Axes.js +121 -0
- package/esm/DotplotView/components/Axes.js.map +1 -0
- package/esm/DotplotView/components/CursorIcon.d.ts +4 -0
- package/esm/DotplotView/components/CursorIcon.js +11 -0
- package/esm/DotplotView/components/CursorIcon.js.map +1 -0
- package/esm/DotplotView/components/DotplotTooltip.d.ts +19 -0
- package/esm/DotplotView/components/DotplotTooltip.js +101 -0
- package/esm/DotplotView/components/DotplotTooltip.js.map +1 -0
- package/esm/DotplotView/components/DotplotView.d.ts +6 -0
- package/esm/DotplotView/components/DotplotView.js +244 -0
- package/esm/DotplotView/components/DotplotView.js.map +1 -0
- package/esm/DotplotView/components/DotplotWarnings.d.ts +6 -0
- package/esm/DotplotView/components/DotplotWarnings.js +15 -0
- package/esm/DotplotView/components/DotplotWarnings.js.map +1 -0
- package/esm/DotplotView/components/ExportSvgDialog.d.ts +8 -0
- package/esm/DotplotView/components/ExportSvgDialog.js +50 -0
- package/esm/DotplotView/components/ExportSvgDialog.js.map +1 -0
- package/esm/DotplotView/components/Grid.d.ts +10 -0
- package/esm/DotplotView/components/Grid.js +53 -0
- package/esm/DotplotView/components/Grid.js.map +1 -0
- package/esm/DotplotView/components/Header.d.ts +10 -0
- package/esm/DotplotView/components/Header.js +140 -0
- package/esm/DotplotView/components/Header.js.map +1 -0
- package/esm/DotplotView/components/ImportCustomTrack.d.ts +11 -0
- package/esm/DotplotView/components/ImportCustomTrack.js +152 -0
- package/esm/DotplotView/components/ImportCustomTrack.js.map +1 -0
- package/esm/DotplotView/components/ImportForm.d.ts +6 -0
- package/esm/DotplotView/components/ImportForm.js +93 -0
- package/esm/DotplotView/components/ImportForm.js.map +1 -0
- package/esm/DotplotView/components/ImportSyntenyTrackSelector.d.ts +9 -0
- package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +44 -0
- package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +1 -0
- package/esm/DotplotView/components/PanButtons.d.ts +6 -0
- package/esm/DotplotView/components/PanButtons.js +55 -0
- package/esm/DotplotView/components/PanButtons.js.map +1 -0
- package/esm/DotplotView/components/WarningDialog.d.ts +16 -0
- package/esm/DotplotView/components/WarningDialog.js +36 -0
- package/esm/DotplotView/components/WarningDialog.js.map +1 -0
- package/esm/DotplotView/components/util.d.ts +19 -0
- package/esm/DotplotView/components/util.js +83 -0
- package/esm/DotplotView/components/util.js.map +1 -0
- package/esm/DotplotView/index.d.ts +2 -0
- package/esm/DotplotView/index.js +15 -0
- package/esm/DotplotView/index.js.map +1 -0
- package/esm/DotplotView/model.d.ts +616 -0
- package/esm/DotplotView/model.js +616 -0
- package/esm/DotplotView/model.js.map +1 -0
- package/esm/DotplotView/svgcomponents/SVGBackground.d.ts +5 -0
- package/esm/DotplotView/svgcomponents/SVGBackground.js +7 -0
- package/esm/DotplotView/svgcomponents/SVGBackground.js.map +1 -0
- package/esm/DotplotView/svgcomponents/SVGDotplotView.d.ts +2 -0
- package/esm/DotplotView/svgcomponents/SVGDotplotView.js +40 -0
- package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +1 -0
- package/esm/LaunchDotplotView.d.ts +2 -0
- package/esm/LaunchDotplotView.js +42 -0
- package/esm/LaunchDotplotView.js.map +1 -0
- package/esm/ServerSideRenderedBlockContent.d.ts +12 -0
- package/esm/ServerSideRenderedBlockContent.js +62 -0
- package/esm/ServerSideRenderedBlockContent.js.map +1 -0
- package/esm/ServerSideSyntenyRendering.d.ts +23 -0
- package/esm/ServerSideSyntenyRendering.js +29 -0
- package/esm/ServerSideSyntenyRendering.js.map +1 -0
- package/esm/index.d.ts +7 -0
- package/esm/index.js +38 -0
- package/esm/index.js.map +1 -0
- package/esm/util.d.ts +9 -0
- package/esm/util.js +5 -0
- package/esm/util.js.map +1 -0
- package/package.json +69 -0
- package/src/ComparativeRenderer/index.ts +87 -0
- package/src/DotplotDisplay/components/DotplotDisplay.tsx +34 -0
- package/src/DotplotDisplay/index.ts +48 -0
- package/src/DotplotDisplay/renderDotplotBlock.ts +60 -0
- package/src/DotplotDisplay/stateModelFactory.tsx +196 -0
- package/src/DotplotReadVsRef/DotplotReadVsRef.ts +115 -0
- package/src/DotplotReadVsRef/index.ts +50 -0
- package/src/DotplotRenderer/ComparativeRenderRpc.ts +87 -0
- package/src/DotplotRenderer/DotplotRenderer.ts +328 -0
- package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
- package/src/DotplotRenderer/components/DotplotRendering.tsx +12 -0
- package/src/DotplotRenderer/configSchema.ts +92 -0
- package/src/DotplotRenderer/index.ts +16 -0
- package/src/DotplotView/1dview.ts +98 -0
- package/src/DotplotView/blockTypes.ts +140 -0
- package/src/DotplotView/components/Axes.tsx +246 -0
- package/src/DotplotView/components/CursorIcon.tsx +24 -0
- package/src/DotplotView/components/DotplotTooltip.tsx +163 -0
- package/src/DotplotView/components/DotplotView.tsx +348 -0
- package/src/DotplotView/components/DotplotWarnings.tsx +26 -0
- package/src/DotplotView/components/ExportSvgDialog.tsx +129 -0
- package/src/DotplotView/components/Grid.tsx +112 -0
- package/src/DotplotView/components/Header.tsx +182 -0
- package/src/DotplotView/components/ImportCustomTrack.tsx +262 -0
- package/src/DotplotView/components/ImportForm.tsx +209 -0
- package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +90 -0
- package/src/DotplotView/components/PanButtons.tsx +93 -0
- package/src/DotplotView/components/WarningDialog.tsx +74 -0
- package/src/DotplotView/components/util.ts +118 -0
- package/src/DotplotView/index.ts +16 -0
- package/src/DotplotView/model.test.ts +17 -0
- package/src/DotplotView/model.ts +719 -0
- package/src/DotplotView/svgcomponents/SVGBackground.tsx +21 -0
- package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +68 -0
- package/src/LaunchDotplotView.ts +63 -0
- package/src/ServerSideRenderedBlockContent.tsx +86 -0
- package/src/ServerSideSyntenyRendering.tsx +54 -0
- package/src/index.ts +41 -0
- package/src/util.ts +14 -0
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
import React from 'react'
|
|
3
|
+
import { ThemeOptions } from '@mui/material'
|
|
4
|
+
import { types, Instance } from 'mobx-state-tree'
|
|
5
|
+
import {
|
|
6
|
+
getConf,
|
|
7
|
+
ConfigurationReference,
|
|
8
|
+
AnyConfigurationSchemaType,
|
|
9
|
+
} from '@jbrowse/core/configuration'
|
|
10
|
+
import { getParentRenderProps } from '@jbrowse/core/util/tracks'
|
|
11
|
+
import {
|
|
12
|
+
getContainingView,
|
|
13
|
+
makeAbortableReaction,
|
|
14
|
+
ReactRendering,
|
|
15
|
+
} from '@jbrowse/core/util'
|
|
16
|
+
import { BaseDisplay } from '@jbrowse/core/pluggableElementTypes/models'
|
|
17
|
+
|
|
18
|
+
// locals
|
|
19
|
+
import ServerSideRenderedBlockContent from '../ServerSideRenderedBlockContent'
|
|
20
|
+
import { renderBlockData, renderBlockEffect } from './renderDotplotBlock'
|
|
21
|
+
import { DotplotViewModel, ExportSvgOptions } from '../DotplotView/model'
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* #stateModel DotplotDisplay
|
|
25
|
+
* #category display
|
|
26
|
+
*/
|
|
27
|
+
export function stateModelFactory(configSchema: AnyConfigurationSchemaType) {
|
|
28
|
+
return types
|
|
29
|
+
.compose(
|
|
30
|
+
'DotplotDisplay',
|
|
31
|
+
BaseDisplay,
|
|
32
|
+
types
|
|
33
|
+
.model({
|
|
34
|
+
/**
|
|
35
|
+
* #property
|
|
36
|
+
*/
|
|
37
|
+
type: types.literal('DotplotDisplay'),
|
|
38
|
+
/**
|
|
39
|
+
* #property
|
|
40
|
+
*/
|
|
41
|
+
configuration: ConfigurationReference(configSchema),
|
|
42
|
+
})
|
|
43
|
+
.volatile(() => ({
|
|
44
|
+
warnings: [] as { message: string; effect: string }[],
|
|
45
|
+
renderInProgress: undefined as AbortController | undefined,
|
|
46
|
+
filled: false,
|
|
47
|
+
data: undefined as any,
|
|
48
|
+
reactElement: undefined as React.ReactElement | undefined,
|
|
49
|
+
message: undefined as string | undefined,
|
|
50
|
+
renderingComponent: undefined as any,
|
|
51
|
+
ReactComponent2:
|
|
52
|
+
ServerSideRenderedBlockContent as unknown as React.FC<any>,
|
|
53
|
+
})),
|
|
54
|
+
)
|
|
55
|
+
.views(self => ({
|
|
56
|
+
get shouldDisplay() {
|
|
57
|
+
const view = getContainingView(self)
|
|
58
|
+
return (
|
|
59
|
+
view.vview.bpPerPx === self.data.bpPerPxY &&
|
|
60
|
+
view.hview.bpPerPx === self.data.bpPerPxX
|
|
61
|
+
)
|
|
62
|
+
},
|
|
63
|
+
/**
|
|
64
|
+
* #getter
|
|
65
|
+
*/
|
|
66
|
+
get rendererTypeName() {
|
|
67
|
+
return getConf(self, ['renderer', 'type'])
|
|
68
|
+
},
|
|
69
|
+
/**
|
|
70
|
+
* #method
|
|
71
|
+
*/
|
|
72
|
+
renderProps() {
|
|
73
|
+
return {
|
|
74
|
+
...getParentRenderProps(self),
|
|
75
|
+
rpcDriverName: self.rpcDriverName,
|
|
76
|
+
displayModel: self,
|
|
77
|
+
config: self.configuration.renderer,
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
}))
|
|
81
|
+
.views(self => ({
|
|
82
|
+
/**
|
|
83
|
+
* #method
|
|
84
|
+
*/
|
|
85
|
+
async renderSvg(opts: ExportSvgOptions & { theme: ThemeOptions }) {
|
|
86
|
+
const props = renderBlockData(self)
|
|
87
|
+
if (!props) {
|
|
88
|
+
return null
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
const { rendererType, rpcManager, renderProps } = props
|
|
92
|
+
const rendering = await rendererType.renderInClient(rpcManager, {
|
|
93
|
+
...renderProps,
|
|
94
|
+
exportSVG: opts,
|
|
95
|
+
theme: opts.theme || renderProps.theme,
|
|
96
|
+
})
|
|
97
|
+
const { hview, vview } = getContainingView(self) as DotplotViewModel
|
|
98
|
+
const offX = -hview.offsetPx + rendering.offsetX
|
|
99
|
+
const offY = -vview.offsetPx + rendering.offsetY
|
|
100
|
+
return (
|
|
101
|
+
<g transform={`translate(${offX} ${-offY})`}>
|
|
102
|
+
<ReactRendering rendering={rendering} />
|
|
103
|
+
</g>
|
|
104
|
+
)
|
|
105
|
+
},
|
|
106
|
+
}))
|
|
107
|
+
.actions(self => {
|
|
108
|
+
let renderInProgress: undefined | AbortController
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
afterAttach() {
|
|
112
|
+
makeAbortableReaction(
|
|
113
|
+
self,
|
|
114
|
+
() => renderBlockData(self),
|
|
115
|
+
blockData => renderBlockEffect(blockData),
|
|
116
|
+
{
|
|
117
|
+
name: `${self.type} ${self.id} rendering`,
|
|
118
|
+
delay: 500,
|
|
119
|
+
fireImmediately: true,
|
|
120
|
+
},
|
|
121
|
+
this.setLoading,
|
|
122
|
+
this.setRendered,
|
|
123
|
+
this.setError,
|
|
124
|
+
)
|
|
125
|
+
},
|
|
126
|
+
/**
|
|
127
|
+
* #action
|
|
128
|
+
*/
|
|
129
|
+
setLoading(abortController: AbortController) {
|
|
130
|
+
self.filled = false
|
|
131
|
+
self.message = undefined
|
|
132
|
+
self.reactElement = undefined
|
|
133
|
+
self.data = undefined
|
|
134
|
+
self.error = undefined
|
|
135
|
+
self.renderingComponent = undefined
|
|
136
|
+
renderInProgress = abortController
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* #action
|
|
140
|
+
*/
|
|
141
|
+
setMessage(messageText: string) {
|
|
142
|
+
if (renderInProgress && !renderInProgress.signal.aborted) {
|
|
143
|
+
renderInProgress.abort()
|
|
144
|
+
}
|
|
145
|
+
self.filled = false
|
|
146
|
+
self.message = messageText
|
|
147
|
+
self.reactElement = undefined
|
|
148
|
+
self.data = undefined
|
|
149
|
+
self.error = undefined
|
|
150
|
+
self.renderingComponent = undefined
|
|
151
|
+
renderInProgress = undefined
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
* #action
|
|
155
|
+
*/
|
|
156
|
+
setRendered(args?: {
|
|
157
|
+
data: any
|
|
158
|
+
reactElement: React.ReactElement
|
|
159
|
+
renderingComponent: React.Component
|
|
160
|
+
}) {
|
|
161
|
+
if (args === undefined) {
|
|
162
|
+
return
|
|
163
|
+
}
|
|
164
|
+
const { data, reactElement, renderingComponent } = args
|
|
165
|
+
self.warnings = data.warnings
|
|
166
|
+
self.filled = true
|
|
167
|
+
self.message = undefined
|
|
168
|
+
self.reactElement = reactElement
|
|
169
|
+
self.data = data
|
|
170
|
+
self.error = undefined
|
|
171
|
+
self.renderingComponent = renderingComponent
|
|
172
|
+
renderInProgress = undefined
|
|
173
|
+
},
|
|
174
|
+
/**
|
|
175
|
+
* #action
|
|
176
|
+
*/
|
|
177
|
+
setError(error: unknown) {
|
|
178
|
+
console.error(error)
|
|
179
|
+
if (renderInProgress && !renderInProgress.signal.aborted) {
|
|
180
|
+
renderInProgress.abort()
|
|
181
|
+
}
|
|
182
|
+
// the rendering failed for some reason
|
|
183
|
+
self.filled = false
|
|
184
|
+
self.message = undefined
|
|
185
|
+
self.reactElement = undefined
|
|
186
|
+
self.data = undefined
|
|
187
|
+
self.error = error
|
|
188
|
+
self.renderingComponent = undefined
|
|
189
|
+
renderInProgress = undefined
|
|
190
|
+
},
|
|
191
|
+
}
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export type DotplotDisplayStateModel = ReturnType<typeof stateModelFactory>
|
|
196
|
+
export type DotplotDisplayModel = Instance<DotplotDisplayStateModel>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { getConf } from '@jbrowse/core/configuration'
|
|
2
|
+
import { getSession, Feature, gatherOverlaps } from '@jbrowse/core/util'
|
|
3
|
+
import {
|
|
4
|
+
LinearPileupDisplayModel,
|
|
5
|
+
MismatchParser,
|
|
6
|
+
} from '@jbrowse/plugin-alignments'
|
|
7
|
+
|
|
8
|
+
// locals
|
|
9
|
+
import { ReducedFeature } from '../util'
|
|
10
|
+
|
|
11
|
+
const { featurizeSA, getClip, getTag, getLength, getLengthSansClipping } =
|
|
12
|
+
MismatchParser
|
|
13
|
+
|
|
14
|
+
export function onClick(feature: Feature, self: LinearPileupDisplayModel) {
|
|
15
|
+
const session = getSession(self)
|
|
16
|
+
try {
|
|
17
|
+
const cigar = feature.get('CIGAR')
|
|
18
|
+
const clipPos = getClip(cigar, 1)
|
|
19
|
+
const flags = feature.get('flags')
|
|
20
|
+
const strand = feature.get('strand')
|
|
21
|
+
const readName = feature.get('name')
|
|
22
|
+
const readAssembly = `${readName}_assembly_${Date.now()}`
|
|
23
|
+
const { parentTrack } = self
|
|
24
|
+
const [trackAssembly] = getConf(parentTrack, 'assemblyNames')
|
|
25
|
+
const assemblyNames = [trackAssembly, readAssembly]
|
|
26
|
+
const trackId = `track-${Date.now()}`
|
|
27
|
+
const trackName = `${readName}_vs_${trackAssembly}`
|
|
28
|
+
const SA = (getTag(feature, 'SA') as string) || ''
|
|
29
|
+
const SA2 = featurizeSA(SA, feature.id(), strand, readName, true)
|
|
30
|
+
|
|
31
|
+
const feat = feature.toJSON()
|
|
32
|
+
feat.strand = 1
|
|
33
|
+
feat.mate = {
|
|
34
|
+
refName: readName,
|
|
35
|
+
start: clipPos,
|
|
36
|
+
end: clipPos + getLengthSansClipping(cigar),
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
// if secondary alignment or supplementary, calculate length from SA[0]'s
|
|
40
|
+
// CIGAR which is the primary alignments. otherwise it is the primary
|
|
41
|
+
// alignment just use seq.length if primary alignment
|
|
42
|
+
const totalLength = getLength(flags & 2048 ? SA2[0].CIGAR : cigar)
|
|
43
|
+
|
|
44
|
+
const features = [feat, ...SA2] as ReducedFeature[]
|
|
45
|
+
|
|
46
|
+
features.sort((a, b) => a.clipPos - b.clipPos)
|
|
47
|
+
|
|
48
|
+
const refLength = features.reduce((a, f) => a + f.end - f.start, 0)
|
|
49
|
+
|
|
50
|
+
session.addView('DotplotView', {
|
|
51
|
+
type: 'DotplotView',
|
|
52
|
+
hview: {
|
|
53
|
+
offsetPx: 0,
|
|
54
|
+
bpPerPx: refLength / 800,
|
|
55
|
+
displayedRegions: gatherOverlaps(
|
|
56
|
+
features.map((f, index) => {
|
|
57
|
+
const { start, end, refName } = f
|
|
58
|
+
return {
|
|
59
|
+
start,
|
|
60
|
+
end,
|
|
61
|
+
refName,
|
|
62
|
+
index,
|
|
63
|
+
assemblyName: trackAssembly,
|
|
64
|
+
}
|
|
65
|
+
}),
|
|
66
|
+
),
|
|
67
|
+
},
|
|
68
|
+
vview: {
|
|
69
|
+
offsetPx: 0,
|
|
70
|
+
bpPerPx: totalLength / 400,
|
|
71
|
+
minimumBlockWidth: 0,
|
|
72
|
+
interRegionPaddingWidth: 0,
|
|
73
|
+
displayedRegions: [
|
|
74
|
+
{
|
|
75
|
+
assemblyName: readAssembly,
|
|
76
|
+
start: 0,
|
|
77
|
+
end: totalLength,
|
|
78
|
+
refName: readName,
|
|
79
|
+
},
|
|
80
|
+
],
|
|
81
|
+
},
|
|
82
|
+
|
|
83
|
+
viewTrackConfigs: [
|
|
84
|
+
{
|
|
85
|
+
type: 'SyntenyTrack',
|
|
86
|
+
assemblyNames,
|
|
87
|
+
adapter: {
|
|
88
|
+
type: 'FromConfigAdapter',
|
|
89
|
+
features,
|
|
90
|
+
},
|
|
91
|
+
trackId,
|
|
92
|
+
name: trackName,
|
|
93
|
+
},
|
|
94
|
+
],
|
|
95
|
+
assemblyNames,
|
|
96
|
+
tracks: [
|
|
97
|
+
{
|
|
98
|
+
configuration: trackId,
|
|
99
|
+
type: 'SyntenyTrack',
|
|
100
|
+
displays: [
|
|
101
|
+
{
|
|
102
|
+
type: 'DotplotDisplay',
|
|
103
|
+
configuration: `${trackId}-DotplotDisplay`,
|
|
104
|
+
},
|
|
105
|
+
],
|
|
106
|
+
},
|
|
107
|
+
],
|
|
108
|
+
|
|
109
|
+
displayName: `${readName} vs ${trackAssembly}`,
|
|
110
|
+
})
|
|
111
|
+
} catch (e) {
|
|
112
|
+
console.error(e)
|
|
113
|
+
session.notify(`${e}`, 'error')
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import {
|
|
3
|
+
PluggableElementType,
|
|
4
|
+
ViewType,
|
|
5
|
+
} from '@jbrowse/core/pluggableElementTypes'
|
|
6
|
+
import { LinearPileupDisplayModel } from '@jbrowse/plugin-alignments'
|
|
7
|
+
|
|
8
|
+
// icons
|
|
9
|
+
import AddIcon from '@mui/icons-material/Add'
|
|
10
|
+
|
|
11
|
+
// local
|
|
12
|
+
import { onClick } from './DotplotReadVsRef'
|
|
13
|
+
|
|
14
|
+
export default function DotplotReadVsRefMenuItem(pluginManager: PluginManager) {
|
|
15
|
+
pluginManager.addToExtensionPoint(
|
|
16
|
+
'Core-extendPluggableElement',
|
|
17
|
+
(pluggableElement: PluggableElementType) => {
|
|
18
|
+
if (pluggableElement.name === 'LinearPileupDisplay') {
|
|
19
|
+
const { stateModel } = pluggableElement as ViewType
|
|
20
|
+
const newStateModel = stateModel.extend(
|
|
21
|
+
(self: LinearPileupDisplayModel) => {
|
|
22
|
+
const superContextMenuItems = self.contextMenuItems
|
|
23
|
+
return {
|
|
24
|
+
views: {
|
|
25
|
+
contextMenuItems() {
|
|
26
|
+
const feature = self.contextMenuFeature
|
|
27
|
+
return [
|
|
28
|
+
...superContextMenuItems(),
|
|
29
|
+
...(feature
|
|
30
|
+
? [
|
|
31
|
+
{
|
|
32
|
+
label: 'Dotplot of read vs ref',
|
|
33
|
+
icon: AddIcon,
|
|
34
|
+
onClick: () => onClick(feature, self),
|
|
35
|
+
},
|
|
36
|
+
]
|
|
37
|
+
: []),
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
;(pluggableElement as ViewType).stateModel = newStateModel
|
|
46
|
+
}
|
|
47
|
+
return pluggableElement
|
|
48
|
+
},
|
|
49
|
+
)
|
|
50
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { checkAbortSignal } from '@jbrowse/core/util'
|
|
2
|
+
import RpcMethodType from '@jbrowse/core/pluggableElementTypes/RpcMethodType'
|
|
3
|
+
import ComparativeRenderer, {
|
|
4
|
+
RenderArgs as ComparativeRenderArgs,
|
|
5
|
+
RenderArgsSerialized as ComparativeRenderArgsSerialized,
|
|
6
|
+
RenderResults,
|
|
7
|
+
ResultsSerialized,
|
|
8
|
+
} from '@jbrowse/core/pluggableElementTypes/renderers/ComparativeServerSideRendererType'
|
|
9
|
+
import { RemoteAbortSignal } from '@jbrowse/core/rpc/remoteAbortSignals'
|
|
10
|
+
|
|
11
|
+
interface RenderArgs extends ComparativeRenderArgs {
|
|
12
|
+
adapterConfig: {}
|
|
13
|
+
rendererType: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface RenderArgsSerialized extends ComparativeRenderArgsSerialized {
|
|
17
|
+
adapterConfig: {}
|
|
18
|
+
rendererType: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* call a synteny renderer with the given args
|
|
23
|
+
* param views: a set of views that each contain a set of regions
|
|
24
|
+
* used instead of passing regions directly as in render()
|
|
25
|
+
*/
|
|
26
|
+
export default class ComparativeRender extends RpcMethodType {
|
|
27
|
+
name = 'ComparativeRender'
|
|
28
|
+
|
|
29
|
+
async renameRegionsIfNeeded(args: RenderArgs, rend: ComparativeRenderer) {
|
|
30
|
+
return rend.renameRegionsIfNeeded(args)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getRenderer(rendererType: string) {
|
|
34
|
+
const pm = this.pluginManager
|
|
35
|
+
return pm.getRendererType(rendererType) as ComparativeRenderer
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async serializeArguments(args: RenderArgs, rpcDriver: string) {
|
|
39
|
+
const { rendererType } = args
|
|
40
|
+
const renderer = this.getRenderer(rendererType)
|
|
41
|
+
const n = (await super.serializeArguments(args, rpcDriver)) as RenderArgs
|
|
42
|
+
const result = await this.renameRegionsIfNeeded(n, renderer)
|
|
43
|
+
|
|
44
|
+
return rpcDriver === 'MainThreadRpcDriver'
|
|
45
|
+
? result
|
|
46
|
+
: renderer.serializeArgsInClient(result)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async execute(
|
|
50
|
+
args: RenderArgsSerialized & { signal?: RemoteAbortSignal },
|
|
51
|
+
rpcDriver: string,
|
|
52
|
+
) {
|
|
53
|
+
let deserializedArgs = args
|
|
54
|
+
if (rpcDriver !== 'MainThreadRpcDriver') {
|
|
55
|
+
deserializedArgs = await this.deserializeArguments(args, rpcDriver)
|
|
56
|
+
}
|
|
57
|
+
const { sessionId, rendererType, signal } = deserializedArgs
|
|
58
|
+
if (!sessionId) {
|
|
59
|
+
throw new Error('must pass a unique session id')
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
checkAbortSignal(signal)
|
|
63
|
+
|
|
64
|
+
const renderer = this.getRenderer(rendererType)
|
|
65
|
+
return rpcDriver === 'MainThreadRpcDriver'
|
|
66
|
+
? renderer.render(deserializedArgs)
|
|
67
|
+
: renderer.renderInWorker(deserializedArgs)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async deserializeReturn(
|
|
71
|
+
val: RenderResults | ResultsSerialized,
|
|
72
|
+
args: RenderArgs,
|
|
73
|
+
rpcDriver: string,
|
|
74
|
+
): Promise<unknown> {
|
|
75
|
+
const ret = (await super.deserializeReturn(
|
|
76
|
+
val,
|
|
77
|
+
args,
|
|
78
|
+
rpcDriver,
|
|
79
|
+
)) as ResultsSerialized
|
|
80
|
+
if (rpcDriver === 'MainThreadRpcDriver') {
|
|
81
|
+
return ret
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const renderer = this.getRenderer(args.rendererType)
|
|
85
|
+
return renderer.deserializeResultsInClient(ret, args)
|
|
86
|
+
}
|
|
87
|
+
}
|