Skip to content

Commit

Permalink
Add ability to show all regions with data from TRA features with CHR2
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Mar 7, 2023
1 parent 5df0d50 commit 4f6f926
Show file tree
Hide file tree
Showing 3 changed files with 186 additions and 161 deletions.
26 changes: 25 additions & 1 deletion plugins/sv-inspector/src/SvInspectorView/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,34 @@ import ViewType from '@jbrowse/core/pluggableElementTypes/ViewType'

import ReactComponent from './components/SvInspectorView'
import stateModelFactory from './models/SvInspectorView'
import { Feature, getContainingView, getSession } from '@jbrowse/core/util'
import { IAnyStateTreeNode } from 'mobx-state-tree'

function defaultOnChordClick(
feature: Feature,
chordTrack: IAnyStateTreeNode,
pluginManager: PluginManager,
) {
const session = getSession(chordTrack)
session.setSelection(feature)
const view = getContainingView(chordTrack)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const viewType = pluginManager.getViewType('BreakpointSplitView') as any
const viewSnapshot = viewType.snapshotFromBreakendFeature(feature, view)

// try to center the offsetPx
viewSnapshot.views[0].offsetPx -= view.width / 2 + 100
viewSnapshot.views[1].offsetPx -= view.width / 2 + 100
viewSnapshot.featureData = feature.toJSON()

session.addView('BreakpointSplitView', viewSnapshot)
}

export default (pluginManager: PluginManager) => {
pluginManager.jexl.addFunction('defaultOnChordClick', defaultOnChordClick)

pluginManager.addViewType(() => {
const { stateModel } = stateModelFactory(pluginManager)
const stateModel = stateModelFactory(pluginManager)
return new ViewType({
name: 'SvInspectorView',
displayName: 'SV inspector',
Expand Down
Loading

0 comments on commit 4f6f926

Please sign in to comment.