Skip to content

Commit

Permalink
Volatile-ize spreadsheet view
Browse files Browse the repository at this point in the history
Remove

[skip ci] Volatile

[skip ci] Parse out INFO field

[skip ci] Misc

Misc

Restyling

Refactoring

More misc

Misc

Misc

Misc

Misc

New

Refname renaming fix for breakpoint split view

Breakpoint split view

Misc

[skip ci] Refactors

Use 7.0.0

Updates

Misc

Misc

Misc

SV inspector working

Wow

Misc

More notifyError
  • Loading branch information
cmdcolin committed Nov 4, 2024
1 parent c5ba32e commit 834ad10
Show file tree
Hide file tree
Showing 93 changed files with 1,428 additions and 29,414 deletions.
1 change: 1 addition & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default tseslint.config(
'@typescript-eslint/no-unsafe-member-access': 'off',
'@typescript-eslint/no-unsafe-argument': 'off',
'@typescript-eslint/no-unsafe-assignment': 'off',
'@typescript-eslint/no-deprecated': 'off',
'@typescript-eslint/restrict-plus-operands': 'off',
'@typescript-eslint/no-unsafe-call': 'off',
'@typescript-eslint/no-unsafe-return': 'off',
Expand Down
6 changes: 6 additions & 0 deletions packages/core/assemblyManager/assembly.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,12 @@ export default function assemblyFactory(
self.refNameAliases[refName] || self.lowerCaseRefNameAliases[refName]
)
},
/**
* #method
*/
getCanonicalRefNameOrDefault(refName: string) {
return this.getCanonicalRefName(refName) || refName
},
/**
* #method
*/
Expand Down
4 changes: 1 addition & 3 deletions packages/core/assemblyManager/assemblyManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,7 @@ function assemblyManagerFactory(conf: IAnyType, pm: PluginManager) {
if (assembly) {
return assembly.isValidRefName(refName)
}
throw new Error(
`Failed to look up refName ${refName} on ${assemblyName} because assembly does not exist`,
)
throw new Error(`assembly "${assemblyName}" not found`)
},
}))
.actions(self => ({
Expand Down
2 changes: 1 addition & 1 deletion packages/core/configuration/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
* will be sent to each of the slotNames
*/
export function readConfObject<CONFMODEL extends AnyConfigurationModel>(
confObject: CONFMODEL,
confObject: CONFMODEL | Record<string, unknown>,
slotPath?:
| ConfigurationSlotName<ConfigurationSchemaForModel<CONFMODEL>>
| string[],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const OldHydrate = observer(function OldHydrate(props: Props) {
function doHydrate() {
if (domNode && html) {
if (domNode.innerHTML) {

unmountComponentAtNode(domNode)
}

Expand All @@ -80,13 +81,15 @@ const OldHydrate = observer(function OldHydrate(props: Props) {
// hydration for when we have some free time. helps keep the
// framerate up.
rIC(() => {

hydrate(<RenderingComponent {...props} />, domNode)
})
}
}
doHydrate()
return () => {
if (domNode) {

unmountComponentAtNode(domNode)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ const OldHydrate = observer(function ({
const domNode = ref.current
function doHydrate() {
if (domNode) {

unmountComponentAtNode(domNode)
domNode.innerHTML = html

rIC(() => {

hydrate(
<ThemeProvider theme={jbrowseTheme}>
<RenderingComponent {...rest} />
Expand All @@ -100,6 +102,7 @@ const OldHydrate = observer(function ({

return () => {
if (domNode) {

unmountComponentAtNode(domNode)
}
}
Expand Down
7 changes: 5 additions & 2 deletions packages/core/ui/ResizeHandle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ const useStyles = makeStyles()({
},
flexbox_verticalHandle: {
cursor: 'col-resize',
alignSelf: 'stretch', // the height: 100% is actually unable to function inside flexbox
alignSelf: 'stretch',
// uses alignSelf:stretch with flexbox as the height: 100% is actually
// unable to function inside flexbox
},
flexbox_horizontalHandle: {
cursor: 'row-resize',
alignSelf: 'stretch', // similar to above
alignSelf: 'stretch',
// similar to above
},
})

Expand Down
1 change: 1 addition & 0 deletions packages/core/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ export function renderToStaticMarkup(
if (createRootFn) {
createRootFn(div).render(node)
} else {

render(node, div)
}
})
Expand Down
69 changes: 39 additions & 30 deletions packages/sv-core/src/BreakendMultiLevelOptionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Button, DialogActions, DialogContent } from '@mui/material'
import { getSnapshot } from 'mobx-state-tree'
import { Dialog } from '@jbrowse/core/ui'
import { when } from 'mobx'
import { getSession, Feature } from '@jbrowse/core/util'
import { Feature, AbstractSessionModel } from '@jbrowse/core/util'
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
import type { Assembly } from '@jbrowse/core/assemblyManager/assembly'

Expand All @@ -29,17 +29,17 @@ function stripIds(arr: Track[]) {
}

const BreakendMultiLevelOptionDialog = observer(function ({
model,
session,
handleClose,
feature,
assemblyName,
viewType,
view,
}: {
model: unknown
session: AbstractSessionModel
handleClose: () => void
feature: Feature
view: LinearGenomeViewModel
view?: LinearGenomeViewModel
assemblyName: string
viewType: {
getBreakendCoveringRegions: (arg: {
Expand All @@ -63,45 +63,52 @@ const BreakendMultiLevelOptionDialog = observer(function ({
title="Multi-level breakpoint split view options"
>
<DialogContent>
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>
<div>Launch multi-level breakpoint split view</div>
{view ? (
<>
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>

{copyTracks ? (
<Checkbox2
checked={mirror}
disabled={!copyTracks}
label="Mirror the copied tracks (only available if copying tracks and using two level)"
onChange={event => {
setMirror(event.target.checked)
}}
/>
{copyTracks ? (
<Checkbox2
checked={mirror}
disabled={!copyTracks}
label="Mirror the copied tracks (only available if copying tracks and using two level)"
onChange={event => {
setMirror(event.target.checked)
}}
/>
) : null}
</>
) : null}
</DialogContent>
<DialogActions>
<Button
onClick={() => {
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
const session = getSession(model)
try {
const asm =
await session.assemblyManager.waitForAssembly(assemblyName)
if (!asm) {
const { assemblyManager } = session
const assembly =
await assemblyManager.waitForAssembly(assemblyName)
if (!assembly) {
throw new Error(`assembly ${assemblyName} not found`)
}

const { refName, pos, mateRefName, matePos } =
viewType.getBreakendCoveringRegions({
feature,
assembly: asm,
assembly: assembly,
})

const viewTracks = getSnapshot(view.tracks) as Track[]
const viewTracks = view
? (getSnapshot(view.tracks) as Track[])
: []
const breakpointSplitView = session.addView(
'BreakpointSplitView',
{
Expand All @@ -114,7 +121,7 @@ const BreakendMultiLevelOptionDialog = observer(function ({
{
type: 'LinearGenomeView',
hideHeader: true,
tracks: stripIds(getSnapshot(view.tracks)),
tracks: stripIds(viewTracks),
},
{
type: 'LinearGenomeView',
Expand All @@ -126,8 +133,10 @@ const BreakendMultiLevelOptionDialog = observer(function ({
],
},
) as unknown as { views: LinearGenomeViewModel[] }
const r1 = asm.regions!.find(r => r.refName === refName)
const r2 = asm.regions!.find(r => r.refName === mateRefName)
const r1 = assembly.regions!.find(r => r.refName === refName)
const r2 = assembly.regions!.find(
r => r.refName === mateRefName,
)
if (!r1 || !r2) {
throw new Error("can't find regions")
}
Expand Down Expand Up @@ -172,7 +181,7 @@ const BreakendMultiLevelOptionDialog = observer(function ({
breakpointSplitView.views[0]!.centerAt(pos, refName)
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
})()
handleClose()
Expand Down
39 changes: 23 additions & 16 deletions packages/sv-core/src/BreakendSingleLevelOptionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { Button, DialogActions, DialogContent, TextField } from '@mui/material'
import { getSnapshot } from 'mobx-state-tree'
import { Dialog } from '@jbrowse/core/ui'
import {
getSession,
Feature,
gatherOverlaps,
useLocalStorage,
AbstractSessionModel,
} from '@jbrowse/core/util'
import type { LinearGenomeViewModel } from '@jbrowse/plugin-linear-genome-view'
import type { Assembly } from '@jbrowse/core/assemblyManager/assembly'
Expand All @@ -33,17 +33,17 @@ function stripIds(arr: Track[]) {
}

const BreakendSingleLevelOptionDialog = observer(function ({
model,
session,
handleClose,
feature,
assemblyName,
viewType,
view,
}: {
model: unknown
session: AbstractSessionModel
handleClose: () => void
feature: Feature
view: LinearGenomeViewModel
view?: LinearGenomeViewModel
assemblyName: string
viewType: {
getBreakendCoveringRegions: (arg: {
Expand All @@ -70,13 +70,15 @@ const BreakendSingleLevelOptionDialog = observer(function ({
title="Single-level breakpoint split view options"
>
<DialogContent>
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>
{view ? (
<Checkbox2
checked={copyTracks}
label="Copy tracks into the new view"
onChange={event => {
setCopyTracks(event.target.checked)
}}
/>
) : null}

<TextField
label="Window size (bp)"
Expand All @@ -89,17 +91,20 @@ const BreakendSingleLevelOptionDialog = observer(function ({
<DialogActions>
<Button
onClick={() => {
const session = getSession(model)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
;(async () => {
try {
const assembly = session.assemblyManager.get(assemblyName)
const { assemblyManager } = session
const assembly =
await assemblyManager.waitForAssembly(assemblyName)
if (!assembly) {
throw new Error(`assembly ${assemblyName} not found`)
}
const w = +windowSize
if (Number.isNaN(w)) {
throw new Error('windowSize not a number')
}
const { refName, pos, mateRefName, matePos } =
// @ts-expect-error
viewType.getBreakendCoveringRegions({ feature, assembly })

const breakpointSplitView = session.addView(
Expand All @@ -112,7 +117,9 @@ const BreakendSingleLevelOptionDialog = observer(function ({
views: [
{
type: 'LinearGenomeView',
tracks: stripIds(getSnapshot(view.tracks)),
tracks: view?.tracks
? stripIds(getSnapshot(view.tracks))
: [],
},
],
},
Expand All @@ -139,7 +146,7 @@ const BreakendSingleLevelOptionDialog = observer(function ({
)
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
})()
handleClose()
Expand Down
2 changes: 1 addition & 1 deletion plugins/alignments/src/AlignmentsFeatureDetail/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ export async function navToLoc(locString: string, model: IAnyStateTreeNode) {
}
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export function SharedLinearPileupDisplayMixin(
}
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
},

Expand Down Expand Up @@ -429,7 +429,7 @@ export function SharedLinearPileupDisplayMixin(
}
} catch (e) {
console.error(e)
session.notify(`${e}`)
session.notifyError(`${e}`, e)
}
},
}
Expand Down
Loading

0 comments on commit 834ad10

Please sign in to comment.