@jbrowse/plugin-linear-genome-view 1.6.3 → 1.6.6

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 (30) hide show
  1. package/dist/BaseLinearDisplay/components/LinearBlocks.d.ts +0 -5
  2. package/dist/BaseLinearDisplay/models/baseLinearDisplayConfigSchema.d.ts +1 -1
  3. package/dist/LinearBareDisplay/configSchema.d.ts +1 -1
  4. package/dist/LinearBasicDisplay/configSchema.d.ts +1 -1
  5. package/dist/LinearGenomeView/components/ScaleBar.d.ts +2 -0
  6. package/dist/LinearGenomeView/components/TrackContainer.d.ts +3 -2
  7. package/dist/LinearGenomeView/index.d.ts +1 -0
  8. package/dist/index.d.ts +1 -1
  9. package/dist/plugin-linear-genome-view.cjs.development.js +143 -250
  10. package/dist/plugin-linear-genome-view.cjs.development.js.map +1 -1
  11. package/dist/plugin-linear-genome-view.cjs.production.min.js +1 -1
  12. package/dist/plugin-linear-genome-view.cjs.production.min.js.map +1 -1
  13. package/dist/plugin-linear-genome-view.esm.js +145 -252
  14. package/dist/plugin-linear-genome-view.esm.js.map +1 -1
  15. package/package.json +2 -2
  16. package/src/BaseLinearDisplay/components/BaseLinearDisplay.tsx +2 -4
  17. package/src/BaseLinearDisplay/components/LinearBlocks.tsx +4 -8
  18. package/src/BaseLinearDisplay/models/BaseLinearDisplayModel.tsx +11 -3
  19. package/src/LinearBasicDisplay/model.ts +1 -1
  20. package/src/LinearGenomeView/components/HelpDialog.tsx +14 -1
  21. package/src/LinearGenomeView/components/LinearGenomeViewSvg.tsx +1 -13
  22. package/src/LinearGenomeView/components/OverviewScaleBar.tsx +7 -3
  23. package/src/LinearGenomeView/components/TrackContainer.tsx +24 -39
  24. package/src/LinearGenomeView/components/TrackLabel.tsx +5 -5
  25. package/src/LinearGenomeView/components/__snapshots__/LinearGenomeView.test.js.snap +194 -191
  26. package/src/LinearGenomeView/index.test.ts +44 -42
  27. package/src/LinearGenomeView/index.tsx +176 -245
  28. package/src/LinearGenomeView/volvoxDisplayedRegions.json +16 -0
  29. package/dist/LinearGenomeView/components/ReturnToImportFormDialog.d.ts +0 -9
  30. package/src/LinearGenomeView/components/ReturnToImportFormDialog.tsx +0 -83
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/plugin-linear-genome-view",
3
- "version": "1.6.3",
3
+ "version": "1.6.6",
4
4
  "description": "JBrowse 2 linear genome view",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -61,5 +61,5 @@
61
61
  "publishConfig": {
62
62
  "access": "public"
63
63
  },
64
- "gitHead": "c6d6783d3dc82ea96390ab177ceb8ed38b439333"
64
+ "gitHead": "9fcca7793af0df2d6e527ddaace2b368c8ed2879"
65
65
  }
@@ -31,7 +31,7 @@ const useStyles = makeStyles(theme => ({
31
31
  color: theme.palette.common.white,
32
32
  fontFamily: theme.typography.fontFamily,
33
33
  padding: '4px 8px',
34
- fontSize: theme.typography.pxToRem(10),
34
+ fontSize: theme.typography.pxToRem(12),
35
35
  lineHeight: `${round(14 / 10)}em`,
36
36
  maxWidth: 300,
37
37
  wordWrap: 'break-word',
@@ -96,9 +96,7 @@ const Tooltip = observer(
96
96
  {...attributes.popper}
97
97
  >
98
98
  <TooltipContents
99
- ref={(elt: HTMLDivElement) =>
100
- setWidth(elt?.getBoundingClientRect().width || 0)
101
- }
99
+ ref={elt => setWidth(elt?.getBoundingClientRect().width || 0)}
102
100
  message={contents}
103
101
  />
104
102
  </div>
@@ -1,7 +1,7 @@
1
+ import React from 'react'
1
2
  import { makeStyles } from '@material-ui/core/styles'
2
3
  import { getContainingView } from '@jbrowse/core/util'
3
- import { observer, PropTypes } from 'mobx-react'
4
- import React from 'react'
4
+ import { observer } from 'mobx-react'
5
5
  import {
6
6
  ContentBlock,
7
7
  ElidedBlock,
@@ -14,6 +14,7 @@ import {
14
14
  ElidedBlock as ElidedBlockComponent,
15
15
  InterRegionPaddingBlock as InterRegionPaddingBlockComponent,
16
16
  } from './Block'
17
+ import { LinearGenomeViewModel } from '../../LinearGenomeView'
17
18
 
18
19
  const useStyles = makeStyles({
19
20
  linearBlocks: {
@@ -96,8 +97,7 @@ const RenderedBlocks = observer(
96
97
  function LinearBlocks({ model }: { model: BaseLinearDisplayModel }) {
97
98
  const classes = useStyles()
98
99
  const { blockDefinitions } = model
99
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
100
- const viewModel = getContainingView(model) as any
100
+ const viewModel = getContainingView(model) as LinearGenomeViewModel
101
101
  return (
102
102
  <div
103
103
  data-testid="Blockset"
@@ -111,9 +111,5 @@ function LinearBlocks({ model }: { model: BaseLinearDisplayModel }) {
111
111
  )
112
112
  }
113
113
 
114
- LinearBlocks.propTypes = {
115
- model: PropTypes.observableObject.isRequired,
116
- }
117
-
118
114
  export { RenderedBlocks, useStyles }
119
115
  export default observer(LinearBlocks)
@@ -387,7 +387,10 @@ export const BaseLinearDisplay = types
387
387
  self.setError()
388
388
  const aborter = new AbortController()
389
389
  const view = getContainingView(self) as LGV
390
- if (!view.initialized) {
390
+
391
+ // extra check for contentBlocks.length
392
+ // https://github.com/GMOD/jbrowse-components/issues/2694
393
+ if (!view.initialized || !view.staticBlocks.contentBlocks.length) {
391
394
  return
392
395
  }
393
396
 
@@ -411,7 +414,7 @@ export const BaseLinearDisplay = types
411
414
  afterAttach() {
412
415
  // this autorun performs stats estimation
413
416
  //
414
- // the chain of events calls estimateRegionStats against the data
417
+ // the chain of events calls estimateRegionsStats against the data
415
418
  // adapter which by default uses featureDensity, but can also respond
416
419
  // with a byte size estimate and fetch size limit (data adapter can
417
420
  // define what is too much data)
@@ -423,7 +426,12 @@ export const BaseLinearDisplay = types
423
426
  const aborter = new AbortController()
424
427
  const view = getContainingView(self) as LGV
425
428
 
426
- if (!view.initialized) {
429
+ // extra check for contentBlocks.length
430
+ // https://github.com/GMOD/jbrowse-components/issues/2694
431
+ if (
432
+ !view.initialized ||
433
+ !view.staticBlocks.contentBlocks.length
434
+ ) {
427
435
  return
428
436
  }
429
437
 
@@ -139,7 +139,7 @@ const stateModelFactory = (configSchema: AnyConfigurationSchemaType) =>
139
139
  {
140
140
  label: 'Set max height',
141
141
  onClick: () => {
142
- getSession(self).queueDialog((doneCallback: Function) => [
142
+ getSession(self).queueDialog(doneCallback => [
143
143
  SetMaxHeightDlg,
144
144
  { model: self, handleClose: doneCallback },
145
145
  ])
@@ -53,7 +53,9 @@ export default function HelpDialog({
53
53
  <li>
54
54
  Jump to a specific region by typing the region into the location box
55
55
  as: <code>ref:start..end</code> or <code>ref:start-end</code>.
56
- Commas are allowed in the start and end coordinates.
56
+ Commas are allowed in the start and end coordinates. A
57
+ space-separated list of locstrings can be used to open up multiple
58
+ chromosomes at a time
57
59
  </li>
58
60
  </ul>
59
61
  <h3>Example Searches</h3>
@@ -68,6 +70,17 @@ export default function HelpDialog({
68
70
  <code>chr4:79,500,000..80,000,000</code> - jumps the region on
69
71
  chromosome 4 between 79.5Mb and 80Mb.
70
72
  </li>
73
+ <li>
74
+ <code>chr1:1-100 chr2:1-100</code> - create a split view of
75
+ chr1:1-100 and chr2:1-100
76
+ </li>
77
+ <li>
78
+ <code>chr1 chr2 chr3</code> - open up multiple chromosomes at once
79
+ </li>
80
+ <li>
81
+ <code>chr1:1-100[rev] chr2:1-100</code> - open up the first region
82
+ in the horizontally flipped orientation
83
+ </li>
71
84
  </ul>
72
85
  </DialogContent>
73
86
  <Divider />
@@ -3,7 +3,7 @@ import { renderToStaticMarkup } from 'react-dom/server'
3
3
  import { when } from 'mobx'
4
4
  import { getParent } from 'mobx-state-tree'
5
5
  import { getConf, readConfObject } from '@jbrowse/core/configuration'
6
- import { getSession } from '@jbrowse/core/util'
6
+ import { getSession, getBpDisplayStr } from '@jbrowse/core/util'
7
7
  import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
8
8
  import Base1DView from '@jbrowse/core/util/Base1DViewModel'
9
9
 
@@ -18,18 +18,6 @@ import { Polygon, Cytobands } from './OverviewScaleBar'
18
18
 
19
19
  type LGV = LinearGenomeViewModel
20
20
 
21
- function getBpDisplayStr(totalBp: number) {
22
- let displayBp
23
- if (Math.floor(totalBp / 1000000) > 0) {
24
- displayBp = `${parseFloat((totalBp / 1000000).toPrecision(3))}Mbp`
25
- } else if (Math.floor(totalBp / 1000) > 0) {
26
- displayBp = `${parseFloat((totalBp / 1000).toPrecision(3))}Kbp`
27
- } else {
28
- displayBp = `${Math.floor(totalBp)}bp`
29
- }
30
- return displayBp
31
- }
32
-
33
21
  function ScaleBar({ model, fontSize }: { model: LGV; fontSize: number }) {
34
22
  const {
35
23
  offsetPx,
@@ -181,7 +181,7 @@ const Cytobands = observer(
181
181
  assembly?: Assembly
182
182
  block: ContentBlock
183
183
  }) => {
184
- const { offsetPx } = block
184
+ const { offsetPx, reversed } = block
185
185
  const cytobands = assembly?.cytobands
186
186
  ?.map(f => ({
187
187
  refName: assembly.getCanonicalRefName(f.get('refName')),
@@ -205,6 +205,10 @@ const Cytobands = observer(
205
205
  ]
206
206
  })
207
207
 
208
+ const arr = cytobands || []
209
+ const lcap = reversed ? arr.length - 1 : 0
210
+ const rcap = reversed ? 0 : arr.length - 1
211
+
208
212
  let firstCent = true
209
213
  return cytobands ? (
210
214
  <g transform={`translate(-${offsetPx})`}>
@@ -238,7 +242,7 @@ const Cytobands = observer(
238
242
  )
239
243
  }
240
244
 
241
- if (index === 0) {
245
+ if (lcap === index) {
242
246
  return (
243
247
  <path
244
248
  key={key}
@@ -252,7 +256,7 @@ const Cytobands = observer(
252
256
  fill={colorMap[type]}
253
257
  />
254
258
  )
255
- } else if (index === cytobands.length - 1) {
259
+ } else if (rcap === index) {
256
260
  return (
257
261
  <path
258
262
  key={key}
@@ -1,13 +1,12 @@
1
1
  import React, { useEffect, useRef } from 'react'
2
+ import { Paper, makeStyles } from '@material-ui/core'
2
3
  import { observer } from 'mobx-react'
3
4
  import { isAlive } from 'mobx-state-tree'
4
- import { BaseTrackModel } from '@jbrowse/core/pluggableElementTypes/models'
5
5
  import { getConf } from '@jbrowse/core/configuration'
6
+ import { BaseTrackModel } from '@jbrowse/core/pluggableElementTypes/models'
6
7
  import { ResizeHandle } from '@jbrowse/core/ui'
7
- import { useDebouncedCallback, getContainingView } from '@jbrowse/core/util'
8
+ import { useDebouncedCallback } from '@jbrowse/core/util'
8
9
  import clsx from 'clsx'
9
- import Paper from '@material-ui/core/Paper'
10
- import { makeStyles } from '@material-ui/core/styles'
11
10
 
12
11
  import { LinearGenomeViewModel, RESIZE_HANDLE_HEIGHT } from '..'
13
12
  import TrackLabel from './TrackLabel'
@@ -16,8 +15,6 @@ const useStyles = makeStyles(theme => ({
16
15
  root: {},
17
16
  resizeHandle: {
18
17
  height: RESIZE_HANDLE_HEIGHT,
19
- boxSizing: 'border-box',
20
- position: 'relative',
21
18
  zIndex: 2,
22
19
  },
23
20
  overlay: {
@@ -29,13 +26,6 @@ const useStyles = makeStyles(theme => ({
29
26
  zIndex: 3,
30
27
  borderRadius: theme.shape.borderRadius,
31
28
  },
32
- renderingComponentContainer: {
33
- position: 'absolute',
34
- // -1 offset because of the 1px border of the Paper
35
- left: -1,
36
- height: '100%',
37
- width: '100%',
38
- },
39
29
  trackLabel: {
40
30
  zIndex: 3,
41
31
  margin: theme.spacing(1),
@@ -54,24 +44,25 @@ const useStyles = makeStyles(theme => ({
54
44
  position: 'relative',
55
45
  background: 'none',
56
46
  zIndex: 2,
57
- boxSizing: 'content-box',
58
47
  },
59
48
  }))
60
49
 
61
50
  type LGV = LinearGenomeViewModel
62
51
 
63
- function TrackContainer(props: {
64
- model: LinearGenomeViewModel
52
+ function TrackContainer({
53
+ model,
54
+ track,
55
+ }: {
56
+ model: LGV
65
57
  track: BaseTrackModel
66
58
  }) {
67
59
  const classes = useStyles()
68
- const { model, track } = props
69
60
  const display = track.displays[0]
70
- const { horizontalScroll, draggingTrackId, moveTrack } = model
61
+ const { id, trackLabels, horizontalScroll, draggingTrackId, moveTrack } =
62
+ model
71
63
  const { height } = display
72
- const view = getContainingView(display) as LGV
73
64
  const trackId = getConf(track, 'trackId')
74
- const ref = useRef(null)
65
+ const ref = useRef<HTMLDivElement>(null)
75
66
 
76
67
  useEffect(() => {
77
68
  if (ref.current) {
@@ -96,18 +87,6 @@ function TrackContainer(props: {
96
87
 
97
88
  return (
98
89
  <div className={classes.root}>
99
- {view.trackLabels !== 'hidden' ? (
100
- <TrackLabel
101
- track={track}
102
- className={clsx(
103
- classes.trackLabel,
104
- view.trackLabels === 'overlapping'
105
- ? classes.trackLabelOverlap
106
- : classes.trackLabelInline,
107
- )}
108
- />
109
- ) : null}
110
-
111
90
  <Paper
112
91
  variant="outlined"
113
92
  className={classes.trackRenderingContainer}
@@ -117,14 +96,21 @@ function TrackContainer(props: {
117
96
  display.setScrollTop(target.scrollTop)
118
97
  }}
119
98
  onDragEnter={debouncedOnDragEnter}
120
- data-testid={`trackRenderingContainer-${view.id}-${trackId}`}
99
+ data-testid={`trackRenderingContainer-${id}-${trackId}`}
121
100
  role="presentation"
122
101
  >
123
- <div
124
- ref={ref}
125
- className={classes.renderingComponentContainer}
126
- style={{ transform: `scaleX(${model.scaleFactor})` }}
127
- >
102
+ {trackLabels !== 'hidden' ? (
103
+ <TrackLabel
104
+ track={track}
105
+ className={clsx(
106
+ classes.trackLabel,
107
+ trackLabels === 'overlapping'
108
+ ? classes.trackLabelOverlap
109
+ : classes.trackLabelInline,
110
+ )}
111
+ />
112
+ ) : null}
113
+ <div ref={ref} style={{ transform: `scaleX(${model.scaleFactor})` }}>
128
114
  <RenderingComponent
129
115
  model={display}
130
116
  blockState={{}}
@@ -140,7 +126,6 @@ function TrackContainer(props: {
140
126
  top: display.height - 20,
141
127
  }}
142
128
  >
143
- {' '}
144
129
  <DisplayBlurb model={display} />
145
130
  </div>
146
131
  ) : null}
@@ -102,7 +102,10 @@ const TrackLabel = React.forwardRef(
102
102
  handleClose()
103
103
  }
104
104
 
105
- const items = track.trackMenuItems()
105
+ const items = [
106
+ ...session.getTrackActionMenuItems?.(trackConf),
107
+ ...track.trackMenuItems(),
108
+ ].sort((a, b) => (b.priority || 0) - (a.priority || 0))
106
109
 
107
110
  return (
108
111
  <>
@@ -148,10 +151,7 @@ const TrackLabel = React.forwardRef(
148
151
  onMenuItemClick={handleMenuItemClick}
149
152
  open={Boolean(anchorEl)}
150
153
  onClose={handleClose}
151
- menuItems={[
152
- ...session.getTrackActionMenuItems?.(trackConf),
153
- ...items,
154
- ].sort((a, b) => (b.priority || 0) - (a.priority || 0))}
154
+ menuItems={items}
155
155
  />
156
156
  </>
157
157
  )