Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 24, 2024
1 parent 31c10b2 commit d551ec9
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default class BreakpointSplitViewType extends ViewType {
const bpPerPx = 10
const { assemblyManager } = session
const assembly = await assemblyManager.waitForAssembly(assemblyName)
if (!assembly) {
if (!assembly?.regions) {
throw new Error(`assembly ${assemblyName} not found`)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const SpreadsheetView = observer(function ({
const [initialHeight, setInitialHeight] = useState<number>(0)
const { classes } = useStyles()
const { spreadsheet, hideVerticalResizeHandle, height } = model
return (
return spreadsheet ? (
<>
<div style={{ height }} className={classes.contentArea}>
<SpreadsheetDataGrid model={spreadsheet} />
Expand All @@ -47,6 +47,8 @@ const SpreadsheetView = observer(function ({
/>
)}
</>
) : (
<div>Unknown</div>
)
})

Expand Down
27 changes: 17 additions & 10 deletions plugins/spreadsheet-view/src/SpreadsheetView/components/util.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
import { FileLocation, getSession } from '@jbrowse/core/util'
import {
AbstractSessionModel,
FileLocation,
getSession,
} from '@jbrowse/core/util'
import { getParent } from 'mobx-state-tree'
import { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'

type LGV = LinearGenomeViewModel
type MaybeLGV = LinearGenomeViewModel | undefined

export function locationLinkClick(
spreadsheet: { assemblyName?: string },
locString: string,
) {
const session = getSession(spreadsheet)
const { assemblyName } = spreadsheet
const { id } = getParent<{ id: string }>(spreadsheet)

const newViewId = `${id}_${assemblyName}`
export function locationLinkClick({
assemblyName,
session,
locString,
spreadsheetViewId,
}: {
assemblyName: string
session: AbstractSessionModel
locString: string
spreadsheetViewId: string
}) {
const newViewId = `${spreadsheetViewId}_${assemblyName}`
let view = session.views.find(v => v.id === newViewId) as MaybeLGV
if (!view) {
view = session.addView('LinearGenomeView', { id: newViewId }) as LGV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,21 @@ import { locationLinkClick } from '../../components/util'
export default function FeatureMenu({
assemblyName,
session,
row,
spreadsheetId,
arg,
spreadsheetViewId,
}: {
spreadsheetId: string
spreadsheetViewId: string
assemblyName: string
session: AbstractSessionModel
row: {
feature: Feature
value: string
arg: {
value?: string
row: {
feature: Feature
loc: string
}
}
}) {
const { row } = arg
return (
<CascadingMenuButton
menuItems={[
Expand All @@ -31,51 +35,53 @@ export default function FeatureMenu({
try {
await locationLinkClick({
spreadsheetViewId,
locString: row.value,
locString: row.loc,
assemblyName,
session,
})
} catch (e) {
console.error(e)
session.notify(`${e}`, 'error')
session.notifyError(`${e}`, e)
}
},
},
{
label: 'Open in single level split view',
label: 'Open in single-level split view',
onClick: async () => {
try {
const { pluginManager } = getEnv(session)
const viewType = pluginManager.getViewType('BreakpointSplitView')!
// @ts-expect-error
const snap = viewType.singleLevelSnapshotFromBreakendFeature({
feature: row.feature,
session,
assemblyName,
})
const snap =
// @ts-expect-error
await viewType.singleLevelSnapshotFromBreakendFeature({
feature: row.feature,
session,
assemblyName,
})
console.log({ snap })
session.addView('BreakpointSplitView', snap)
} catch (e) {
console.error(e)
session.notify(`${e}`, 'error')
session.notifyError(`${e}`, e)
}
},
},
{
label: 'Open in breakpoint split view',
label: 'Open in multi-level split view',
onClick: async () => {
try {
const { pluginManager } = getEnv(session)
const viewType = pluginManager.getViewType('BreakpointSplitView')!
// @ts-expect-error
const snap = viewType.snapshotFromBreakendFeature({
const snap = await viewType.snapshotFromBreakendFeature({
feature: row.feature,
session,
assemblyName,
})
session.addView('BreakpointSplitView', snap)
} catch (e) {
console.error(e)
session.notify(`${e}`, 'error')
session.notifyError(`${e}`, e)
}
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ function stateModelFactory() {
session={session}
spreadsheetViewId={getParent<{ id: string }>(self).id}
assemblyName={self.assemblyName}
// @ts-expect-error
row={row}
arg={row}
/>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ function stateModelFactory() {
* load a new spreadsheet and set our mode to display it
*/
displaySpreadsheet(spreadsheet: SpreadsheetData, assemblyName: string) {
// @ts-expect-error
self.spreadsheet = { assemblyName }
// @ts-expect-error
self.spreadsheet.setData(spreadsheet)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ function SvInspectorViewF(pluginManager: PluginManager) {
{
label: 'Return to import form',
onClick: () => {
self.spreadsheetView.spreadsheet.setData(undefined)
self.spreadsheetView.clearData()
},
icon: FolderOpenIcon,
},
Expand Down

0 comments on commit d551ec9

Please sign in to comment.