@jbrowse/plugin-linear-genome-view 2.3.3 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (198) hide show
  1. package/dist/BaseLinearDisplay/components/Block.js +1 -1
  2. package/dist/BaseLinearDisplay/components/Block.js.map +1 -1
  3. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +11 -11
  4. package/dist/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js.map +1 -1
  5. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +74 -4
  6. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js +41 -22
  7. package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.js.map +1 -1
  8. package/dist/BaseLinearDisplay/models/configSchema.js +8 -0
  9. package/dist/BaseLinearDisplay/models/configSchema.js.map +1 -1
  10. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +1 -1
  11. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js +5 -0
  12. package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.js.map +1 -1
  13. package/dist/LinearBareDisplay/model.d.ts +62 -4
  14. package/dist/LinearBasicDisplay/model.d.ts +72 -14
  15. package/dist/LinearGenomeView/components/CenterLine.js +2 -2
  16. package/dist/LinearGenomeView/components/CenterLine.js.map +1 -1
  17. package/dist/LinearGenomeView/components/Cytobands.d.ts +118 -0
  18. package/dist/LinearGenomeView/components/Cytobands.js +92 -0
  19. package/dist/LinearGenomeView/components/Cytobands.js.map +1 -0
  20. package/dist/LinearGenomeView/components/ExportSvgDialog.d.ts +1 -1
  21. package/dist/LinearGenomeView/components/ExportSvgDialog.js +24 -3
  22. package/dist/LinearGenomeView/components/ExportSvgDialog.js.map +1 -1
  23. package/dist/LinearGenomeView/components/GetSequenceDialog.js +4 -1
  24. package/dist/LinearGenomeView/components/GetSequenceDialog.js.map +1 -1
  25. package/dist/LinearGenomeView/components/Gridlines.js +1 -1
  26. package/dist/LinearGenomeView/components/Gridlines.js.map +1 -1
  27. package/dist/LinearGenomeView/components/Header.js +3 -4
  28. package/dist/LinearGenomeView/components/Header.js.map +1 -1
  29. package/dist/LinearGenomeView/components/LinearGenomeView.js +1 -1
  30. package/dist/LinearGenomeView/components/MiniControls.js +5 -4
  31. package/dist/LinearGenomeView/components/MiniControls.js.map +1 -1
  32. package/dist/LinearGenomeView/components/OverviewScalebar.d.ts +1 -115
  33. package/dist/LinearGenomeView/components/OverviewScalebar.js +15 -99
  34. package/dist/LinearGenomeView/components/OverviewScalebar.js.map +1 -1
  35. package/dist/LinearGenomeView/components/RubberbandSpan.js +2 -2
  36. package/dist/LinearGenomeView/components/RubberbandSpan.js.map +1 -1
  37. package/dist/LinearGenomeView/components/TrackLabel.js +6 -5
  38. package/dist/LinearGenomeView/components/TrackLabel.js.map +1 -1
  39. package/dist/LinearGenomeView/components/ZoomControls.js +5 -4
  40. package/dist/LinearGenomeView/components/ZoomControls.js.map +1 -1
  41. package/dist/LinearGenomeView/components/util.d.ts +6 -0
  42. package/dist/LinearGenomeView/components/util.js +11 -1
  43. package/dist/LinearGenomeView/components/util.js.map +1 -1
  44. package/dist/LinearGenomeView/model.d.ts +10 -2
  45. package/dist/LinearGenomeView/model.js +6 -6
  46. package/dist/LinearGenomeView/model.js.map +1 -1
  47. package/dist/LinearGenomeView/svgcomponents/SVGBackground.d.ts +6 -0
  48. package/dist/LinearGenomeView/svgcomponents/SVGBackground.js +13 -0
  49. package/dist/LinearGenomeView/svgcomponents/SVGBackground.js.map +1 -0
  50. package/dist/LinearGenomeView/svgcomponents/SVGHeader.d.ts +10 -0
  51. package/dist/LinearGenomeView/svgcomponents/SVGHeader.js +55 -0
  52. package/dist/LinearGenomeView/svgcomponents/SVGHeader.js.map +1 -0
  53. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.d.ts +13 -0
  54. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +56 -0
  55. package/dist/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js.map +1 -0
  56. package/dist/LinearGenomeView/svgcomponents/SVGRegionSeparators.d.ts +8 -0
  57. package/dist/LinearGenomeView/svgcomponents/SVGRegionSeparators.js +13 -0
  58. package/dist/LinearGenomeView/svgcomponents/SVGRegionSeparators.js.map +1 -0
  59. package/dist/LinearGenomeView/svgcomponents/SVGRuler.d.ts +8 -0
  60. package/dist/LinearGenomeView/svgcomponents/SVGRuler.js +51 -0
  61. package/dist/LinearGenomeView/svgcomponents/SVGRuler.js.map +1 -0
  62. package/dist/LinearGenomeView/svgcomponents/SVGScalebar.d.ts +8 -0
  63. package/dist/LinearGenomeView/svgcomponents/SVGScalebar.js +22 -0
  64. package/dist/LinearGenomeView/svgcomponents/SVGScalebar.js.map +1 -0
  65. package/dist/LinearGenomeView/svgcomponents/SVGTrackLabel.d.ts +8 -0
  66. package/dist/LinearGenomeView/svgcomponents/SVGTrackLabel.js +15 -0
  67. package/dist/LinearGenomeView/svgcomponents/SVGTrackLabel.js.map +1 -0
  68. package/dist/LinearGenomeView/svgcomponents/SVGTracks.d.ts +23 -0
  69. package/dist/LinearGenomeView/svgcomponents/SVGTracks.js +30 -0
  70. package/dist/LinearGenomeView/svgcomponents/SVGTracks.js.map +1 -0
  71. package/dist/LinearGenomeView/util.js +1 -1
  72. package/dist/LinearGenomeView/util.js.map +1 -1
  73. package/dist/index.d.ts +133 -18
  74. package/dist/index.js +6 -2
  75. package/dist/index.js.map +1 -1
  76. package/esm/BaseLinearDisplay/components/Block.js +1 -1
  77. package/esm/BaseLinearDisplay/components/Block.js.map +1 -1
  78. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js +11 -11
  79. package/esm/BaseLinearDisplay/components/ServerSideRenderedBlockContent.js.map +1 -1
  80. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +74 -4
  81. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js +42 -23
  82. package/esm/BaseLinearDisplay/models/BaseLinearDisplayModel.js.map +1 -1
  83. package/esm/BaseLinearDisplay/models/configSchema.js +8 -0
  84. package/esm/BaseLinearDisplay/models/configSchema.js.map +1 -1
  85. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +1 -1
  86. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js +5 -0
  87. package/esm/BaseLinearDisplay/models/serverSideRenderedBlock.js.map +1 -1
  88. package/esm/LinearBareDisplay/model.d.ts +62 -4
  89. package/esm/LinearBasicDisplay/model.d.ts +72 -14
  90. package/esm/LinearGenomeView/components/CenterLine.js +2 -2
  91. package/esm/LinearGenomeView/components/CenterLine.js.map +1 -1
  92. package/esm/LinearGenomeView/components/Cytobands.d.ts +118 -0
  93. package/esm/LinearGenomeView/components/Cytobands.js +87 -0
  94. package/esm/LinearGenomeView/components/Cytobands.js.map +1 -0
  95. package/esm/LinearGenomeView/components/ExportSvgDialog.d.ts +1 -1
  96. package/esm/LinearGenomeView/components/ExportSvgDialog.js +25 -4
  97. package/esm/LinearGenomeView/components/ExportSvgDialog.js.map +1 -1
  98. package/esm/LinearGenomeView/components/GetSequenceDialog.js +4 -1
  99. package/esm/LinearGenomeView/components/GetSequenceDialog.js.map +1 -1
  100. package/esm/LinearGenomeView/components/Gridlines.js +1 -1
  101. package/esm/LinearGenomeView/components/Gridlines.js.map +1 -1
  102. package/esm/LinearGenomeView/components/Header.js +5 -6
  103. package/esm/LinearGenomeView/components/Header.js.map +1 -1
  104. package/esm/LinearGenomeView/components/LinearGenomeView.js +1 -1
  105. package/esm/LinearGenomeView/components/MiniControls.js +5 -4
  106. package/esm/LinearGenomeView/components/MiniControls.js.map +1 -1
  107. package/esm/LinearGenomeView/components/OverviewScalebar.d.ts +1 -115
  108. package/esm/LinearGenomeView/components/OverviewScalebar.js +12 -96
  109. package/esm/LinearGenomeView/components/OverviewScalebar.js.map +1 -1
  110. package/esm/LinearGenomeView/components/RubberbandSpan.js +2 -2
  111. package/esm/LinearGenomeView/components/RubberbandSpan.js.map +1 -1
  112. package/esm/LinearGenomeView/components/TrackLabel.js +6 -5
  113. package/esm/LinearGenomeView/components/TrackLabel.js.map +1 -1
  114. package/esm/LinearGenomeView/components/ZoomControls.js +5 -4
  115. package/esm/LinearGenomeView/components/ZoomControls.js.map +1 -1
  116. package/esm/LinearGenomeView/components/util.d.ts +6 -0
  117. package/esm/LinearGenomeView/components/util.js +9 -0
  118. package/esm/LinearGenomeView/components/util.js.map +1 -1
  119. package/esm/LinearGenomeView/model.d.ts +10 -2
  120. package/esm/LinearGenomeView/model.js +4 -4
  121. package/esm/LinearGenomeView/model.js.map +1 -1
  122. package/esm/LinearGenomeView/svgcomponents/SVGBackground.d.ts +6 -0
  123. package/esm/LinearGenomeView/svgcomponents/SVGBackground.js +7 -0
  124. package/esm/LinearGenomeView/svgcomponents/SVGBackground.js.map +1 -0
  125. package/esm/LinearGenomeView/svgcomponents/SVGHeader.d.ts +10 -0
  126. package/esm/LinearGenomeView/svgcomponents/SVGHeader.js +49 -0
  127. package/esm/LinearGenomeView/svgcomponents/SVGHeader.js.map +1 -0
  128. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.d.ts +13 -0
  129. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js +47 -0
  130. package/esm/LinearGenomeView/svgcomponents/SVGLinearGenomeView.js.map +1 -0
  131. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.d.ts +8 -0
  132. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.js +7 -0
  133. package/esm/LinearGenomeView/svgcomponents/SVGRegionSeparators.js.map +1 -0
  134. package/esm/LinearGenomeView/svgcomponents/SVGRuler.d.ts +8 -0
  135. package/esm/LinearGenomeView/svgcomponents/SVGRuler.js +45 -0
  136. package/esm/LinearGenomeView/svgcomponents/SVGRuler.js.map +1 -0
  137. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.d.ts +8 -0
  138. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.js +16 -0
  139. package/esm/LinearGenomeView/svgcomponents/SVGScalebar.js.map +1 -0
  140. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.d.ts +8 -0
  141. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js +9 -0
  142. package/esm/LinearGenomeView/svgcomponents/SVGTrackLabel.js.map +1 -0
  143. package/esm/LinearGenomeView/svgcomponents/SVGTracks.d.ts +23 -0
  144. package/esm/LinearGenomeView/svgcomponents/SVGTracks.js +24 -0
  145. package/esm/LinearGenomeView/svgcomponents/SVGTracks.js.map +1 -0
  146. package/esm/LinearGenomeView/util.js +1 -1
  147. package/esm/LinearGenomeView/util.js.map +1 -1
  148. package/esm/index.d.ts +133 -18
  149. package/esm/index.js +3 -2
  150. package/esm/index.js.map +1 -1
  151. package/package.json +3 -3
  152. package/src/BaseLinearDisplay/components/Block.tsx +1 -1
  153. package/src/BaseLinearDisplay/components/ServerSideRenderedBlockContent.tsx +11 -12
  154. package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +53 -35
  155. package/src/BaseLinearDisplay/models/configSchema.ts +8 -0
  156. package/src/BaseLinearDisplay/models/serverSideRenderedBlock.ts +9 -17
  157. package/src/LinearGenomeView/components/CenterLine.tsx +2 -2
  158. package/src/LinearGenomeView/components/Cytobands.tsx +154 -0
  159. package/src/LinearGenomeView/components/ExportSvgDialog.tsx +56 -4
  160. package/src/LinearGenomeView/components/GetSequenceDialog.tsx +5 -1
  161. package/src/LinearGenomeView/components/Gridlines.tsx +1 -1
  162. package/src/LinearGenomeView/components/Header.tsx +6 -13
  163. package/src/LinearGenomeView/components/LinearGenomeView.test.tsx +8 -11
  164. package/src/LinearGenomeView/components/LinearGenomeView.tsx +1 -1
  165. package/src/LinearGenomeView/components/MiniControls.tsx +6 -7
  166. package/src/LinearGenomeView/components/OverviewScalebar.tsx +218 -381
  167. package/src/LinearGenomeView/components/RubberbandSpan.tsx +2 -2
  168. package/src/LinearGenomeView/components/TrackLabel.tsx +3 -5
  169. package/src/LinearGenomeView/components/ZoomControls.tsx +3 -4
  170. package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.tsx.snap +1240 -1203
  171. package/src/LinearGenomeView/components/util.ts +13 -0
  172. package/src/LinearGenomeView/index.test.ts +9 -5
  173. package/src/LinearGenomeView/model.ts +16 -5
  174. package/src/LinearGenomeView/svgcomponents/SVGBackground.tsx +21 -0
  175. package/src/LinearGenomeView/svgcomponents/SVGHeader.tsx +93 -0
  176. package/src/LinearGenomeView/svgcomponents/SVGLinearGenomeView.tsx +114 -0
  177. package/src/LinearGenomeView/svgcomponents/SVGRegionSeparators.tsx +31 -0
  178. package/src/LinearGenomeView/svgcomponents/SVGRuler.tsx +125 -0
  179. package/src/LinearGenomeView/svgcomponents/SVGScalebar.tsx +57 -0
  180. package/src/LinearGenomeView/svgcomponents/SVGTrackLabel.tsx +45 -0
  181. package/src/LinearGenomeView/svgcomponents/SVGTracks.tsx +67 -0
  182. package/src/LinearGenomeView/util.test.ts +7 -4
  183. package/src/LinearGenomeView/util.ts +2 -2
  184. package/src/index.ts +10 -1
  185. package/dist/LinearGenomeView/components/LinearGenomeViewSvg.d.ts +0 -4
  186. package/dist/LinearGenomeView/components/LinearGenomeViewSvg.js +0 -141
  187. package/dist/LinearGenomeView/components/LinearGenomeViewSvg.js.map +0 -1
  188. package/dist/LinearGenomeView/components/Ruler.d.ts +0 -11
  189. package/dist/LinearGenomeView/components/Ruler.js +0 -39
  190. package/dist/LinearGenomeView/components/Ruler.js.map +0 -1
  191. package/esm/LinearGenomeView/components/LinearGenomeViewSvg.d.ts +0 -4
  192. package/esm/LinearGenomeView/components/LinearGenomeViewSvg.js +0 -134
  193. package/esm/LinearGenomeView/components/LinearGenomeViewSvg.js.map +0 -1
  194. package/esm/LinearGenomeView/components/Ruler.d.ts +0 -11
  195. package/esm/LinearGenomeView/components/Ruler.js +0 -34
  196. package/esm/LinearGenomeView/components/Ruler.js.map +0 -1
  197. package/src/LinearGenomeView/components/LinearGenomeViewSvg.tsx +0 -307
  198. package/src/LinearGenomeView/components/Ruler.tsx +0 -78
@@ -7,7 +7,6 @@ import { observer } from 'mobx-react'
7
7
  import Base1DView, { Base1DViewModel } from '@jbrowse/core/util/Base1DViewModel'
8
8
  import { getSession, getTickDisplayStr } from '@jbrowse/core/util'
9
9
  import { ContentBlock } from '@jbrowse/core/util/blockTypes'
10
- import { Assembly } from '@jbrowse/core/assemblyManager/assembly'
11
10
 
12
11
  // locals
13
12
  import {
@@ -17,6 +16,8 @@ import {
17
16
  } from '..'
18
17
  import { chooseGridPitch } from '../util'
19
18
  import OverviewRubberband from './OverviewRubberband'
19
+ import Cytobands from './Cytobands'
20
+ import { getCytobands } from './util'
20
21
 
21
22
  const wholeSeqSpacer = 2
22
23
 
@@ -32,13 +33,14 @@ const useStyles = makeStyles()(theme => ({
32
33
  position: 'absolute',
33
34
  top: 0,
34
35
  height: HEADER_OVERVIEW_HEIGHT,
36
+ overflow: 'hidden',
35
37
  },
36
38
  scalebarContigForward: {
37
- backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 9'%3E%3Cpath d='M-.1 0L6 4.5L-.1 9' fill='none' stroke='%23ddd'/%3E%3C/svg%3E")`,
39
+ backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 9'%3E%3Cpath d='M-.1 0L6 4.5L-.1 9' fill='none' stroke='${theme.palette.divider}'/%3E%3C/svg%3E")`,
38
40
  backgroundRepeat: 'repeat',
39
41
  },
40
42
  scalebarContigReverse: {
41
- backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 9'%3E%3Cpath d='M6 0L0 4.5L6 9' fill='none' stroke='%23ddd'/%3E%3C/svg%3E")`,
43
+ backgroundImage: `url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 9'%3E%3Cpath d='M6 0L0 4.5L6 9' fill='none' stroke='${theme.palette.divider}'/%3E%3C/svg%3E")`,
42
44
  backgroundRepeat: 'repeat',
43
45
  },
44
46
 
@@ -72,393 +74,228 @@ const useStyles = makeStyles()(theme => ({
72
74
  },
73
75
  }))
74
76
 
75
- const Polygon = observer(
76
- ({
77
- model,
78
- overview,
79
- useOffset = true,
80
- }: {
81
- model: LGV
82
- overview: Base1DViewModel
83
- useOffset?: boolean
84
- }) => {
85
- const theme = useTheme()
86
- const multiplier = Number(useOffset)
87
- const { interRegionPaddingWidth, offsetPx, dynamicBlocks, cytobandOffset } =
88
- model
89
- const { contentBlocks, totalWidthPxWithoutBorders } = dynamicBlocks
90
-
91
- const { tertiary, primary } = theme.palette
92
- const polygonColor = tertiary ? tertiary.light : primary.light
93
-
94
- if (!contentBlocks.length) {
95
- return null
96
- }
97
- const first = contentBlocks[0]
98
- const last = contentBlocks[contentBlocks.length - 1]
99
- const topLeft =
100
- (overview.bpToPx({
101
- ...first,
102
- coord: first.reversed ? first.end : first.start,
103
- }) || 0) +
104
- cytobandOffset * multiplier
105
- const topRight =
106
- (overview.bpToPx({
107
- ...last,
108
- coord: last.reversed ? last.start : last.end,
109
- }) || 0) +
110
- cytobandOffset * multiplier
111
-
112
- const startPx = Math.max(0, -offsetPx)
113
- const endPx =
114
- startPx +
115
- totalWidthPxWithoutBorders +
116
- (contentBlocks.length * interRegionPaddingWidth) / 2
117
-
118
- const points = [
119
- [startPx, HEADER_BAR_HEIGHT],
120
- [endPx, HEADER_BAR_HEIGHT],
121
- [topRight, 0],
122
- [topLeft, 0],
123
- ]
124
-
125
- return (
126
- <polygon
127
- points={points.toString()}
128
- fill={alpha(polygonColor, 0.3)}
129
- stroke={alpha(polygonColor, 0.8)}
130
- />
131
- )
132
- },
133
- )
134
-
135
- type LGV = LinearGenomeViewModel
136
-
137
- // rounded rect from https://stackoverflow.com/a/45889603/2129219
138
- // prettier-ignore
139
- function rightRoundedRect(x: number, y: number, width: number, height: number, radius: number) {
140
- return "M" + x + "," + y
141
- + "h" + (width - radius)
142
- + "a" + radius + "," + radius + " 0 0 1 " + radius + "," + radius
143
- + "v" + (height - 2 * radius)
144
- + "a" + radius + "," + radius + " 0 0 1 " + -radius + "," + radius
145
- + "h" + (radius - width)
146
- + "z";
147
- }
148
-
149
- // prettier-ignore
150
- function leftRoundedRect(x: number, y: number, width: number, height: number, radius: number ) {
151
- return "M" + (x + radius) + "," + y
152
- + "h" + (width - radius)
153
- + "v" + height
154
- + "h" + (radius - width)
155
- + "a" + radius + "," + radius + " 0 0 1 " + (-radius) + "," + (-radius)
156
- + "v" + (2 * radius - height)
157
- + "a" + radius + "," + radius + " 0 0 1 " + radius + "," + (-radius)
158
- + "z";
159
- }
160
-
161
- const colorMap: { [key: string]: string | undefined } = {
162
- gneg: 'rgb(227,227,227)',
163
- gpos25: 'rgb(142,142,142)',
164
- gpos50: 'rgb(85,85,85)',
165
- gpos100: 'rgb(0,0,0)',
166
- gpos75: 'rgb(57,57,57)',
167
- gvar: 'rgb(0,0,0)',
168
- stalk: 'rgb(127,127,127)',
169
- acen: '#800',
170
- }
77
+ const Polygon = observer(function ({
78
+ model,
79
+ overview,
80
+ useOffset = true,
81
+ }: {
82
+ model: LGV
83
+ overview: Base1DViewModel
84
+ useOffset?: boolean
85
+ }) {
86
+ const theme = useTheme()
87
+ const multiplier = Number(useOffset)
88
+ const { interRegionPaddingWidth, offsetPx, dynamicBlocks, cytobandOffset } =
89
+ model
90
+ const { contentBlocks, totalWidthPxWithoutBorders } = dynamicBlocks
91
+
92
+ const { tertiary, primary } = theme.palette
93
+ const polygonColor = tertiary ? tertiary.light : primary.light
94
+
95
+ if (!contentBlocks.length) {
96
+ return null
97
+ }
98
+ const first = contentBlocks[0]
99
+ const last = contentBlocks[contentBlocks.length - 1]
100
+ const topLeft =
101
+ (overview.bpToPx({
102
+ ...first,
103
+ coord: first.reversed ? first.end : first.start,
104
+ }) || 0) +
105
+ cytobandOffset * multiplier
106
+ const topRight =
107
+ (overview.bpToPx({
108
+ ...last,
109
+ coord: last.reversed ? last.start : last.end,
110
+ }) || 0) +
111
+ cytobandOffset * multiplier
112
+
113
+ const startPx = Math.max(0, -offsetPx)
114
+ const endPx =
115
+ startPx +
116
+ totalWidthPxWithoutBorders +
117
+ (contentBlocks.length * interRegionPaddingWidth) / 2
118
+
119
+ const points = [
120
+ [startPx, HEADER_BAR_HEIGHT],
121
+ [endPx, HEADER_BAR_HEIGHT],
122
+ [topRight, 0],
123
+ [topLeft, 0],
124
+ ]
171
125
 
172
- function getCytobands(assembly: Assembly | undefined, refName: string) {
173
126
  return (
174
- assembly?.cytobands
175
- ?.map(f => ({
176
- refName: assembly.getCanonicalRefName(f.get('refName')),
177
- start: f.get('start'),
178
- end: f.get('end'),
179
- type: f.get('type'),
180
- }))
181
- .filter(f => f.refName === refName) || []
127
+ <polygon
128
+ points={points.toString()}
129
+ fill={alpha(polygonColor, 0.3)}
130
+ stroke={alpha(polygonColor, 0.8)}
131
+ />
182
132
  )
183
- }
184
-
185
- const Cytobands = observer(
186
- ({
187
- overview,
188
- block,
189
- assembly,
190
- }: {
191
- overview: Base1DViewModel
192
- assembly?: Assembly
193
- block: ContentBlock
194
- }) => {
195
- const { offsetPx, reversed } = block
196
- const cytobands = getCytobands(assembly, block.refName)
197
- const coords = cytobands.map(f => {
198
- const { refName, start, end, type } = f
199
- return [
200
- overview.bpToPx({
201
- refName,
202
- coord: start,
203
- }),
204
- overview.bpToPx({
205
- refName,
206
- coord: end,
207
- }),
208
- type,
209
- ]
210
- })
211
-
212
- const arr = cytobands || []
213
- const lcap = reversed ? arr.length - 1 : 0
214
- const rcap = reversed ? 0 : arr.length - 1
215
-
216
- let firstCent = true
217
- return (
218
- <g transform={`translate(-${offsetPx})`}>
219
- {coords.map(([start, end, type], index) => {
220
- const key = `${start}-${end}-${type}`
221
- if (type === 'acen' && firstCent) {
222
- firstCent = false
223
- return (
224
- <polygon
225
- key={key}
226
- points={[
227
- [start, 0],
228
- [end, HEADER_OVERVIEW_HEIGHT / 2],
229
- [start, HEADER_OVERVIEW_HEIGHT],
230
- ].toString()}
231
- fill={colorMap[type]}
232
- />
233
- )
234
- }
235
- if (type === 'acen' && !firstCent) {
236
- return (
237
- <polygon
238
- key={key}
239
- points={[
240
- [start, HEADER_OVERVIEW_HEIGHT / 2],
241
- [end, 0],
242
- [end, HEADER_OVERVIEW_HEIGHT],
243
- ].toString()}
244
- fill={colorMap[type]}
245
- />
246
- )
247
- }
248
-
249
- if (lcap === index) {
250
- return (
251
- <path
252
- key={key}
253
- d={leftRoundedRect(
254
- Math.min(start, end),
255
- 0,
256
- Math.abs(end - start),
257
- HEADER_OVERVIEW_HEIGHT,
258
- 8,
259
- )}
260
- fill={colorMap[type]}
261
- />
262
- )
263
- } else if (rcap === index) {
264
- return (
265
- <path
266
- key={key}
267
- d={rightRoundedRect(
268
- Math.min(start, end),
269
- 0,
270
- Math.abs(end - start) - 2,
271
- HEADER_OVERVIEW_HEIGHT,
272
- 8,
273
- )}
274
- fill={colorMap[type]}
275
- />
276
- )
277
- } else {
278
- return (
279
- <rect
280
- key={key}
281
- x={Math.min(start, end)}
282
- y={0}
283
- width={Math.abs(end - start)}
284
- height={HEADER_OVERVIEW_HEIGHT}
285
- fill={colorMap[type]}
286
- />
287
- )
288
- }
289
- })}
290
- </g>
291
- )
292
- },
293
- )
294
-
295
- const OverviewBox = observer(
296
- ({
297
- scale,
298
- model,
299
- block,
300
- overview,
301
- }: {
302
- scale: number
303
- model: LGV
304
- block: ContentBlock
305
- overview: Base1DViewModel
306
- }) => {
307
- const { classes, cx } = useStyles()
308
- const { cytobandOffset, showCytobands } = model
309
- const { start, end, reversed, refName, assemblyName } = block
310
- const { majorPitch } = chooseGridPitch(scale, 120, 15)
311
- const { assemblyManager } = getSession(model)
312
- const assembly = assemblyManager.get(assemblyName)
313
- const refNameColor = assembly?.getRefNameColor(refName)
133
+ })
314
134
 
315
- const tickLabels = []
316
- for (let i = 0; i < Math.floor((end - start) / majorPitch); i++) {
317
- const offsetLabel = (i + 1) * majorPitch
318
- tickLabels.push(reversed ? end - offsetLabel : start + offsetLabel)
319
- }
320
-
321
- const canDisplayCytobands =
322
- showCytobands && getCytobands(assembly, block.refName).length
135
+ type LGV = LinearGenomeViewModel
323
136
 
324
- return (
325
- <div>
326
- {/* name of sequence */}
327
- <Typography
328
- style={{
329
- left: block.offsetPx + 3,
330
- color: canDisplayCytobands ? 'black' : refNameColor,
331
- }}
332
- className={classes.scalebarRefName}
333
- >
334
- {refName}
335
- </Typography>
336
- <div
337
- className={cx(
338
- classes.scalebarContig,
339
- canDisplayCytobands
340
- ? undefined
341
- : reversed
342
- ? classes.scalebarContigReverse
343
- : classes.scalebarContigForward,
344
- !canDisplayCytobands ? classes.scalebarBorder : undefined,
345
- )}
346
- style={{
347
- left: block.offsetPx + cytobandOffset,
348
- width: block.widthPx,
349
- borderColor: refNameColor,
350
- }}
351
- >
352
- {!canDisplayCytobands
353
- ? tickLabels.map((tickLabel, labelIdx) => (
354
- <Typography
355
- key={`${JSON.stringify(block)}-${tickLabel}-${labelIdx}`}
356
- className={classes.scalebarLabel}
357
- variant="body2"
358
- style={{
359
- left: ((labelIdx + 1) * majorPitch) / scale,
360
- pointerEvents: 'none',
361
- color: refNameColor,
362
- }}
363
- >
364
- {getTickDisplayStr(tickLabel, overview.bpPerPx)}
365
- </Typography>
366
- ))
367
- : null}
137
+ const OverviewBox = observer(function ({
138
+ scale,
139
+ model,
140
+ block,
141
+ overview,
142
+ }: {
143
+ scale: number
144
+ model: LGV
145
+ block: ContentBlock
146
+ overview: Base1DViewModel
147
+ }) {
148
+ const { classes, cx } = useStyles()
149
+ const theme = useTheme()
150
+ const { cytobandOffset, showCytobands } = model
151
+ const { start, end, reversed, refName, assemblyName } = block
152
+ const { majorPitch } = chooseGridPitch(scale, 120, 15)
153
+ const { assemblyManager } = getSession(model)
154
+ const assembly = assemblyManager.get(assemblyName)
155
+ const refNameColor = assembly?.getRefNameColor(refName)
156
+
157
+ const tickLabels = []
158
+ for (let i = 0; i < Math.floor((end - start) / majorPitch); i++) {
159
+ const offsetLabel = (i + 1) * majorPitch
160
+ tickLabels.push(reversed ? end - offsetLabel : start + offsetLabel)
161
+ }
162
+
163
+ const canDisplayCytobands =
164
+ showCytobands && getCytobands(assembly, block.refName).length
368
165
 
369
- {canDisplayCytobands ? (
370
- <svg style={{ width: '100%' }}>
371
- <Cytobands
372
- overview={overview}
373
- assembly={assembly}
374
- block={block}
375
- />
376
- </svg>
377
- ) : null}
378
- </div>
166
+ return (
167
+ <div>
168
+ {/* name of sequence */}
169
+ <Typography
170
+ style={{
171
+ left: block.offsetPx + 3,
172
+ color: canDisplayCytobands
173
+ ? theme.palette.primary.contrastText
174
+ : refNameColor,
175
+ }}
176
+ className={classes.scalebarRefName}
177
+ >
178
+ {refName}
179
+ </Typography>
180
+ <div
181
+ className={cx(
182
+ classes.scalebarContig,
183
+ canDisplayCytobands
184
+ ? undefined
185
+ : reversed
186
+ ? classes.scalebarContigReverse
187
+ : classes.scalebarContigForward,
188
+ !canDisplayCytobands ? classes.scalebarBorder : undefined,
189
+ )}
190
+ style={{
191
+ left: block.offsetPx + cytobandOffset,
192
+ width: block.widthPx,
193
+ borderColor: refNameColor,
194
+ }}
195
+ >
196
+ {!canDisplayCytobands
197
+ ? tickLabels.map((tickLabel, labelIdx) => (
198
+ <Typography
199
+ key={`${JSON.stringify(block)}-${tickLabel}-${labelIdx}`}
200
+ className={classes.scalebarLabel}
201
+ variant="body2"
202
+ style={{
203
+ left: ((labelIdx + 1) * majorPitch) / scale,
204
+ pointerEvents: 'none',
205
+ color: refNameColor,
206
+ }}
207
+ >
208
+ {getTickDisplayStr(tickLabel, overview.bpPerPx)}
209
+ </Typography>
210
+ ))
211
+ : null}
212
+
213
+ {canDisplayCytobands ? (
214
+ <svg style={{ width: '100%' }}>
215
+ <Cytobands overview={overview} assembly={assembly} block={block} />
216
+ </svg>
217
+ ) : null}
379
218
  </div>
380
- )
381
- },
382
- )
383
-
384
- const Scalebar = observer(
385
- ({
386
- model,
387
- scale,
388
- overview,
389
- }: {
390
- model: LGV
391
- overview: Base1DViewModel
392
- scale: number
393
- }) => {
394
- const { classes } = useStyles()
395
- const theme = useTheme()
396
- const { dynamicBlocks, showCytobands, cytobandOffset } = model
397
- const visibleRegions = dynamicBlocks.contentBlocks
398
- const overviewVisibleRegions = overview.dynamicBlocks
399
-
400
- const { tertiary, primary } = theme.palette
401
- const scalebarColor = tertiary ? tertiary.light : primary.light
402
-
403
- if (!visibleRegions.length) {
404
- return null
405
- }
406
- const first = visibleRegions[0]
407
- const firstOverviewPx =
408
- overview.bpToPx({
409
- ...first,
410
- coord: first.reversed ? first.end : first.start,
411
- }) || 0
412
-
413
- const last = visibleRegions[visibleRegions.length - 1]
414
- const lastOverviewPx =
415
- overview.bpToPx({
416
- ...last,
417
- coord: last.reversed ? last.start : last.end,
418
- }) || 0
219
+ </div>
220
+ )
221
+ })
419
222
 
420
- const color = showCytobands ? '#f00' : scalebarColor
421
- const transparency = showCytobands ? 0.1 : 0.3
223
+ const Scalebar = observer(function ({
224
+ model,
225
+ scale,
226
+ overview,
227
+ }: {
228
+ model: LGV
229
+ overview: Base1DViewModel
230
+ scale: number
231
+ }) {
232
+ const { classes } = useStyles()
233
+ const theme = useTheme()
234
+ const { dynamicBlocks, showCytobands, cytobandOffset } = model
235
+ const visibleRegions = dynamicBlocks.contentBlocks
236
+ const overviewVisibleRegions = overview.dynamicBlocks
237
+
238
+ const { tertiary, primary } = theme.palette
239
+ const scalebarColor = tertiary ? tertiary.light : primary.light
240
+
241
+ if (!visibleRegions.length) {
242
+ return null
243
+ }
244
+ const first = visibleRegions[0]
245
+ const firstOverviewPx =
246
+ overview.bpToPx({
247
+ ...first,
248
+ coord: first.reversed ? first.end : first.start,
249
+ }) || 0
250
+
251
+ const last = visibleRegions[visibleRegions.length - 1]
252
+ const lastOverviewPx =
253
+ overview.bpToPx({
254
+ ...last,
255
+ coord: last.reversed ? last.start : last.end,
256
+ }) || 0
257
+
258
+ const color = showCytobands ? '#f00' : scalebarColor
259
+ const transparency = showCytobands ? 0.1 : 0.3
422
260
 
423
- return (
424
- <div className={classes.scalebar}>
425
- <div
426
- className={classes.scalebarVisibleRegion}
427
- style={{
428
- width: lastOverviewPx - firstOverviewPx,
429
- left: firstOverviewPx + cytobandOffset,
430
- background: alpha(color, transparency),
431
- borderColor: color,
432
- }}
433
- />
434
- {/* this is the entire scale bar */}
435
- {overviewVisibleRegions.map((block, idx) => {
436
- return !(block instanceof ContentBlock) ? (
437
- <div
438
- key={`${JSON.stringify(block)}-${idx}`}
439
- className={classes.scalebarContig}
440
- style={{
441
- width: block.widthPx,
442
- left: block.offsetPx,
443
- backgroundColor: '#999',
444
- backgroundImage:
445
- 'repeating-linear-gradient(90deg, transparent, transparent 1px, rgba(255,255,255,.5) 1px, rgba(255,255,255,.5) 3px)',
446
- }}
447
- />
448
- ) : (
449
- <OverviewBox
450
- scale={scale}
451
- block={block}
452
- model={model}
453
- overview={overview}
454
- key={`${JSON.stringify(block)}-${idx}`}
455
- />
456
- )
457
- })}
458
- </div>
459
- )
460
- },
461
- )
261
+ return (
262
+ <div className={classes.scalebar}>
263
+ <div
264
+ className={classes.scalebarVisibleRegion}
265
+ style={{
266
+ width: lastOverviewPx - firstOverviewPx,
267
+ left: firstOverviewPx + cytobandOffset,
268
+ background: alpha(color, transparency),
269
+ borderColor: color,
270
+ }}
271
+ />
272
+ {/* this is the entire scale bar */}
273
+ {overviewVisibleRegions.map((block, idx) => {
274
+ return !(block instanceof ContentBlock) ? (
275
+ <div
276
+ key={`${JSON.stringify(block)}-${idx}`}
277
+ className={classes.scalebarContig}
278
+ style={{
279
+ width: block.widthPx,
280
+ left: block.offsetPx,
281
+ backgroundColor: '#999',
282
+ backgroundImage:
283
+ 'repeating-linear-gradient(90deg, transparent, transparent 1px, rgba(255,255,255,.5) 1px, rgba(255,255,255,.5) 3px)',
284
+ }}
285
+ />
286
+ ) : (
287
+ <OverviewBox
288
+ scale={scale}
289
+ block={block}
290
+ model={model}
291
+ overview={overview}
292
+ key={`${JSON.stringify(block)}-${idx}`}
293
+ />
294
+ )
295
+ })}
296
+ </div>
297
+ )
298
+ })
462
299
 
463
300
  function OverviewScalebar({
464
301
  model,
@@ -7,8 +7,8 @@ import { stringify, toLocale } from '@jbrowse/core/util'
7
7
  const useStyles = makeStyles()(theme => {
8
8
  const { primary, tertiary } = theme.palette
9
9
  const background = tertiary
10
- ? alpha(tertiary.main, 0.7)
11
- : alpha(primary.main, 0.7)
10
+ ? alpha(tertiary.light, 0.7)
11
+ : alpha(primary.light, 0.7)
12
12
  return {
13
13
  rubberband: {
14
14
  height: '100%',