@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,21 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { useTheme } from '@mui/material'
|
|
3
|
+
|
|
4
|
+
export default function SVGBackground({
|
|
5
|
+
width,
|
|
6
|
+
height,
|
|
7
|
+
}: {
|
|
8
|
+
width: number
|
|
9
|
+
height: number
|
|
10
|
+
}) {
|
|
11
|
+
const theme = useTheme()
|
|
12
|
+
return (
|
|
13
|
+
<rect
|
|
14
|
+
x={0}
|
|
15
|
+
y={0}
|
|
16
|
+
width={width}
|
|
17
|
+
height={height}
|
|
18
|
+
fill={theme.palette.background.default}
|
|
19
|
+
/>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import { renderToStaticMarkup } from 'react-dom/server'
|
|
3
|
+
import { when } from 'mobx'
|
|
4
|
+
import { getSession } from '@jbrowse/core/util'
|
|
5
|
+
import { ThemeProvider } from '@mui/material'
|
|
6
|
+
import { createJBrowseTheme } from '@jbrowse/core/ui'
|
|
7
|
+
|
|
8
|
+
// locals
|
|
9
|
+
import { DotplotViewModel, ExportSvgOptions } from '../model'
|
|
10
|
+
import { GridRaw } from '../components/Grid'
|
|
11
|
+
import { HorizontalAxisRaw, VerticalAxisRaw } from '../components/Axes'
|
|
12
|
+
import SVGBackground from './SVGBackground'
|
|
13
|
+
|
|
14
|
+
// render LGV to SVG
|
|
15
|
+
export async function renderToSvg(
|
|
16
|
+
model: DotplotViewModel,
|
|
17
|
+
opts: ExportSvgOptions,
|
|
18
|
+
) {
|
|
19
|
+
await when(() => model.initialized)
|
|
20
|
+
const { themeName = 'default', Wrapper = ({ children }) => <>{children}</> } =
|
|
21
|
+
opts
|
|
22
|
+
const session = getSession(model)
|
|
23
|
+
const theme = session.allThemes?.()[themeName]
|
|
24
|
+
const { width, borderX, viewWidth, viewHeight, tracks, height } = model
|
|
25
|
+
const shift = 50
|
|
26
|
+
const displayResults = await Promise.all(
|
|
27
|
+
tracks.map(async track => {
|
|
28
|
+
const display = track.displays[0]
|
|
29
|
+
await when(() => (display.ready !== undefined ? display.ready : true))
|
|
30
|
+
return { track, result: await display.renderSvg({ ...opts, theme }) }
|
|
31
|
+
}),
|
|
32
|
+
)
|
|
33
|
+
const w = width + shift * 2
|
|
34
|
+
|
|
35
|
+
// the xlink namespace is used for rendering <image> tag
|
|
36
|
+
return renderToStaticMarkup(
|
|
37
|
+
<ThemeProvider theme={createJBrowseTheme(theme)}>
|
|
38
|
+
<Wrapper>
|
|
39
|
+
<svg
|
|
40
|
+
width={width}
|
|
41
|
+
height={height}
|
|
42
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
43
|
+
xmlnsXlink="http://www.w3.org/1999/xlink"
|
|
44
|
+
viewBox={[0, 0, w, height].toString()}
|
|
45
|
+
>
|
|
46
|
+
<SVGBackground width={w} height={height} />
|
|
47
|
+
<VerticalAxisRaw model={model} />
|
|
48
|
+
<g transform={`translate(${borderX} 0)`}>
|
|
49
|
+
<GridRaw model={model} />
|
|
50
|
+
<defs>
|
|
51
|
+
<clipPath id="clip-ruler">
|
|
52
|
+
<rect x={0} y={0} width={viewWidth} height={viewHeight} />
|
|
53
|
+
</clipPath>
|
|
54
|
+
</defs>
|
|
55
|
+
<g clipPath="url(#clip-ruler)">
|
|
56
|
+
{displayResults.map(({ result }, i) => (
|
|
57
|
+
<g key={i}>{result}</g>
|
|
58
|
+
))}
|
|
59
|
+
</g>
|
|
60
|
+
</g>
|
|
61
|
+
<g transform={`translate(${borderX} ${viewHeight})`}>
|
|
62
|
+
<HorizontalAxisRaw model={model} />
|
|
63
|
+
</g>
|
|
64
|
+
</svg>
|
|
65
|
+
</Wrapper>
|
|
66
|
+
</ThemeProvider>,
|
|
67
|
+
)
|
|
68
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
2
|
+
import { AbstractSessionModel } from '@jbrowse/core/util'
|
|
3
|
+
import { DotplotViewModel } from './DotplotView/model'
|
|
4
|
+
import { transaction } from 'mobx'
|
|
5
|
+
|
|
6
|
+
export default function LaunchDotplotView(pluginManager: PluginManager) {
|
|
7
|
+
pluginManager.addToExtensionPoint(
|
|
8
|
+
'LaunchView-DotplotView',
|
|
9
|
+
// @ts-expect-error
|
|
10
|
+
async ({
|
|
11
|
+
session,
|
|
12
|
+
views,
|
|
13
|
+
tracks = [],
|
|
14
|
+
}: {
|
|
15
|
+
session: AbstractSessionModel
|
|
16
|
+
views: { loc: string; assembly: string; tracks?: string[] }[]
|
|
17
|
+
tracks?: string[]
|
|
18
|
+
}) => {
|
|
19
|
+
try {
|
|
20
|
+
const model = session.addView('DotplotView', {}) as DotplotViewModel
|
|
21
|
+
const assemblyNames = views.map(view => view.assembly)
|
|
22
|
+
|
|
23
|
+
transaction(() => {
|
|
24
|
+
model.setViews([
|
|
25
|
+
{ bpPerPx: 0.1, offsetPx: 0 },
|
|
26
|
+
{ bpPerPx: 0.1, offsetPx: 0 },
|
|
27
|
+
])
|
|
28
|
+
model.setAssemblyNames(assemblyNames[0], assemblyNames[1])
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
// http://localhost:3000/?config=test_data%2Fvolvox%2Fconfig.json&session=spec-{"views":[{"type":"DotplotView","views":[{"assembly":"volvox"},{"assembly":"volvox"}],"tracks":["volvox_fake_synteny"]}]}
|
|
32
|
+
|
|
33
|
+
const idsNotFound = [] as string[]
|
|
34
|
+
tracks.forEach(track => tryTrack(model, track, idsNotFound))
|
|
35
|
+
|
|
36
|
+
if (idsNotFound.length) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Could not resolve identifiers: ${idsNotFound.join(',')}`,
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
} catch (e) {
|
|
42
|
+
session.notify(`${e}`, 'error')
|
|
43
|
+
throw e
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function tryTrack(
|
|
50
|
+
model: { showTrack: (arg: string) => void },
|
|
51
|
+
trackId: string,
|
|
52
|
+
idsNotFound: string[],
|
|
53
|
+
) {
|
|
54
|
+
try {
|
|
55
|
+
model.showTrack(trackId)
|
|
56
|
+
} catch (e) {
|
|
57
|
+
if (`${e}`.match('Could not resolve identifier')) {
|
|
58
|
+
idsNotFound.push(trackId)
|
|
59
|
+
} else {
|
|
60
|
+
throw e
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import React, { useEffect, useState, CSSProperties } from 'react'
|
|
2
|
+
import { makeStyles } from 'tss-react/mui'
|
|
3
|
+
import { Typography } from '@mui/material'
|
|
4
|
+
import { LoadingEllipses } from '@jbrowse/core/ui'
|
|
5
|
+
import { observer } from 'mobx-react'
|
|
6
|
+
|
|
7
|
+
const useStyles = makeStyles()(theme => {
|
|
8
|
+
const bg = theme.palette.action.disabledBackground
|
|
9
|
+
return {
|
|
10
|
+
loading: {
|
|
11
|
+
paddingLeft: '0.6em',
|
|
12
|
+
backgroundColor: theme.palette.background.default,
|
|
13
|
+
backgroundImage: `repeating-linear-gradient(45deg, transparent, transparent 5px, ${bg} 5px, ${bg} 10px)`,
|
|
14
|
+
textAlign: 'center',
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
blockMessage: {
|
|
18
|
+
backgroundColor: bg,
|
|
19
|
+
padding: '10px',
|
|
20
|
+
},
|
|
21
|
+
blockError: {
|
|
22
|
+
backgroundColor: bg,
|
|
23
|
+
padding: '10px',
|
|
24
|
+
color: 'red',
|
|
25
|
+
},
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
function LoadingMessage() {
|
|
30
|
+
// only show the loading message after 300ms to prevent excessive flickering
|
|
31
|
+
const [shown, setShown] = useState(false)
|
|
32
|
+
const { classes } = useStyles()
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
const timeout = setTimeout(() => setShown(true), 300)
|
|
35
|
+
return () => clearTimeout(timeout)
|
|
36
|
+
}, [])
|
|
37
|
+
|
|
38
|
+
return shown ? (
|
|
39
|
+
<div className={classes.loading}>
|
|
40
|
+
<LoadingEllipses />
|
|
41
|
+
</div>
|
|
42
|
+
) : null
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function BlockMessage({ messageText }: { messageText: string }) {
|
|
46
|
+
const { classes } = useStyles()
|
|
47
|
+
return (
|
|
48
|
+
<div className={classes.blockMessage}>
|
|
49
|
+
<Typography>{`${messageText}`}</Typography>
|
|
50
|
+
</div>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function BlockError({ error }: { error: unknown }) {
|
|
55
|
+
const { classes } = useStyles()
|
|
56
|
+
return (
|
|
57
|
+
<div className={classes.blockError}>
|
|
58
|
+
<Typography>{`${error}`}</Typography>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export default observer(function ({
|
|
64
|
+
model,
|
|
65
|
+
style,
|
|
66
|
+
}: {
|
|
67
|
+
model: {
|
|
68
|
+
error?: unknown
|
|
69
|
+
message?: string
|
|
70
|
+
filled?: boolean
|
|
71
|
+
shouldDisplay?: boolean
|
|
72
|
+
reactElement?: React.ReactElement
|
|
73
|
+
}
|
|
74
|
+
style: CSSProperties
|
|
75
|
+
}) {
|
|
76
|
+
if (model.error) {
|
|
77
|
+
return <BlockError error={model.error} data-testid="reload_button" />
|
|
78
|
+
} else if (model.message) {
|
|
79
|
+
return <BlockMessage messageText={model.message} />
|
|
80
|
+
} else if (!model.filled) {
|
|
81
|
+
return <LoadingMessage />
|
|
82
|
+
} else if (model.shouldDisplay) {
|
|
83
|
+
return <div style={style}>{model.reactElement}</div>
|
|
84
|
+
}
|
|
85
|
+
return null
|
|
86
|
+
})
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
+
import React, { useRef, useState, useEffect } from 'react'
|
|
3
|
+
import { observer, PropTypes } from 'mobx-react'
|
|
4
|
+
import { drawImageOntoCanvasContext } from '@jbrowse/core/util/offscreenCanvasPonyfill'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A block whose content is rendered outside of the main thread and hydrated by this
|
|
8
|
+
* component.
|
|
9
|
+
*/
|
|
10
|
+
function ServerSideSyntenyRendering({
|
|
11
|
+
model,
|
|
12
|
+
}: {
|
|
13
|
+
model: {
|
|
14
|
+
imageData: string
|
|
15
|
+
style: Record<string, string>
|
|
16
|
+
renderProps: {
|
|
17
|
+
width: number
|
|
18
|
+
height: number
|
|
19
|
+
highResolutionScaling?: number
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}) {
|
|
23
|
+
const { imageData, style, renderProps } = model
|
|
24
|
+
const { width, height, highResolutionScaling = 1 } = renderProps
|
|
25
|
+
|
|
26
|
+
const featureCanvas = useRef<HTMLCanvasElement>(null)
|
|
27
|
+
const [done, setDone] = useState(false)
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (!imageData) {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
const canvas = featureCanvas.current!
|
|
34
|
+
const context = canvas.getContext('2d')!
|
|
35
|
+
drawImageOntoCanvasContext(imageData, context)
|
|
36
|
+
setDone(true)
|
|
37
|
+
}, [height, imageData, width])
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<canvas
|
|
41
|
+
data-testid={`prerendered_canvas${done ? '_done' : ''}`}
|
|
42
|
+
ref={featureCanvas}
|
|
43
|
+
width={width * highResolutionScaling}
|
|
44
|
+
height={height * highResolutionScaling}
|
|
45
|
+
style={{ width, height, ...style }}
|
|
46
|
+
/>
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ServerSideSyntenyRendering.propTypes = {
|
|
51
|
+
model: PropTypes.observableObject.isRequired,
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export default observer(ServerSideSyntenyRendering)
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import Plugin from '@jbrowse/core/Plugin'
|
|
2
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
3
|
+
import { AbstractSessionModel, isAbstractMenuManager } from '@jbrowse/core/util'
|
|
4
|
+
|
|
5
|
+
// icons
|
|
6
|
+
import TimelineIcon from '@mui/icons-material/Timeline'
|
|
7
|
+
|
|
8
|
+
// locals
|
|
9
|
+
import DotplotViewF from './DotplotView'
|
|
10
|
+
import DotplotDisplayF from './DotplotDisplay'
|
|
11
|
+
import DotplotRendererF from './DotplotRenderer'
|
|
12
|
+
import LaunchDotplotViewF from './LaunchDotplotView'
|
|
13
|
+
import ComparativeRenderer from './ComparativeRenderer'
|
|
14
|
+
import DotplotReadVsRefMenuItem from './DotplotReadVsRef'
|
|
15
|
+
|
|
16
|
+
export default class DotplotPlugin extends Plugin {
|
|
17
|
+
name = 'DotplotPlugin'
|
|
18
|
+
|
|
19
|
+
install(pluginManager: PluginManager) {
|
|
20
|
+
DotplotViewF(pluginManager)
|
|
21
|
+
DotplotDisplayF(pluginManager)
|
|
22
|
+
DotplotRendererF(pluginManager)
|
|
23
|
+
LaunchDotplotViewF(pluginManager)
|
|
24
|
+
DotplotReadVsRefMenuItem(pluginManager)
|
|
25
|
+
|
|
26
|
+
// install our comparative rendering rpc callback
|
|
27
|
+
pluginManager.addRpcMethod(() => new ComparativeRenderer(pluginManager))
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
configure(pluginManager: PluginManager) {
|
|
31
|
+
if (isAbstractMenuManager(pluginManager.rootModel)) {
|
|
32
|
+
pluginManager.rootModel.appendToSubMenu(['Add'], {
|
|
33
|
+
label: 'Dotplot view',
|
|
34
|
+
icon: TimelineIcon,
|
|
35
|
+
onClick: (session: AbstractSessionModel) => {
|
|
36
|
+
session.addView('DotplotView', {})
|
|
37
|
+
},
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
package/src/util.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Feature } from '@jbrowse/core/util'
|
|
2
|
+
|
|
3
|
+
export interface ReducedFeature {
|
|
4
|
+
refName: string
|
|
5
|
+
start: number
|
|
6
|
+
clipPos: number
|
|
7
|
+
end: number
|
|
8
|
+
seqLength: number
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function getTag(f: Feature, tag: string) {
|
|
12
|
+
const tags = f.get('tags')
|
|
13
|
+
return tags ? tags[tag] : f.get(tag)
|
|
14
|
+
}
|