JBrowse 2 · Circular Genome View examples

Inline plugin

A Plugin subclass that adds a view menu item.

Open the view’s menu, at the top left, to find Rotate half a turn. A published plugin goes through loadPlugins instead, as on the linear view’s plugins page; the plugin store lists them.

View source — 54 lines
import Plugin from '@jbrowse/core/Plugin'
import { extendViewType } from '@jbrowse/core/pluggableElementTypes'
import { CircularGenomeView } from '@jbrowse/react-circular-genome-view2'

import type PluginManager from '@jbrowse/core/PluginManager'

class HalfTurnPlugin extends Plugin {
  name = 'HalfTurnPlugin'

  install(pluginManager: PluginManager) {
    extendViewType(pluginManager, 'CircularView', stateModel =>
      stateModel.extend(self => {
        const superMenuItems = self.menuItems
        return {
          views: {
            menuItems() {
              return [
                ...superMenuItems(),
                {
                  label: 'Rotate half a turn',
                  onClick: () => {
                    self.rotate(Math.PI)
                  },
                },
              ]
            },
          },
        }
      }),
    )
  }

  configure() {}
}

export default function InlinePlugin() {
  return (
    <CircularGenomeView
      assembly={{
        name: 'volvox',
        uri: 'https://jbrowse.org/genomes/volvox/volvox.2bit',
      }}
      plugins={[HalfTurnPlugin]}
      tracks={[
        {
          trackId: 'volvox_sv',
          name: 'Volvox duplications',
          uri: 'https://jbrowse.org/code/jb2/main/test_data/volvox/volvox.dup.vcf.gz',
        },
      ]}
      view={{ tracks: ['volvox_sv'] }}
    />
  )
}