@jbrowse/plugin-dotplot-view 2.6.1 → 2.6.2

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.
Files changed (188) hide show
  1. package/dist/ComparativeRenderer/index.js +0 -1
  2. package/dist/DotplotDisplay/components/DotplotDisplay.js +0 -1
  3. package/dist/DotplotDisplay/index.js +0 -1
  4. package/dist/DotplotDisplay/renderDotplotBlock.js +0 -1
  5. package/dist/DotplotDisplay/stateModelFactory.js +0 -1
  6. package/dist/DotplotReadVsRef/DotplotReadVsRef.js +0 -1
  7. package/dist/DotplotReadVsRef/index.js +0 -1
  8. package/dist/DotplotRenderer/ComparativeRenderRpc.js +0 -1
  9. package/dist/DotplotRenderer/DotplotRenderer.js +0 -1
  10. package/dist/DotplotRenderer/components/DotplotRendering.js +0 -1
  11. package/dist/DotplotRenderer/configSchema.js +0 -1
  12. package/dist/DotplotRenderer/index.js +0 -1
  13. package/dist/DotplotView/1dview.js +0 -1
  14. package/dist/DotplotView/blockTypes.js +0 -1
  15. package/dist/DotplotView/components/Axes.js +0 -1
  16. package/dist/DotplotView/components/CursorIcon.js +0 -1
  17. package/dist/DotplotView/components/DotplotTooltip.js +0 -1
  18. package/dist/DotplotView/components/DotplotView.js +0 -1
  19. package/dist/DotplotView/components/DotplotWarnings.js +0 -1
  20. package/dist/DotplotView/components/ExportSvgDialog.js +0 -1
  21. package/dist/DotplotView/components/Grid.js +0 -1
  22. package/dist/DotplotView/components/Header.js +0 -1
  23. package/dist/DotplotView/components/ImportCustomTrack.js +0 -1
  24. package/dist/DotplotView/components/ImportForm.js +0 -1
  25. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js +0 -1
  26. package/dist/DotplotView/components/PanButtons.js +0 -1
  27. package/dist/DotplotView/components/WarningDialog.js +0 -1
  28. package/dist/DotplotView/components/util.js +0 -1
  29. package/dist/DotplotView/index.js +0 -1
  30. package/dist/DotplotView/model.js +0 -1
  31. package/dist/DotplotView/svgcomponents/SVGBackground.js +0 -1
  32. package/dist/DotplotView/svgcomponents/SVGDotplotView.js +0 -1
  33. package/dist/LaunchDotplotView.js +0 -1
  34. package/dist/ServerSideRenderedBlockContent.js +0 -1
  35. package/dist/ServerSideSyntenyRendering.js +0 -1
  36. package/dist/index.js +0 -1
  37. package/dist/util.js +0 -1
  38. package/esm/ComparativeRenderer/index.js +0 -1
  39. package/esm/DotplotDisplay/components/DotplotDisplay.js +0 -1
  40. package/esm/DotplotDisplay/index.js +0 -1
  41. package/esm/DotplotDisplay/renderDotplotBlock.js +0 -1
  42. package/esm/DotplotDisplay/stateModelFactory.js +0 -1
  43. package/esm/DotplotReadVsRef/DotplotReadVsRef.js +0 -1
  44. package/esm/DotplotReadVsRef/index.js +0 -1
  45. package/esm/DotplotRenderer/ComparativeRenderRpc.js +0 -1
  46. package/esm/DotplotRenderer/DotplotRenderer.js +0 -1
  47. package/esm/DotplotRenderer/components/DotplotRendering.js +0 -1
  48. package/esm/DotplotRenderer/configSchema.js +0 -1
  49. package/esm/DotplotRenderer/index.js +0 -1
  50. package/esm/DotplotView/1dview.js +0 -1
  51. package/esm/DotplotView/blockTypes.js +0 -1
  52. package/esm/DotplotView/components/Axes.js +0 -1
  53. package/esm/DotplotView/components/CursorIcon.js +0 -1
  54. package/esm/DotplotView/components/DotplotTooltip.js +0 -1
  55. package/esm/DotplotView/components/DotplotView.js +0 -1
  56. package/esm/DotplotView/components/DotplotWarnings.js +0 -1
  57. package/esm/DotplotView/components/ExportSvgDialog.js +0 -1
  58. package/esm/DotplotView/components/Grid.js +0 -1
  59. package/esm/DotplotView/components/Header.js +0 -1
  60. package/esm/DotplotView/components/ImportCustomTrack.js +0 -1
  61. package/esm/DotplotView/components/ImportForm.js +0 -1
  62. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js +0 -1
  63. package/esm/DotplotView/components/PanButtons.js +0 -1
  64. package/esm/DotplotView/components/WarningDialog.js +0 -1
  65. package/esm/DotplotView/components/util.js +0 -1
  66. package/esm/DotplotView/index.js +0 -1
  67. package/esm/DotplotView/model.js +0 -1
  68. package/esm/DotplotView/svgcomponents/SVGBackground.js +0 -1
  69. package/esm/DotplotView/svgcomponents/SVGDotplotView.js +0 -1
  70. package/esm/LaunchDotplotView.js +0 -1
  71. package/esm/ServerSideRenderedBlockContent.js +0 -1
  72. package/esm/ServerSideSyntenyRendering.js +0 -1
  73. package/esm/index.js +0 -1
  74. package/esm/util.js +0 -1
  75. package/package.json +3 -4
  76. package/dist/ComparativeRenderer/index.js.map +0 -1
  77. package/dist/DotplotDisplay/components/DotplotDisplay.js.map +0 -1
  78. package/dist/DotplotDisplay/index.js.map +0 -1
  79. package/dist/DotplotDisplay/renderDotplotBlock.js.map +0 -1
  80. package/dist/DotplotDisplay/stateModelFactory.js.map +0 -1
  81. package/dist/DotplotReadVsRef/DotplotReadVsRef.js.map +0 -1
  82. package/dist/DotplotReadVsRef/index.js.map +0 -1
  83. package/dist/DotplotRenderer/ComparativeRenderRpc.js.map +0 -1
  84. package/dist/DotplotRenderer/DotplotRenderer.js.map +0 -1
  85. package/dist/DotplotRenderer/components/DotplotRendering.js.map +0 -1
  86. package/dist/DotplotRenderer/configSchema.js.map +0 -1
  87. package/dist/DotplotRenderer/index.js.map +0 -1
  88. package/dist/DotplotView/1dview.js.map +0 -1
  89. package/dist/DotplotView/blockTypes.js.map +0 -1
  90. package/dist/DotplotView/components/Axes.js.map +0 -1
  91. package/dist/DotplotView/components/CursorIcon.js.map +0 -1
  92. package/dist/DotplotView/components/DotplotTooltip.js.map +0 -1
  93. package/dist/DotplotView/components/DotplotView.js.map +0 -1
  94. package/dist/DotplotView/components/DotplotWarnings.js.map +0 -1
  95. package/dist/DotplotView/components/ExportSvgDialog.js.map +0 -1
  96. package/dist/DotplotView/components/Grid.js.map +0 -1
  97. package/dist/DotplotView/components/Header.js.map +0 -1
  98. package/dist/DotplotView/components/ImportCustomTrack.js.map +0 -1
  99. package/dist/DotplotView/components/ImportForm.js.map +0 -1
  100. package/dist/DotplotView/components/ImportSyntenyTrackSelector.js.map +0 -1
  101. package/dist/DotplotView/components/PanButtons.js.map +0 -1
  102. package/dist/DotplotView/components/WarningDialog.js.map +0 -1
  103. package/dist/DotplotView/components/util.js.map +0 -1
  104. package/dist/DotplotView/index.js.map +0 -1
  105. package/dist/DotplotView/model.js.map +0 -1
  106. package/dist/DotplotView/svgcomponents/SVGBackground.js.map +0 -1
  107. package/dist/DotplotView/svgcomponents/SVGDotplotView.js.map +0 -1
  108. package/dist/LaunchDotplotView.js.map +0 -1
  109. package/dist/ServerSideRenderedBlockContent.js.map +0 -1
  110. package/dist/ServerSideSyntenyRendering.js.map +0 -1
  111. package/dist/index.js.map +0 -1
  112. package/dist/util.js.map +0 -1
  113. package/esm/ComparativeRenderer/index.js.map +0 -1
  114. package/esm/DotplotDisplay/components/DotplotDisplay.js.map +0 -1
  115. package/esm/DotplotDisplay/index.js.map +0 -1
  116. package/esm/DotplotDisplay/renderDotplotBlock.js.map +0 -1
  117. package/esm/DotplotDisplay/stateModelFactory.js.map +0 -1
  118. package/esm/DotplotReadVsRef/DotplotReadVsRef.js.map +0 -1
  119. package/esm/DotplotReadVsRef/index.js.map +0 -1
  120. package/esm/DotplotRenderer/ComparativeRenderRpc.js.map +0 -1
  121. package/esm/DotplotRenderer/DotplotRenderer.js.map +0 -1
  122. package/esm/DotplotRenderer/components/DotplotRendering.js.map +0 -1
  123. package/esm/DotplotRenderer/configSchema.js.map +0 -1
  124. package/esm/DotplotRenderer/index.js.map +0 -1
  125. package/esm/DotplotView/1dview.js.map +0 -1
  126. package/esm/DotplotView/blockTypes.js.map +0 -1
  127. package/esm/DotplotView/components/Axes.js.map +0 -1
  128. package/esm/DotplotView/components/CursorIcon.js.map +0 -1
  129. package/esm/DotplotView/components/DotplotTooltip.js.map +0 -1
  130. package/esm/DotplotView/components/DotplotView.js.map +0 -1
  131. package/esm/DotplotView/components/DotplotWarnings.js.map +0 -1
  132. package/esm/DotplotView/components/ExportSvgDialog.js.map +0 -1
  133. package/esm/DotplotView/components/Grid.js.map +0 -1
  134. package/esm/DotplotView/components/Header.js.map +0 -1
  135. package/esm/DotplotView/components/ImportCustomTrack.js.map +0 -1
  136. package/esm/DotplotView/components/ImportForm.js.map +0 -1
  137. package/esm/DotplotView/components/ImportSyntenyTrackSelector.js.map +0 -1
  138. package/esm/DotplotView/components/PanButtons.js.map +0 -1
  139. package/esm/DotplotView/components/WarningDialog.js.map +0 -1
  140. package/esm/DotplotView/components/util.js.map +0 -1
  141. package/esm/DotplotView/index.js.map +0 -1
  142. package/esm/DotplotView/model.js.map +0 -1
  143. package/esm/DotplotView/svgcomponents/SVGBackground.js.map +0 -1
  144. package/esm/DotplotView/svgcomponents/SVGDotplotView.js.map +0 -1
  145. package/esm/LaunchDotplotView.js.map +0 -1
  146. package/esm/ServerSideRenderedBlockContent.js.map +0 -1
  147. package/esm/ServerSideSyntenyRendering.js.map +0 -1
  148. package/esm/index.js.map +0 -1
  149. package/esm/util.js.map +0 -1
  150. package/src/ComparativeRenderer/index.ts +0 -87
  151. package/src/DotplotDisplay/components/DotplotDisplay.tsx +0 -34
  152. package/src/DotplotDisplay/index.ts +0 -48
  153. package/src/DotplotDisplay/renderDotplotBlock.ts +0 -60
  154. package/src/DotplotDisplay/stateModelFactory.tsx +0 -196
  155. package/src/DotplotReadVsRef/DotplotReadVsRef.ts +0 -115
  156. package/src/DotplotReadVsRef/index.ts +0 -50
  157. package/src/DotplotRenderer/ComparativeRenderRpc.ts +0 -87
  158. package/src/DotplotRenderer/DotplotRenderer.ts +0 -328
  159. package/src/DotplotRenderer/__image_snapshots__/linear-synteny-renderer-test-ts-test-rendering-a-simple-synteny-from-fake-data-1-snap.png +0 -0
  160. package/src/DotplotRenderer/components/DotplotRendering.tsx +0 -12
  161. package/src/DotplotRenderer/configSchema.ts +0 -92
  162. package/src/DotplotRenderer/index.ts +0 -16
  163. package/src/DotplotView/1dview.ts +0 -98
  164. package/src/DotplotView/blockTypes.ts +0 -140
  165. package/src/DotplotView/components/Axes.tsx +0 -246
  166. package/src/DotplotView/components/CursorIcon.tsx +0 -24
  167. package/src/DotplotView/components/DotplotTooltip.tsx +0 -163
  168. package/src/DotplotView/components/DotplotView.tsx +0 -348
  169. package/src/DotplotView/components/DotplotWarnings.tsx +0 -26
  170. package/src/DotplotView/components/ExportSvgDialog.tsx +0 -129
  171. package/src/DotplotView/components/Grid.tsx +0 -112
  172. package/src/DotplotView/components/Header.tsx +0 -182
  173. package/src/DotplotView/components/ImportCustomTrack.tsx +0 -262
  174. package/src/DotplotView/components/ImportForm.tsx +0 -209
  175. package/src/DotplotView/components/ImportSyntenyTrackSelector.tsx +0 -90
  176. package/src/DotplotView/components/PanButtons.tsx +0 -93
  177. package/src/DotplotView/components/WarningDialog.tsx +0 -74
  178. package/src/DotplotView/components/util.ts +0 -118
  179. package/src/DotplotView/index.ts +0 -16
  180. package/src/DotplotView/model.test.ts +0 -17
  181. package/src/DotplotView/model.ts +0 -719
  182. package/src/DotplotView/svgcomponents/SVGBackground.tsx +0 -21
  183. package/src/DotplotView/svgcomponents/SVGDotplotView.tsx +0 -68
  184. package/src/LaunchDotplotView.ts +0 -63
  185. package/src/ServerSideRenderedBlockContent.tsx +0 -86
  186. package/src/ServerSideSyntenyRendering.tsx +0 -54
  187. package/src/index.ts +0 -41
  188. package/src/util.ts +0 -14
@@ -1,87 +0,0 @@
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
- }
@@ -1,328 +0,0 @@
1
- import {
2
- readConfObject,
3
- AnyConfigurationModel,
4
- } from '@jbrowse/core/configuration'
5
- import {
6
- renameRegionsIfNeeded,
7
- renderToAbstractCanvas,
8
- Region,
9
- Feature,
10
- } from '@jbrowse/core/util'
11
- import { bpToPx } from '@jbrowse/core/util/Base1DUtils'
12
- import { getSnapshot } from 'mobx-state-tree'
13
- import ComparativeRenderer, {
14
- RenderArgsDeserialized,
15
- RenderArgs,
16
- } from '@jbrowse/core/pluggableElementTypes/renderers/ComparativeServerSideRendererType'
17
- import { MismatchParser } from '@jbrowse/plugin-alignments'
18
-
19
- // locals
20
- import { Dotplot1DView, Dotplot1DViewModel } from '../DotplotView/model'
21
- import { createJBrowseTheme } from '@jbrowse/core/ui'
22
-
23
- const { parseCigar } = MismatchParser
24
-
25
- export interface DotplotRenderArgsDeserialized extends RenderArgsDeserialized {
26
- height: number
27
- width: number
28
- highResolutionScaling: number
29
- view: {
30
- hview: Dotplot1DViewModel
31
- vview: Dotplot1DViewModel
32
- }
33
- }
34
-
35
- interface DotplotRenderArgs extends RenderArgs {
36
- adapterConfig: AnyConfigurationModel
37
- sessionId: string
38
- view: {
39
- hview: { displayedRegions: Region[] }
40
- vview: { displayedRegions: Region[] }
41
- }
42
- }
43
-
44
- const r = 'fell outside of range due to CIGAR string'
45
- const lt = '(less than min coordinate of feature)'
46
- const gt = '(greater than max coordinate of feature)'
47
- const fudgeFactor = 1 // allow 1px fuzzyness before warn
48
-
49
- function drawCir(ctx: CanvasRenderingContext2D, x: number, y: number, r = 1) {
50
- ctx.beginPath()
51
- ctx.arc(x, y, r / 2, 0, 2 * Math.PI)
52
- ctx.fill()
53
- }
54
-
55
- export default class DotplotRenderer extends ComparativeRenderer {
56
- supportsSVG = true
57
-
58
- async renameRegionsIfNeeded(args: DotplotRenderArgs) {
59
- const pm = this.pluginManager
60
- const assemblyManager = pm.rootModel?.session?.assemblyManager
61
-
62
- const { view, sessionId, adapterConfig } = args
63
-
64
- async function process(regions?: Region[]) {
65
- if (!assemblyManager) {
66
- throw new Error('No assembly manager provided')
67
- }
68
- const result = await renameRegionsIfNeeded(assemblyManager, {
69
- sessionId,
70
- adapterConfig,
71
- regions,
72
- })
73
- return result.regions
74
- }
75
-
76
- view.hview.displayedRegions = await process(view.hview.displayedRegions)
77
- view.vview.displayedRegions = await process(view.vview.displayedRegions)
78
-
79
- return args
80
- }
81
-
82
- async drawDotplot(
83
- ctx: CanvasRenderingContext2D,
84
- props: DotplotRenderArgsDeserialized & { views: Dotplot1DViewModel[] },
85
- ) {
86
- const { config, views, height, drawCigar, theme } = props
87
- const color = readConfObject(config, 'color')
88
- const posColor = readConfObject(config, 'posColor')
89
- const negColor = readConfObject(config, 'negColor')
90
- const colorBy = readConfObject(config, 'colorBy')
91
- const lineWidth = readConfObject(config, 'lineWidth')
92
- const thresholds = readConfObject(config, 'thresholds')
93
- const palette = readConfObject(config, 'thresholdsPalette')
94
- const isCallback = config.color.isCallback
95
- const [hview, vview] = views
96
- const db1 = hview.dynamicBlocks.contentBlocks[0]?.offsetPx
97
- const db2 = vview.dynamicBlocks.contentBlocks[0]?.offsetPx
98
- const warnings = [] as { message: string; effect: string }[]
99
- ctx.lineWidth = lineWidth
100
-
101
- // we operate on snapshots of these attributes of the hview/vview because
102
- // it is significantly faster than accessing the mobx objects
103
- const { bpPerPx: hBpPerPx } = hview
104
- const { bpPerPx: vBpPerPx } = vview
105
-
106
- function clampWithWarnX(
107
- num: number,
108
- min: number,
109
- max: number,
110
- feature: Feature,
111
- ) {
112
- const strand = feature.get('strand') || 1
113
- if (strand === -1) {
114
- ;[max, min] = [min, max]
115
- }
116
- if (num < min - fudgeFactor) {
117
- let start = feature.get('start')
118
- let end = feature.get('end')
119
- const refName = feature.get('refName')
120
- if (strand === -1) {
121
- ;[end, start] = [start, end]
122
- }
123
-
124
- warnings.push({
125
- message: `feature at (X ${refName}:${start}-${end}) ${r} ${lt}`,
126
- effect: 'clipped the feature',
127
- })
128
- return min
129
- }
130
- if (num > max + fudgeFactor) {
131
- const strand = feature.get('strand') || 1
132
- const start = strand === 1 ? feature.get('start') : feature.get('end')
133
- const end = strand === 1 ? feature.get('end') : feature.get('start')
134
- const refName = feature.get('refName')
135
-
136
- warnings.push({
137
- message: `feature at (X ${refName}:${start}-${end}) ${r} ${gt}`,
138
- effect: 'clipped the feature',
139
- })
140
- return max
141
- }
142
- return num
143
- }
144
-
145
- function clampWithWarnY(
146
- num: number,
147
- min: number,
148
- max: number,
149
- feature: Feature,
150
- ) {
151
- if (num < min - fudgeFactor) {
152
- const mate = feature.get('mate')
153
- const { refName, start, end } = mate
154
- warnings.push({
155
- message: `feature at (Y ${refName}:${start}-${end}) ${r} ${lt}`,
156
- effect: 'clipped the feature',
157
- })
158
- return min
159
- }
160
- if (num > max + fudgeFactor) {
161
- const mate = feature.get('mate')
162
- const { refName, start, end } = mate
163
-
164
- warnings.push({
165
- message: `feature at (Y ${refName}:${start}-${end}) ${r} ${gt}`,
166
- effect: 'clipped the feature',
167
- })
168
- return max
169
- }
170
- return num
171
- }
172
-
173
- const hsnap = {
174
- ...getSnapshot(hview),
175
- staticBlocks: hview.staticBlocks,
176
- width: hview.width,
177
- }
178
- const vsnap = {
179
- ...getSnapshot(vview),
180
- staticBlocks: vview.staticBlocks,
181
- width: vview.width,
182
- }
183
- const t = createJBrowseTheme(theme)
184
- hview.features?.forEach(feature => {
185
- const strand = feature.get('strand') || 1
186
- const start = strand === 1 ? feature.get('start') : feature.get('end')
187
- const end = strand === 1 ? feature.get('end') : feature.get('start')
188
- const refName = feature.get('refName')
189
- const mate = feature.get('mate')
190
- const mateRef = mate.refName
191
-
192
- let r
193
- if (colorBy === 'identity') {
194
- const identity = feature.get('identity')
195
- for (let i = 0; i < thresholds.length; i++) {
196
- if (identity > +thresholds[i]) {
197
- r = palette[i]
198
- break
199
- }
200
- }
201
- } else if (colorBy === 'meanQueryIdentity') {
202
- r = `hsl(${feature.get('meanScore') * 200},100%,40%)`
203
- } else if (colorBy === 'mappingQuality') {
204
- r = `hsl(${feature.get('mappingQual')},100%,40%)`
205
- } else if (colorBy === 'strand') {
206
- r = strand === -1 ? negColor : posColor
207
- } else if (colorBy === 'default') {
208
- r = isCallback
209
- ? readConfObject(config, 'color', { feature })
210
- : color === '#f0f'
211
- ? t.palette.text.primary
212
- : color
213
- }
214
- ctx.fillStyle = r
215
- ctx.strokeStyle = r
216
-
217
- const b10 = bpToPx({ self: hsnap, refName, coord: start })
218
- const b20 = bpToPx({ self: hsnap, refName, coord: end })
219
- const e10 = bpToPx({ self: vsnap, refName: mateRef, coord: mate.start })
220
- const e20 = bpToPx({ self: vsnap, refName: mateRef, coord: mate.end })
221
- if (
222
- b10 !== undefined &&
223
- b20 !== undefined &&
224
- e10 !== undefined &&
225
- e20 !== undefined
226
- ) {
227
- const b1 = b10.offsetPx - db1
228
- const b2 = b20.offsetPx - db1
229
- const e1 = e10.offsetPx - db2
230
- const e2 = e20.offsetPx - db2
231
- if (Math.abs(b1 - b2) <= 4 && Math.abs(e1 - e2) <= 4) {
232
- drawCir(ctx, b1, height - e1, lineWidth)
233
- } else {
234
- let currX = b1
235
- let currY = e1
236
- const cigar = feature.get('CIGAR')
237
- if (drawCigar && cigar) {
238
- const cigarOps = parseCigar(cigar)
239
-
240
- ctx.beginPath()
241
- ctx.moveTo(currX, height - currY)
242
-
243
- for (let i = 0; i < cigarOps.length; i += 2) {
244
- const val = +cigarOps[i]
245
- const op = cigarOps[i + 1]
246
- if (op === 'M' || op === '=' || op === 'X') {
247
- currX += (val / hBpPerPx) * strand
248
- currY += val / vBpPerPx
249
- } else if (op === 'D' || op === 'N') {
250
- currX += (val / hBpPerPx) * strand
251
- } else if (op === 'I') {
252
- currY += val / vBpPerPx
253
- }
254
- currX = clampWithWarnX(currX, b1, b2, feature)
255
- currY = clampWithWarnY(currY, e1, e2, feature)
256
- ctx.lineTo(currX, height - currY)
257
- }
258
-
259
- ctx.stroke()
260
- } else {
261
- ctx.beginPath()
262
- ctx.moveTo(b1, height - e1)
263
- ctx.lineTo(b2, height - e2)
264
- ctx.stroke()
265
- }
266
- }
267
- } else {
268
- if (warnings.length <= 5) {
269
- if (b10 === undefined || b20 === undefined) {
270
- warnings.push({
271
- message: `feature at (X ${refName}:${start}-${end}) not plotted, fell outside of range`,
272
- effect: 'feature not rendered',
273
- })
274
- } else {
275
- warnings.push({
276
- message: `feature at (Y ${mateRef}:${mate.start}-${mate.end}) not plotted, fell outside of range`,
277
- effect: 'feature not rendered',
278
- })
279
- }
280
- }
281
- }
282
- })
283
-
284
- return { warnings }
285
- }
286
-
287
- async render(renderProps: DotplotRenderArgsDeserialized) {
288
- const {
289
- width,
290
- height,
291
- view: { hview, vview },
292
- } = renderProps
293
- const dimensions = [width, height]
294
- const views = [hview, vview].map((snap, idx) => {
295
- const view = Dotplot1DView.create(snap)
296
- view.setVolatileWidth(dimensions[idx])
297
- return view
298
- })
299
- const target = views[0]
300
- const feats = await this.getFeatures({
301
- ...renderProps,
302
- regions: target.dynamicBlocks.contentBlocks,
303
- })
304
- target.setFeatures(feats)
305
-
306
- const ret = await renderToAbstractCanvas(width, height, renderProps, ctx =>
307
- this.drawDotplot(ctx, { ...renderProps, views }),
308
- )
309
-
310
- const results = await super.render({
311
- ...renderProps,
312
- ...ret,
313
- height,
314
- width,
315
- })
316
-
317
- return {
318
- ...results,
319
- ...ret,
320
- height,
321
- width,
322
- offsetX: views[0].dynamicBlocks.blocks[0]?.offsetPx || 0,
323
- offsetY: views[1].dynamicBlocks.blocks[0]?.offsetPx || 0,
324
- bpPerPxX: views[0].bpPerPx,
325
- bpPerPxY: views[1].bpPerPx,
326
- }
327
- }
328
- }
@@ -1,12 +0,0 @@
1
- import React from 'react'
2
- import { PrerenderedCanvas } from '@jbrowse/core/ui'
3
- import { observer } from 'mobx-react'
4
-
5
- // locals
6
- import { DotplotRenderArgsDeserialized } from '../DotplotRenderer'
7
-
8
- function DotplotRendering(props: DotplotRenderArgsDeserialized) {
9
- return <PrerenderedCanvas {...props} />
10
- }
11
-
12
- export default observer(DotplotRendering)
@@ -1,92 +0,0 @@
1
- import { ConfigurationSchema } from '@jbrowse/core/configuration'
2
- import { types } from 'mobx-state-tree'
3
-
4
- /**
5
- * #config DotplotRenderer
6
- * #category renderer
7
- */
8
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
9
-
10
- export default ConfigurationSchema(
11
- 'DotplotRenderer',
12
- {
13
- /**
14
- * #slot
15
- */
16
- color: {
17
- type: 'color',
18
- description:
19
- 'the color of each feature in a synteny, used with colorBy:default',
20
- defaultValue: '#f0f',
21
- contextVariable: ['feature'],
22
- },
23
-
24
- /**
25
- * #slot
26
- */
27
- posColor: {
28
- type: 'color',
29
- description: 'the color for forward alignments, used with colorBy:strand',
30
- defaultValue: 'blue',
31
- },
32
- /**
33
- * #slot
34
- */
35
- negColor: {
36
- type: 'color',
37
- description: 'the color for reverse alignments, used with colorBy:strand',
38
- defaultValue: 'red',
39
- },
40
-
41
- /**
42
- * #slot
43
- */
44
- lineWidth: {
45
- type: 'number',
46
- description: 'width of the lines to be drawn',
47
- defaultValue: 2.5, // 2.5 is similar to D-GENIES
48
- },
49
-
50
- /**
51
- * #slot
52
- */
53
- colorBy: {
54
- type: 'stringEnum',
55
- model: types.enumeration('colorBy', [
56
- 'identity',
57
- 'meanQueryIdentity',
58
- 'mappingQuality',
59
- 'strand',
60
- 'default',
61
- ]),
62
- description: `Color by options:<br/>
63
- <ul>
64
- <li>"identity" - the identity of the particular hit, similar to D-GENIES, use the other config slots 'thresholds' and 'thresholdsPalette' to define colors for this setting</li>
65
- <li>"meanQueryIdentity" - calculates the weighted mean identity (weighted by alignment length) of all the hits that the query maps to (e.g. if the query is split aligned to many target, uses their weighted mean. can help show patterns of more related and distant synteny after WGD)</li>
66
- <li>"mappingQuality" - uses mapping quality from PAF, some adapters don't have this setting</li>
67
- <li>"strand" - colors negative alignments with negColor and positive alignments with posColor</li>
68
- <li>"default" - uses the 'color' config slot</li>
69
- </ul>`,
70
- defaultValue: 'default',
71
- },
72
-
73
- /**
74
- * #slot
75
- */
76
- thresholdsPalette: {
77
- type: 'stringArray',
78
- defaultValue: ['#094b09', '#2ebd40', '#d5670b', '#ffd84b'],
79
- description: 'threshold colors, used with colorBy:identity',
80
- },
81
-
82
- /**
83
- * #slot
84
- */
85
- thresholds: {
86
- type: 'stringArray',
87
- defaultValue: ['0.75', '0.5', '0.25', '0'],
88
- description: 'threshold breakpoints, used with colorBy:identity',
89
- },
90
- },
91
- { explicitlyTyped: true },
92
- )
@@ -1,16 +0,0 @@
1
- import PluginManager from '@jbrowse/core/PluginManager'
2
- import ReactComponent from './components/DotplotRendering'
3
- import DotplotRenderer from './DotplotRenderer'
4
- import configSchema from './configSchema'
5
-
6
- export default (pluginManager: PluginManager) => {
7
- pluginManager.addRendererType(
8
- () =>
9
- new DotplotRenderer({
10
- name: 'DotplotRenderer',
11
- configSchema: configSchema,
12
- ReactComponent,
13
- pluginManager,
14
- }),
15
- )
16
- }
@@ -1,98 +0,0 @@
1
- import { getParent, Instance } from 'mobx-state-tree'
2
- import { observable } from 'mobx'
3
- import Base1DView from '@jbrowse/core/util/Base1DViewModel'
4
- import calculateDynamicBlocks from '@jbrowse/core/util/calculateDynamicBlocks'
5
-
6
- /**
7
- * #stateModel Dotplot1DView
8
- * ref https://mobx-state-tree.js.org/concepts/volatiles on volatile state used here
9
- */
10
- function x() {} // eslint-disable-line @typescript-eslint/no-unused-vars
11
-
12
- const Dotplot1DView = Base1DView.extend(self => {
13
- const scaleFactor = observable.box(1)
14
- return {
15
- views: {
16
- /**
17
- * #getter
18
- * this uses padding=false and elision=false
19
- */
20
- get dynamicBlocks() {
21
- return calculateDynamicBlocks(self, false, false)
22
- },
23
- /**
24
- * #getter
25
- */
26
-
27
- get scaleFactor() {
28
- return scaleFactor.get()
29
- },
30
-
31
- /**
32
- * #getter
33
- */
34
- get maxBpPerPx() {
35
- return self.totalBp / (self.width - 50)
36
- },
37
-
38
- /**
39
- * #getter
40
- */
41
- get minBpPerPx() {
42
- return 1 / 50
43
- },
44
-
45
- /**
46
- * #getter
47
- */
48
- get maxOffset() {
49
- return self.displayedRegionsTotalPx - self.width * 0.2
50
- },
51
-
52
- /**
53
- * #getter
54
- */
55
- get minOffset() {
56
- return -self.width * 0.8
57
- },
58
- },
59
- actions: {
60
- /**
61
- * #action
62
- */
63
- setScaleFactor(n: number) {
64
- scaleFactor.set(n)
65
- },
66
-
67
- /**
68
- * #action
69
- */
70
- center() {
71
- const centerBp = self.totalBp / 2
72
- const centerPx = centerBp / self.bpPerPx
73
- self.scrollTo(centerPx - self.width / 2)
74
- },
75
- },
76
- }
77
- })
78
-
79
- const DotplotHView = Dotplot1DView.extend(self => ({
80
- views: {
81
- get width() {
82
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
- return getParent<any>(self).viewWidth
84
- },
85
- },
86
- }))
87
-
88
- const DotplotVView = Dotplot1DView.extend(self => ({
89
- views: {
90
- get width() {
91
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
92
- return getParent<any>(self).viewHeight
93
- },
94
- },
95
- }))
96
-
97
- export { DotplotVView, DotplotHView, Dotplot1DView }
98
- export type Dotplot1DViewModel = Instance<typeof Dotplot1DView>