jbrowse-plugin-graphgenomeviewer 8.6.0 → 8.7.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jbrowse-plugin-graphgenomeviewer",
3
- "version": "8.6.0",
3
+ "version": "8.7.0",
4
4
  "description": "JBrowse 2 graph genome (pangenome) view: rGFA reference-anchored layouts, the Bandage force-directed engine, and haplotype lanes read from a gbz-base database",
5
5
  "license": "GPL-3.0-or-later",
6
6
  "repository": {
@@ -44,6 +44,7 @@
44
44
  "@jbrowse/cli": "^4.3.0",
45
45
  "@jbrowse/mobx-state-tree": "^6.10.0",
46
46
  "@jbrowse/plugin-linear-genome-view": "5.0.0-beta.19",
47
+ "@jbrowse/plugin-variants": "5.0.0-beta.19",
47
48
  "@mui/icons-material": "^9.5.0",
48
49
  "@mui/material": "^9.5.0",
49
50
  "@mui/system": "^9.5.0",
@@ -12,7 +12,14 @@ import type { AnyConfigurationModel } from '@jbrowse/core/configuration'
12
12
  import type { MenuItem } from '@jbrowse/core/ui'
13
13
  import type { IAnyModelType, IAnyStateTreeNode } from '@jbrowse/mobx-state-tree'
14
14
 
15
- export const FORMS_DISPLAYS = ['LinearMultiSampleVariantDisplay']
15
+ // By track type, not display name, which has changed across releases; the
16
+ // mixin is inert off a WalkFormsAdapter track
17
+ export function takesFormsMenu(display: DisplayType) {
18
+ return (
19
+ display.viewType === 'LinearGenomeView' &&
20
+ [display.trackType].flat().includes('VariantTrack')
21
+ )
22
+ }
16
23
 
17
24
  export const FLOORS: { label: string; value: FloorBp }[] = [
18
25
  { label: 'Auto', value: 'auto' },
@@ -191,12 +198,18 @@ export function withFormsMenu(model: IAnyModelType) {
191
198
 
192
199
  export default function WalkFormsMenuF(pluginManager: PluginManager) {
193
200
  pluginManager.addToExtensionPoint('Core-extendPluggableElement', element => {
194
- if (
195
- element instanceof DisplayType &&
196
- FORMS_DISPLAYS.includes(element.name)
197
- ) {
201
+ if (element instanceof DisplayType && takesFormsMenu(element)) {
198
202
  element.extendStateModel(withFormsMenu)
199
203
  }
200
204
  return element
201
205
  })
202
206
  }
207
+
208
+ export function warnIfNoFormsDisplay(pluginManager: PluginManager) {
209
+ const displays = pluginManager.getElementTypesInGroup('display')
210
+ if (!displays.some(d => d instanceof DisplayType && takesFormsMenu(d))) {
211
+ console.warn(
212
+ 'jbrowse-plugin-graphgenomeviewer: no linear VariantTrack display is registered, so WalkFormsAdapter tracks get no pin or floor menu',
213
+ )
214
+ }
215
+ }
@@ -0,0 +1,61 @@
1
+ import PluginManager from '@jbrowse/core/PluginManager'
2
+ import LinearGenomeViewPlugin from '@jbrowse/plugin-linear-genome-view'
3
+ import VariantsPlugin from '@jbrowse/plugin-variants'
4
+ import { expect, test, vi } from 'vitest'
5
+
6
+ import GraphGenomeViewPlugin from '../index'
7
+ import { takesFormsMenu } from './formsMenu.ts'
8
+
9
+ import type DisplayType from '@jbrowse/core/pluggableElementTypes/DisplayType'
10
+
11
+ // The host's own variant displays, not a fake: the mixin reads members of the
12
+ // multi-sample display by name, and a host that renames one drops the menu
13
+ // without an error.
14
+ function setup(plugins: { install: unknown }[]) {
15
+ const pluginManager = new PluginManager([
16
+ new LinearGenomeViewPlugin(),
17
+ ...(plugins as never[]),
18
+ new GraphGenomeViewPlugin(),
19
+ ])
20
+ pluginManager.createPluggableElements()
21
+ pluginManager.configure()
22
+ return pluginManager
23
+ }
24
+
25
+ test("the host's multi-sample variant display carries the forms menu", async () => {
26
+ const pluginManager = setup([new VariantsPlugin()])
27
+ const displays = (
28
+ pluginManager.getElementTypesInGroup('display') as DisplayType[]
29
+ ).filter(takesFormsMenu)
30
+ await Promise.all(displays.map(d => d.loadStateModel()))
31
+ const withRows = displays.flatMap(t => {
32
+ const display = t.stateModel.create(
33
+ {
34
+ type: t.name,
35
+ configuration: t.configSchema.create({ displayId: 'x', type: t.name }),
36
+ },
37
+ { pluginManager },
38
+ )
39
+ return 'sourcesBase' in display ? [{ name: t.name, display }] : []
40
+ })
41
+ expect(withRows.map(d => d.name)).not.toEqual([])
42
+ for (const { display } of withRows) {
43
+ for (const member of [
44
+ 'formsMenuItems',
45
+ 'setFormsPinned',
46
+ 'setSources',
47
+ 'trackMenuItems',
48
+ ]) {
49
+ expect(member in display).toBe(true)
50
+ }
51
+ }
52
+ })
53
+
54
+ test('a host with no variant display warns', () => {
55
+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
56
+ setup([])
57
+ expect(warn).toHaveBeenCalledWith(
58
+ expect.stringContaining('no linear VariantTrack display'),
59
+ )
60
+ warn.mockRestore()
61
+ })
package/src/index.ts CHANGED
@@ -14,7 +14,9 @@ import LaunchGraphGenomeViewF from './LaunchGraphGenomeView'
14
14
  import LinearGraphDisplayF from './LinearGraphDisplay/index'
15
15
  import MinigraphBubbleAdapterF from './MinigraphBubbleAdapter/index'
16
16
  import RgfaTabixAdapterF from './RgfaTabixAdapter/index'
17
- import WalkFormsMenuF from './WalkFormsAdapter/formsMenu'
17
+ import WalkFormsMenuF, {
18
+ warnIfNoFormsDisplay,
19
+ } from './WalkFormsAdapter/formsMenu'
18
20
  import WalkFormsAdapterF from './WalkFormsAdapter/index'
19
21
  import WalkTabixSyntenyAdapterF from './WalkTabixSyntenyAdapter/index'
20
22
  import GraphTrackDefaultsF from './graphTrackDefaults/index'
@@ -56,6 +58,7 @@ export default class GraphGenomeViewPlugin extends Plugin {
56
58
  // jbrowse.org/ucsc launch by appending to a menu a released host defines as
57
59
  // a function. The view is still reachable without the entry.
58
60
  configure(pluginManager: PluginManager) {
61
+ warnIfNoFormsDisplay(pluginManager)
59
62
  try {
60
63
  if (isAbstractMenuManager(pluginManager.rootModel)) {
61
64
  pluginManager.rootModel.appendToSubMenu(['Add'], {
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '8.6.0'
1
+ export const version = '8.7.0'