Skip to content

Commit

Permalink
Misc updates, don't block loading until pairwise sequence analysis lo…
Browse files Browse the repository at this point in the history
…aded
  • Loading branch information
cmdcolin committed Jun 3, 2024
1 parent 952eaad commit 0140572
Show file tree
Hide file tree
Showing 7 changed files with 958 additions and 971 deletions.
1 change: 1 addition & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
root: true,
env: {
browser: true,
es2021: true,
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,25 @@
"@jbrowse/plugin-linear-genome-view": "^2.4.2",
"@mui/material": "^5.12.0",
"@mui/system": "^5.12.0",
"@mui/x-data-grid": "^6.16.1",
"@mui/x-data-grid": "^7.3.0",
"@types/jest": "^29.5.12",
"@types/node": "^20.11.16",
"@types/pako": "^2.0.0",
"@types/react": "^18.2.54",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"esbuild": "^0.20.0",
"esbuild": "^0.21.4",
"eslint": "^8.38.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-react": "^7.20.3",
"eslint-plugin-react-hooks": "^4.0.8",
"eslint-plugin-react-refresh": "^0.4.3",
"eslint-plugin-unicorn": "^51.0.0",
"eslint-plugin-unicorn": "^53.0.0",
"jest": "^29.7.0",
"mobx": "^6.0.0",
"mobx-react": "^9.0.1",
"mobx-state-tree": "5.4.1",
"mobx-state-tree": "5.4.2",
"npm-run-all": "^4.1.5",
"prettier": "^3.2.5",
"pretty-bytes": "^6.1.1",
Expand Down
98 changes: 57 additions & 41 deletions src/ProteinView/components/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,61 +1,77 @@
import React, { useState } from 'react'
import React from 'react'
import { observer } from 'mobx-react'
import CascadingMenuButton from '@jbrowse/core/ui/CascadingMenuButton'

// icons
import MenuIcon from '@mui/icons-material/Menu'
import Visibility from '@mui/icons-material/Visibility'

// locals
import { JBrowsePluginProteinViewModel } from '../model'
import ProteinAlignment from './ProteinAlignment'
import { Visibility } from '@mui/icons-material'

const ProteinViewHeader = observer(function ({
model,
}: {
model: JBrowsePluginProteinViewModel
}) {
const { clickString, hoverString, showHighlight, zoomToBaseLevel } = model
const [show, setShow] = useState(true)
const { alignment, showAlignment } = model
return (
<div>
<div style={{ display: 'flex' }}>
<span>
{[
clickString ? `Click: ${clickString}` : '',
hoverString ? `Hover: ${hoverString}` : '',
].join(' ')}
</span>
<span style={{ flexGrow: 1 }} />
<CascadingMenuButton
menuItems={[
{
label: 'Show alignment',
type: 'checkbox',
checked: show,
icon: Visibility,
onClick: () => setShow(!show),
},
{
label: 'Show highlight',
type: 'checkbox',
checked: showHighlight,
icon: Visibility,
onClick: () => model.setShowHighlight(!showHighlight),
},
{
label: 'Zoom to base level on click',
type: 'checkbox',
checked: zoomToBaseLevel,
icon: Visibility,
onClick: () => model.setZoomToBaseLevel(!zoomToBaseLevel),
},
]}
>
<MenuIcon />
</CascadingMenuButton>
</div>
<div>{show ? <ProteinAlignment model={model} /> : null}</div>
<InformativeHeaderArea model={model} />
{showAlignment && alignment ? <ProteinAlignment model={model} /> : null}
</div>
)
})

const InformativeHeaderArea = observer(function ({
model,
}: {
model: JBrowsePluginProteinViewModel
}) {
const {
showAlignment,
clickString,
hoverString,
showHighlight,
zoomToBaseLevel,
} = model
return (
<div style={{ display: 'flex' }}>
<span>
{[
clickString ? `Click: ${clickString}` : '',
hoverString ? `Hover: ${hoverString}` : '',
].join(' ')}
</span>
<span style={{ flexGrow: 1 }} />
<CascadingMenuButton
menuItems={[
{
label: 'Show pairwise alignment area',
type: 'checkbox',
checked: showAlignment,
icon: Visibility,
onClick: () => model.setShowAlignment(!showAlignment),
},
{
label: 'Show pairwise alignment as highlight',
type: 'checkbox',
checked: showHighlight,
icon: Visibility,
onClick: () => model.setShowHighlight(!showHighlight),
},
{
label: 'Zoom to base level on click',
type: 'checkbox',
checked: zoomToBaseLevel,
icon: Visibility,
onClick: () => model.setZoomToBaseLevel(!zoomToBaseLevel),
},
]}
>
<MenuIcon />
</CascadingMenuButton>
</div>
)
})
Expand Down
11 changes: 5 additions & 6 deletions src/ProteinView/components/ProteinView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useEffect } from 'react'
import { observer } from 'mobx-react'
import { ErrorMessage, LoadingEllipses } from '@jbrowse/core/ui'
import { ErrorMessage } from '@jbrowse/core/ui'
import { PluginContext } from 'molstar/lib/mol-plugin/context'

// locals
Expand Down Expand Up @@ -31,23 +31,21 @@ const ProteinView = observer(function ({
}: {
model: JBrowsePluginProteinViewModel
}) {
const { url, data, showControls, alignment } = model
const { url, data, showControls } = model
const { plugin, seq, parentRef, error } = useProteinView({
url,
data,
showControls,
})
return error ? (
<ErrorMessage error={error} />
) : alignment ? (
) : (
<ProteinViewContainer
model={model}
plugin={plugin}
seq={seq}
parentRef={parentRef}
/>
) : (
<LoadingEllipses title="Loading pairwise alignment" />
)
})

Expand All @@ -69,6 +67,7 @@ const ProteinViewContainer = observer(function ({
seq2,
structureSeqHoverPos,
showHighlight,
alignment,
} = model

const { error } = useProteinViewClickBehavior({ plugin, model })
Expand Down Expand Up @@ -114,7 +113,7 @@ const ProteinViewContainer = observer(function ({
}, [plugin, structure, structureSeqHoverPos])

return (
<div>
<div style={{ background: !alignment ? '#ccc' : undefined }}>
{error ? <ErrorMessage error={error} /> : null}
<Header model={model} />
<div
Expand Down
10 changes: 10 additions & 0 deletions src/ProteinView/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ function stateModelFactory() {
* #property
*/
zoomToBaseLevel: false,
/**
* #property
*/
showAlignment: true,
}),
)
.volatile(() => ({
Expand Down Expand Up @@ -139,6 +143,12 @@ function stateModelFactory() {
},
}))
.actions(self => ({
/**
* #action
*/
setShowAlignment(f: boolean) {
self.showAlignment = f
},
/**
* #action
*/
Expand Down
1 change: 0 additions & 1 deletion src/ProteinView/proteinToGenomeMapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export async function clickProteinToGenome({
if (!zoomToBaseLevel) {
const assembly = assemblyManager.get(lgv.assemblyNames[0])
const r = assembly?.getCanonicalRefName(refName) ?? refName
// @ts-expect-error
lgv.centerAt(s1, r)
} else {
await lgv.navToLocString(
Expand Down
Loading

0 comments on commit 0140572

Please sign in to comment.