Skip to content

Commit

Permalink
Fix use of "show all regions with data" feature in SV inspector with …
Browse files Browse the repository at this point in the history
…TRA entries (with CHR2 from INFO) (#3566)

* Make tests robust to jest --randomize

* Add ability to show all regions with data from TRA features with CHR2

* Update auto-gen docs
  • Loading branch information
cmdcolin committed Mar 7, 2023
1 parent d9e5ecc commit 1c35f96
Show file tree
Hide file tree
Showing 14 changed files with 482 additions and 201 deletions.
5 changes: 0 additions & 5 deletions plugins/linear-genome-view/src/LinearGenomeView/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ test('can navToMultiple', () => {
describe('Zoom to selected displayed regions', () => {
const { Session, LinearGenomeModel } = initialize()
let model: LGV
let largestBpPerPx: number
beforeEach(() => {
const session = Session.create({
configuration: {},
Expand Down Expand Up @@ -357,7 +356,6 @@ describe('Zoom to selected displayed regions', () => {
},
)

largestBpPerPx = model.bpPerPx
expect(model.offsetPx).toEqual(0)
expect(model.bpPerPx).toBeCloseTo(31.408)
})
Expand All @@ -384,7 +382,6 @@ describe('Zoom to selected displayed regions', () => {
expect(model.offsetPx).toEqual(0)
// 10000 - 5000 = 5000 / 800 = 6.25
expect(model.bpPerPx).toEqual(6.25)
expect(model.bpPerPx).toBeLessThan(largestBpPerPx)
})

it('can select one region with start or end outside of displayed region', () => {
Expand All @@ -411,7 +408,6 @@ describe('Zoom to selected displayed regions', () => {
expect(Math.abs(model.offsetPx)).toEqual(0)
// endOffset 19000 - (-1) = 19001 / 800 = zoomTo(23.75)
expect(model.bpPerPx).toBeCloseTo(23.75)
expect(model.bpPerPx).toBeLessThan(largestBpPerPx)
})

it('can select over two regions in the same reference sequence', () => {
Expand Down Expand Up @@ -439,7 +435,6 @@ describe('Zoom to selected displayed regions', () => {
expect(model.bpPerPx).toBeCloseTo(27.78, 0)
// offset 5000 / bpPerPx (because that is the starting) = 180.5
expect(model.offsetPx).toBe(181)
expect(model.bpPerPx).toBeLessThan(largestBpPerPx)
})

it('can navigate to overlapping regions with a region between', () => {
Expand Down
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 1c35f96

Please sign in to comment.