@jbrowse/plugin-wiggle 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/BigWigAdapter/BigWigAdapter.d.ts +6 -5
- package/dist/BigWigAdapter/index.d.ts +0 -1
- package/dist/LinearWiggleDisplay/components/Tooltip.d.ts +7 -2
- package/dist/LinearWiggleDisplay/models/model.d.ts +8 -8
- package/dist/WiggleRPC/rpcMethods.d.ts +1 -22
- package/dist/WiggleRendering.d.ts +1 -0
- package/dist/index.d.ts +32 -31
- package/dist/plugin-wiggle.cjs.development.js +312 -261
- package/dist/plugin-wiggle.cjs.development.js.map +1 -1
- package/dist/plugin-wiggle.cjs.production.min.js +1 -1
- package/dist/plugin-wiggle.cjs.production.min.js.map +1 -1
- package/dist/plugin-wiggle.esm.js +313 -262
- package/dist/plugin-wiggle.esm.js.map +1 -1
- package/package.json +3 -3
- package/src/BigWigAdapter/BigWigAdapter.test.ts +5 -1
- package/src/BigWigAdapter/BigWigAdapter.ts +16 -9
- package/src/BigWigAdapter/configSchema.ts +4 -1
- package/src/BigWigAdapter/index.ts +0 -1
- package/src/LinearWiggleDisplay/components/Tooltip.tsx +13 -8
- package/src/LinearWiggleDisplay/models/configSchema.ts +6 -9
- package/src/LinearWiggleDisplay/models/model.tsx +23 -15
- package/src/WiggleRPC/rpcMethods.ts +6 -3
- package/src/WiggleRendering.tsx +1 -0
- package/src/XYPlotRenderer/XYPlotRenderer.ts +1 -1
- package/src/index.ts +44 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/plugin-wiggle",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "JBrowse 2 wiggle adapters, tracks, etc.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"useSrc": "node ../../scripts/useSrc.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@gmod/bbi": "^1.0.
|
|
38
|
+
"@gmod/bbi": "^1.0.31",
|
|
39
39
|
"@material-ui/icons": "^4.11.2",
|
|
40
40
|
"@popperjs/core": "^2.9.3",
|
|
41
41
|
"abortable-promise-cache": "^1.1.3",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "94fdfbc34787ab8f12a87e00038da74b247b42fa"
|
|
64
64
|
}
|
|
@@ -7,7 +7,10 @@ describe('adapter can fetch features from volvox.bw', () => {
|
|
|
7
7
|
beforeEach(() => {
|
|
8
8
|
adapter = new BigWigAdapter(
|
|
9
9
|
configSchema.create({
|
|
10
|
-
bigWigLocation: {
|
|
10
|
+
bigWigLocation: {
|
|
11
|
+
localPath: require.resolve('./test_data/volvox.bw'),
|
|
12
|
+
locationType: 'LocalPathLocation',
|
|
13
|
+
},
|
|
11
14
|
}),
|
|
12
15
|
)
|
|
13
16
|
})
|
|
@@ -16,6 +19,7 @@ describe('adapter can fetch features from volvox.bw', () => {
|
|
|
16
19
|
refName: 'ctgA',
|
|
17
20
|
start: 0,
|
|
18
21
|
end: 20000,
|
|
22
|
+
assemblyName: 'volvox',
|
|
19
23
|
})
|
|
20
24
|
expect(await adapter.refIdToName(0)).toBe('ctgA')
|
|
21
25
|
expect(await adapter.refIdToName(1)).toBe(undefined)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { BigWig
|
|
1
|
+
import { BigWig } from '@gmod/bbi'
|
|
2
2
|
import {
|
|
3
3
|
BaseFeatureDataAdapter,
|
|
4
4
|
BaseOptions,
|
|
5
5
|
} from '@jbrowse/core/data_adapters/BaseAdapter'
|
|
6
|
-
import {
|
|
6
|
+
import { AugmentedRegion as Region } from '@jbrowse/core/util/types'
|
|
7
7
|
import { openLocation } from '@jbrowse/core/util/io'
|
|
8
8
|
import { ObservableCreate } from '@jbrowse/core/util/rxjs'
|
|
9
9
|
import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
@@ -11,8 +11,10 @@ import { map, mergeAll } from 'rxjs/operators'
|
|
|
11
11
|
import { readConfObject } from '@jbrowse/core/configuration'
|
|
12
12
|
import { Instance } from 'mobx-state-tree'
|
|
13
13
|
import { rectifyStats, UnrectifiedFeatureStats } from '@jbrowse/core/util/stats'
|
|
14
|
+
import PluginManager from '@jbrowse/core/PluginManager'
|
|
14
15
|
|
|
15
16
|
import configSchema from './configSchema'
|
|
17
|
+
import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
|
|
16
18
|
|
|
17
19
|
interface WiggleOptions extends BaseOptions {
|
|
18
20
|
resolution?: number
|
|
@@ -27,10 +29,17 @@ export default class BigWigAdapter extends BaseFeatureDataAdapter {
|
|
|
27
29
|
'hasGlobalStats',
|
|
28
30
|
]
|
|
29
31
|
|
|
30
|
-
public constructor(
|
|
31
|
-
|
|
32
|
+
public constructor(
|
|
33
|
+
config: Instance<typeof configSchema>,
|
|
34
|
+
getSubAdapter?: getSubAdapterType,
|
|
35
|
+
pluginManager?: PluginManager,
|
|
36
|
+
) {
|
|
37
|
+
super(config, getSubAdapter, pluginManager)
|
|
32
38
|
this.bigwig = new BigWig({
|
|
33
|
-
filehandle: openLocation(
|
|
39
|
+
filehandle: openLocation(
|
|
40
|
+
readConfObject(config, 'bigWigLocation'),
|
|
41
|
+
this.pluginManager,
|
|
42
|
+
),
|
|
34
43
|
})
|
|
35
44
|
}
|
|
36
45
|
|
|
@@ -57,7 +66,7 @@ export default class BigWigAdapter extends BaseFeatureDataAdapter {
|
|
|
57
66
|
return rectifyStats(header.totalSummary as UnrectifiedFeatureStats)
|
|
58
67
|
}
|
|
59
68
|
|
|
60
|
-
public getFeatures(region:
|
|
69
|
+
public getFeatures(region: Region, opts: WiggleOptions = {}) {
|
|
61
70
|
const { refName, start, end } = region
|
|
62
71
|
const {
|
|
63
72
|
bpPerPx = 0,
|
|
@@ -73,7 +82,7 @@ export default class BigWigAdapter extends BaseFeatureDataAdapter {
|
|
|
73
82
|
})
|
|
74
83
|
ob.pipe(
|
|
75
84
|
mergeAll(),
|
|
76
|
-
map(
|
|
85
|
+
map(record => {
|
|
77
86
|
return new SimpleFeature({
|
|
78
87
|
id: `${refName}:${record.start}-${record.end}`,
|
|
79
88
|
data: { ...record, refName },
|
|
@@ -85,5 +94,3 @@ export default class BigWigAdapter extends BaseFeatureDataAdapter {
|
|
|
85
94
|
|
|
86
95
|
public freeResources(): void {}
|
|
87
96
|
}
|
|
88
|
-
const adapterCapabilities = BigWigAdapter.capabilities
|
|
89
|
-
export { adapterCapabilities }
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
1
|
import React, { useMemo, useState } from 'react'
|
|
3
2
|
import { observer } from 'mobx-react'
|
|
4
3
|
import { makeStyles, alpha, Portal } from '@material-ui/core'
|
|
5
4
|
import { Feature } from '@jbrowse/core/util/simpleFeature'
|
|
5
|
+
|
|
6
|
+
// locals
|
|
6
7
|
import { YSCALEBAR_LABEL_OFFSET } from '../models/model'
|
|
7
8
|
import { usePopper } from 'react-popper'
|
|
8
9
|
|
|
@@ -86,18 +87,19 @@ const Tooltip = observer(
|
|
|
86
87
|
clientRect,
|
|
87
88
|
TooltipContents,
|
|
88
89
|
}: {
|
|
89
|
-
model:
|
|
90
|
+
model: { featureUnderMouse: Feature }
|
|
90
91
|
height: number
|
|
91
92
|
clientMouseCoord: Coord
|
|
92
93
|
offsetMouseCoord: Coord
|
|
93
94
|
clientRect?: ClientRect
|
|
95
|
+
|
|
96
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
94
97
|
TooltipContents: React.FC<any>
|
|
95
98
|
}) => {
|
|
96
99
|
const { featureUnderMouse } = model
|
|
97
|
-
const classes = useStyles()
|
|
98
100
|
const [width, setWidth] = useState(0)
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
+
const [anchorEl, setAnchorEl] = useState<HTMLDivElement | null>(null)
|
|
102
|
+
const classes = useStyles()
|
|
101
103
|
|
|
102
104
|
// must be memoized a la https://github.com/popperjs/react-popper/issues/391
|
|
103
105
|
const virtElement = useMemo(
|
|
@@ -112,18 +114,21 @@ const Tooltip = observer(
|
|
|
112
114
|
right: x,
|
|
113
115
|
width: 0,
|
|
114
116
|
height: 0,
|
|
117
|
+
x,
|
|
118
|
+
y,
|
|
119
|
+
toJSON() {},
|
|
115
120
|
}
|
|
116
121
|
},
|
|
117
122
|
}),
|
|
118
123
|
[clientRect?.top, clientMouseCoord, width],
|
|
119
124
|
)
|
|
120
|
-
const { styles, attributes } = usePopper(virtElement,
|
|
125
|
+
const { styles, attributes } = usePopper(virtElement, anchorEl)
|
|
121
126
|
|
|
122
127
|
return featureUnderMouse ? (
|
|
123
128
|
<>
|
|
124
129
|
<Portal>
|
|
125
130
|
<div
|
|
126
|
-
ref={
|
|
131
|
+
ref={setAnchorEl}
|
|
127
132
|
className={classes.tooltip}
|
|
128
133
|
// zIndex needed to go over widget drawer
|
|
129
134
|
style={{ ...styles.popper, zIndex: 100000 }}
|
|
@@ -152,7 +157,7 @@ const Tooltip = observer(
|
|
|
152
157
|
|
|
153
158
|
const WiggleTooltip = observer(
|
|
154
159
|
(props: {
|
|
155
|
-
model:
|
|
160
|
+
model: { featureUnderMouse: Feature }
|
|
156
161
|
height: number
|
|
157
162
|
offsetMouseCoord: Coord
|
|
158
163
|
clientMouseCoord: Coord
|
|
@@ -4,15 +4,12 @@ import { types } from 'mobx-state-tree'
|
|
|
4
4
|
import PluginManager from '@jbrowse/core/PluginManager'
|
|
5
5
|
|
|
6
6
|
export default function WiggleConfigFactory(pluginManager: PluginManager) {
|
|
7
|
-
const XYPlotRendererConfigSchema =
|
|
8
|
-
'XYPlotRenderer'
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const LinePlotRendererConfigSchema = pluginManager.getRendererType(
|
|
14
|
-
'LinePlotRenderer',
|
|
15
|
-
).configSchema
|
|
7
|
+
const XYPlotRendererConfigSchema =
|
|
8
|
+
pluginManager.getRendererType('XYPlotRenderer').configSchema
|
|
9
|
+
const DensityRendererConfigSchema =
|
|
10
|
+
pluginManager.getRendererType('DensityRenderer').configSchema
|
|
11
|
+
const LinePlotRendererConfigSchema =
|
|
12
|
+
pluginManager.getRendererType('LinePlotRenderer').configSchema
|
|
16
13
|
|
|
17
14
|
return ConfigurationSchema(
|
|
18
15
|
'LinearWiggleDisplay',
|
|
@@ -162,7 +162,7 @@ const stateModelFactory = (
|
|
|
162
162
|
}))
|
|
163
163
|
.views(self => ({
|
|
164
164
|
get TooltipComponent(): React.FC {
|
|
165
|
-
return
|
|
165
|
+
return Tooltip as unknown as React.FC
|
|
166
166
|
},
|
|
167
167
|
|
|
168
168
|
get adapterTypeName() {
|
|
@@ -438,17 +438,19 @@ const stateModelFactory = (
|
|
|
438
438
|
{
|
|
439
439
|
label: 'Set min/max score',
|
|
440
440
|
onClick: () => {
|
|
441
|
-
getSession(self).
|
|
442
|
-
|
|
443
|
-
|
|
441
|
+
getSession(self).queueDialog((doneCallback: Function) => [
|
|
442
|
+
SetMinMaxDlg,
|
|
443
|
+
{ model: self, handleClose: doneCallback },
|
|
444
|
+
])
|
|
444
445
|
},
|
|
445
446
|
},
|
|
446
447
|
{
|
|
447
448
|
label: 'Set color',
|
|
448
449
|
onClick: () => {
|
|
449
|
-
getSession(self).
|
|
450
|
-
|
|
451
|
-
|
|
450
|
+
getSession(self).queueDialog((doneCallback: Function) => [
|
|
451
|
+
SetColorDlg,
|
|
452
|
+
{ model: self, handleClose: doneCallback },
|
|
453
|
+
])
|
|
452
454
|
},
|
|
453
455
|
},
|
|
454
456
|
]
|
|
@@ -507,7 +509,7 @@ const stateModelFactory = (
|
|
|
507
509
|
regions: dynamicBlocks.contentBlocks.map(region => {
|
|
508
510
|
const { start, end } = region
|
|
509
511
|
return {
|
|
510
|
-
...region,
|
|
512
|
+
...JSON.parse(JSON.stringify(region)),
|
|
511
513
|
start: Math.floor(start),
|
|
512
514
|
end: Math.ceil(end),
|
|
513
515
|
}
|
|
@@ -542,13 +544,18 @@ const stateModelFactory = (
|
|
|
542
544
|
async reload() {
|
|
543
545
|
self.setError()
|
|
544
546
|
const aborter = new AbortController()
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
547
|
+
let stats
|
|
548
|
+
try {
|
|
549
|
+
stats = await getStats({
|
|
550
|
+
signal: aborter.signal,
|
|
551
|
+
filters: self.filters,
|
|
552
|
+
})
|
|
553
|
+
if (isAlive(self)) {
|
|
554
|
+
self.updateStats(stats)
|
|
555
|
+
superReload()
|
|
556
|
+
}
|
|
557
|
+
} catch (e) {
|
|
558
|
+
self.setError(e)
|
|
552
559
|
}
|
|
553
560
|
},
|
|
554
561
|
afterAttach() {
|
|
@@ -579,6 +586,7 @@ const stateModelFactory = (
|
|
|
579
586
|
}
|
|
580
587
|
} catch (e) {
|
|
581
588
|
if (!isAbortException(e) && isAlive(self)) {
|
|
589
|
+
console.error(e)
|
|
582
590
|
self.setError(e)
|
|
583
591
|
}
|
|
584
592
|
}
|
|
@@ -74,17 +74,20 @@ export class WiggleGetMultiRegionStats extends RpcMethodType {
|
|
|
74
74
|
|
|
75
75
|
async serializeArguments(
|
|
76
76
|
args: RenderArgs & { signal?: AbortSignal; statusCallback?: Function },
|
|
77
|
+
rpcDriverClassName: string,
|
|
77
78
|
) {
|
|
78
|
-
const assemblyManager =
|
|
79
|
-
?.assemblyManager
|
|
79
|
+
const assemblyManager =
|
|
80
|
+
this.pluginManager.rootModel?.session?.assemblyManager
|
|
80
81
|
if (!assemblyManager) {
|
|
81
82
|
return args
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
const renamedArgs = await renameRegionsIfNeeded(assemblyManager, {
|
|
85
86
|
...args,
|
|
86
87
|
filters: args.filters && args.filters.toJSON().filters,
|
|
87
88
|
})
|
|
89
|
+
|
|
90
|
+
return super.serializeArguments(renamedArgs, rpcDriverClassName)
|
|
88
91
|
}
|
|
89
92
|
|
|
90
93
|
async execute(
|
package/src/WiggleRendering.tsx
CHANGED
|
@@ -43,7 +43,7 @@ export default class XYPlotRenderer extends WiggleBaseRenderer {
|
|
|
43
43
|
const originY = getOrigin(scaleOpts.scaleType)
|
|
44
44
|
const [niceMin, niceMax] = scale.domain()
|
|
45
45
|
|
|
46
|
-
const toY = (n: number) => height - scale(n) + offset
|
|
46
|
+
const toY = (n: number) => height - (scale(n) || 0) + offset
|
|
47
47
|
const toHeight = (n: number) => toY(originY) - toY(n)
|
|
48
48
|
|
|
49
49
|
const colorCallback =
|
package/src/index.ts
CHANGED
|
@@ -9,12 +9,10 @@ import {
|
|
|
9
9
|
createBaseTrackModel,
|
|
10
10
|
} from '@jbrowse/core/pluggableElementTypes/models'
|
|
11
11
|
import DisplayType from '@jbrowse/core/pluggableElementTypes/DisplayType'
|
|
12
|
+
import { FileLocation } from '@jbrowse/core/util/types'
|
|
12
13
|
import WiggleBaseRenderer from './WiggleBaseRenderer'
|
|
13
14
|
import WiggleRendering from './WiggleRendering'
|
|
14
|
-
import {
|
|
15
|
-
configSchema as bigWigAdapterConfigSchema,
|
|
16
|
-
adapterCapabilities,
|
|
17
|
-
} from './BigWigAdapter'
|
|
15
|
+
import { configSchema as bigWigAdapterConfigSchema } from './BigWigAdapter'
|
|
18
16
|
import DensityRenderer, {
|
|
19
17
|
configSchema as densityRendererConfigSchema,
|
|
20
18
|
ReactComponent as DensityRendererReactComponent,
|
|
@@ -38,6 +36,11 @@ import {
|
|
|
38
36
|
WiggleGetGlobalStats,
|
|
39
37
|
WiggleGetMultiRegionStats,
|
|
40
38
|
} from './WiggleRPC/rpcMethods'
|
|
39
|
+
import {
|
|
40
|
+
AdapterGuesser,
|
|
41
|
+
getFileName,
|
|
42
|
+
TrackTypeGuesser,
|
|
43
|
+
} from '@jbrowse/core/util/tracks'
|
|
41
44
|
|
|
42
45
|
export default class WigglePlugin extends Plugin {
|
|
43
46
|
name = 'WigglePlugin'
|
|
@@ -80,11 +83,47 @@ export default class WigglePlugin extends Plugin {
|
|
|
80
83
|
new AdapterType({
|
|
81
84
|
name: 'BigWigAdapter',
|
|
82
85
|
configSchema: bigWigAdapterConfigSchema,
|
|
83
|
-
adapterCapabilities
|
|
86
|
+
adapterCapabilities: [
|
|
87
|
+
'hasResolution',
|
|
88
|
+
'hasLocalStats',
|
|
89
|
+
'hasGlobalStats',
|
|
90
|
+
],
|
|
84
91
|
getAdapterClass: () =>
|
|
85
92
|
import('./BigWigAdapter/BigWigAdapter').then(r => r.default),
|
|
86
93
|
}),
|
|
87
94
|
)
|
|
95
|
+
pluginManager.addToExtensionPoint(
|
|
96
|
+
'Core-guessAdapterForLocation',
|
|
97
|
+
(adapterGuesser: AdapterGuesser) => {
|
|
98
|
+
return (
|
|
99
|
+
file: FileLocation,
|
|
100
|
+
index?: FileLocation,
|
|
101
|
+
adapterHint?: string,
|
|
102
|
+
) => {
|
|
103
|
+
const regexGuess = /\.(bw|bigwig)$/i
|
|
104
|
+
const adapterName = 'BigWigAdapter'
|
|
105
|
+
const fileName = getFileName(file)
|
|
106
|
+
if (regexGuess.test(fileName) || adapterHint === adapterName) {
|
|
107
|
+
return {
|
|
108
|
+
type: adapterName,
|
|
109
|
+
bigWigLocation: file,
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return adapterGuesser(file, index, adapterHint)
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
)
|
|
116
|
+
pluginManager.addToExtensionPoint(
|
|
117
|
+
'Core-guessTrackTypeForLocation',
|
|
118
|
+
(trackTypeGuesser: TrackTypeGuesser) => {
|
|
119
|
+
return (adapterName: string) => {
|
|
120
|
+
if (adapterName === 'BigWigAdapter') {
|
|
121
|
+
return 'QuantitativeTrack'
|
|
122
|
+
}
|
|
123
|
+
return trackTypeGuesser(adapterName)
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
)
|
|
88
127
|
|
|
89
128
|
pluginManager.addRendererType(
|
|
90
129
|
() =>
|