@jbrowse/plugin-linear-genome-view 1.4.1 → 1.5.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.
- package/dist/BaseLinearDisplay/components/Block.d.ts +7 -10
- package/dist/BaseLinearDisplay/models/BaseLinearDisplayModel.d.ts +16 -9
- package/dist/BaseLinearDisplay/models/serverSideRenderedBlock.d.ts +2 -2
- package/dist/LinearBareDisplay/model.d.ts +8 -8
- package/dist/LinearBasicDisplay/model.d.ts +11 -8
- package/dist/LinearGenomeView/components/HelpDialog.d.ts +5 -0
- package/dist/LinearGenomeView/components/LinearGenomeView.d.ts +3 -5
- package/dist/LinearGenomeView/components/LinearGenomeViewSvg.d.ts +4 -0
- package/dist/LinearGenomeView/components/OverviewRubberBand.d.ts +2 -3
- package/dist/LinearGenomeView/components/OverviewScaleBar.d.ts +116 -2
- package/dist/LinearGenomeView/components/RefNameAutocomplete.d.ts +3 -11
- package/dist/LinearGenomeView/components/ScaleBar.d.ts +36 -2
- package/dist/LinearGenomeView/components/util.d.ts +2 -0
- package/dist/LinearGenomeView/index.d.ts +22 -4
- package/dist/index.d.ts +26 -26
- package/dist/plugin-linear-genome-view.cjs.development.js +3178 -2884
- package/dist/plugin-linear-genome-view.cjs.development.js.map +1 -1
- package/dist/plugin-linear-genome-view.cjs.production.min.js +1 -1
- package/dist/plugin-linear-genome-view.cjs.production.min.js.map +1 -1
- package/dist/plugin-linear-genome-view.esm.js +3191 -2898
- package/dist/plugin-linear-genome-view.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +3 -0
- package/src/BaseLinearDisplay/components/Block.tsx +20 -33
- package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +3 -7
- package/src/BaseLinearDisplay/models/serverSideRenderedBlock.ts +15 -13
- package/src/LinearBasicDisplay/model.ts +25 -3
- package/src/LinearGenomeView/components/ExportSvgDialog.tsx +6 -6
- package/src/LinearGenomeView/components/Header.tsx +56 -78
- package/src/LinearGenomeView/components/HelpDialog.tsx +81 -0
- package/src/LinearGenomeView/components/ImportForm.tsx +139 -158
- package/src/LinearGenomeView/components/LinearGenomeView.test.js +6 -6
- package/src/LinearGenomeView/components/LinearGenomeView.tsx +30 -245
- package/src/LinearGenomeView/components/LinearGenomeViewSvg.tsx +317 -0
- package/src/LinearGenomeView/components/OverviewRubberBand.tsx +74 -34
- package/src/LinearGenomeView/components/OverviewScaleBar.tsx +326 -177
- package/src/LinearGenomeView/components/RefNameAutocomplete.tsx +152 -157
- package/src/LinearGenomeView/components/SearchResultsDialog.tsx +12 -34
- package/src/LinearGenomeView/components/SequenceDialog.tsx +10 -9
- package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +127 -254
- package/src/LinearGenomeView/components/util.ts +10 -0
- package/src/LinearGenomeView/index.tsx +69 -27
- package/src/index.ts +3 -1
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import React, { useRef, useEffect, useState } from 'react'
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import {
|
|
3
|
+
Popover,
|
|
4
|
+
Tooltip,
|
|
5
|
+
Typography,
|
|
6
|
+
makeStyles,
|
|
7
|
+
alpha,
|
|
8
|
+
} from '@material-ui/core'
|
|
9
|
+
import { getSession, stringify } from '@jbrowse/core/util'
|
|
5
10
|
import { observer, PropTypes as MobxPropTypes } from 'mobx-react'
|
|
6
|
-
import { Instance } from 'mobx-state-tree'
|
|
7
11
|
import ReactPropTypes from 'prop-types'
|
|
8
12
|
import { Base1DViewModel } from '@jbrowse/core/util/Base1DViewModel'
|
|
9
|
-
import {
|
|
13
|
+
import { LinearGenomeViewModel, HEADER_OVERVIEW_HEIGHT } from '..'
|
|
10
14
|
|
|
11
|
-
type LGV =
|
|
15
|
+
type LGV = LinearGenomeViewModel
|
|
12
16
|
|
|
13
17
|
const useStyles = makeStyles(theme => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const { tertiary, primary } = theme.palette
|
|
19
|
+
const background = tertiary
|
|
20
|
+
? alpha(tertiary.main, 0.7)
|
|
21
|
+
: alpha(primary.main, 0.7)
|
|
17
22
|
return {
|
|
18
23
|
rubberBand: {
|
|
19
24
|
height: '100%',
|
|
@@ -29,9 +34,7 @@ const useStyles = makeStyles(theme => {
|
|
|
29
34
|
minHeight: 8,
|
|
30
35
|
},
|
|
31
36
|
rubberBandText: {
|
|
32
|
-
color:
|
|
33
|
-
? theme.palette.tertiary.contrastText
|
|
34
|
-
: theme.palette.primary.contrastText,
|
|
37
|
+
color: tertiary ? tertiary.contrastText : primary.contrastText,
|
|
35
38
|
},
|
|
36
39
|
popover: {
|
|
37
40
|
mouseEvents: 'none',
|
|
@@ -51,6 +54,49 @@ const useStyles = makeStyles(theme => {
|
|
|
51
54
|
}
|
|
52
55
|
})
|
|
53
56
|
|
|
57
|
+
const HoverTooltip = observer(
|
|
58
|
+
({
|
|
59
|
+
model,
|
|
60
|
+
open,
|
|
61
|
+
guideX,
|
|
62
|
+
overview,
|
|
63
|
+
}: {
|
|
64
|
+
model: LGV
|
|
65
|
+
open: boolean
|
|
66
|
+
guideX: number
|
|
67
|
+
overview: Base1DViewModel
|
|
68
|
+
}) => {
|
|
69
|
+
const classes = useStyles()
|
|
70
|
+
const { cytobandOffset } = model
|
|
71
|
+
const { assemblyManager } = getSession(model)
|
|
72
|
+
|
|
73
|
+
const px = overview.pxToBp(guideX - cytobandOffset)
|
|
74
|
+
const assembly = assemblyManager.get(px.assemblyName)
|
|
75
|
+
const cytoband = assembly?.cytobands?.find(
|
|
76
|
+
f =>
|
|
77
|
+
px.coord > f.get('start') &&
|
|
78
|
+
px.coord < f.get('end') &&
|
|
79
|
+
px.refName === assembly.getCanonicalRefName(f.get('refName')),
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<Tooltip
|
|
84
|
+
open={open}
|
|
85
|
+
placement="top"
|
|
86
|
+
title={[stringify(px), cytoband?.get('name')].join(' ')}
|
|
87
|
+
arrow
|
|
88
|
+
>
|
|
89
|
+
<div
|
|
90
|
+
className={classes.guide}
|
|
91
|
+
style={{
|
|
92
|
+
left: guideX,
|
|
93
|
+
}}
|
|
94
|
+
/>
|
|
95
|
+
</Tooltip>
|
|
96
|
+
)
|
|
97
|
+
},
|
|
98
|
+
)
|
|
99
|
+
|
|
54
100
|
function OverviewRubberBand({
|
|
55
101
|
model,
|
|
56
102
|
overview,
|
|
@@ -60,9 +106,10 @@ function OverviewRubberBand({
|
|
|
60
106
|
overview: Base1DViewModel
|
|
61
107
|
ControlComponent?: React.ReactElement
|
|
62
108
|
}) {
|
|
109
|
+
const { cytobandOffset } = model
|
|
63
110
|
const [startX, setStartX] = useState<number>()
|
|
64
111
|
const [currentX, setCurrentX] = useState<number>()
|
|
65
|
-
const [guideX, setGuideX] = useState<number
|
|
112
|
+
const [guideX, setGuideX] = useState<number>()
|
|
66
113
|
const controlsRef = useRef<HTMLDivElement>(null)
|
|
67
114
|
const rubberBandRef = useRef(null)
|
|
68
115
|
const classes = useStyles()
|
|
@@ -70,9 +117,9 @@ function OverviewRubberBand({
|
|
|
70
117
|
|
|
71
118
|
useEffect(() => {
|
|
72
119
|
function globalMouseMove(event: MouseEvent) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
120
|
+
const ref = controlsRef.current
|
|
121
|
+
if (ref && mouseDragging) {
|
|
122
|
+
const relativeX = event.clientX - ref.getBoundingClientRect().left
|
|
76
123
|
setCurrentX(relativeX)
|
|
77
124
|
}
|
|
78
125
|
}
|
|
@@ -85,8 +132,8 @@ function OverviewRubberBand({
|
|
|
85
132
|
) {
|
|
86
133
|
if (Math.abs(currentX - startX) > 3) {
|
|
87
134
|
model.zoomToDisplayedRegions(
|
|
88
|
-
overview.pxToBp(startX),
|
|
89
|
-
overview.pxToBp(currentX),
|
|
135
|
+
overview.pxToBp(startX - cytobandOffset),
|
|
136
|
+
overview.pxToBp(currentX - cytobandOffset),
|
|
90
137
|
)
|
|
91
138
|
}
|
|
92
139
|
}
|
|
@@ -96,7 +143,7 @@ function OverviewRubberBand({
|
|
|
96
143
|
startX !== undefined &&
|
|
97
144
|
currentX === undefined
|
|
98
145
|
) {
|
|
99
|
-
const clickedAt = overview.pxToBp(startX)
|
|
146
|
+
const clickedAt = overview.pxToBp(startX - cytobandOffset)
|
|
100
147
|
model.centerAt(
|
|
101
148
|
Math.round(clickedAt.coord),
|
|
102
149
|
clickedAt.refName,
|
|
@@ -129,7 +176,7 @@ function OverviewRubberBand({
|
|
|
129
176
|
}
|
|
130
177
|
}
|
|
131
178
|
return () => {}
|
|
132
|
-
}, [mouseDragging, currentX, startX, model, overview])
|
|
179
|
+
}, [mouseDragging, currentX, startX, model, overview, cytobandOffset])
|
|
133
180
|
|
|
134
181
|
function mouseDown(event: React.MouseEvent<HTMLDivElement>) {
|
|
135
182
|
event.preventDefault()
|
|
@@ -157,19 +204,12 @@ function OverviewRubberBand({
|
|
|
157
204
|
return (
|
|
158
205
|
<div style={{ position: 'relative' }}>
|
|
159
206
|
{guideX !== undefined ? (
|
|
160
|
-
<
|
|
207
|
+
<HoverTooltip
|
|
208
|
+
model={model}
|
|
161
209
|
open={!mouseDragging}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
>
|
|
166
|
-
<div
|
|
167
|
-
className={classes.guide}
|
|
168
|
-
style={{
|
|
169
|
-
left: guideX,
|
|
170
|
-
}}
|
|
171
|
-
/>
|
|
172
|
-
</Tooltip>
|
|
210
|
+
overview={overview}
|
|
211
|
+
guideX={guideX}
|
|
212
|
+
/>
|
|
173
213
|
) : null}
|
|
174
214
|
<div
|
|
175
215
|
className={classes.rubberBandControl}
|
|
@@ -195,8 +235,8 @@ function OverviewRubberBand({
|
|
|
195
235
|
let leftBpOffset
|
|
196
236
|
let rightBpOffset
|
|
197
237
|
if (startX) {
|
|
198
|
-
leftBpOffset = overview.pxToBp(startX)
|
|
199
|
-
rightBpOffset = overview.pxToBp(startX + width)
|
|
238
|
+
leftBpOffset = overview.pxToBp(startX - cytobandOffset)
|
|
239
|
+
rightBpOffset = overview.pxToBp(startX + width - cytobandOffset)
|
|
200
240
|
if (currentX && currentX < startX) {
|
|
201
241
|
;[leftBpOffset, rightBpOffset] = [rightBpOffset, leftBpOffset]
|
|
202
242
|
}
|