Skip to content

Add ability to connect to genark and UCSC browsers to jbrowse desktop #4967

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions packages/core/ui/ConfirmDialog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { Button, DialogActions, DialogContent } from '@mui/material'
import { observer } from 'mobx-react'

import Dialog from './Dialog'

import type { DialogProps } from '@mui/material'

interface Props extends DialogProps {
header?: React.ReactNode
onCancel: () => void
onSubmit: () => void
cancelText?: string
submitText?: string
}

const ConfirmDialog = observer(function (props: Props) {
const {
onSubmit,
onCancel,
cancelText = 'Cancel',
submitText = 'OK',
children,
} = props
return (
<Dialog onClose={onCancel} {...props}>
<DialogContent>{children}</DialogContent>
<DialogActions>
<Button
color="secondary"
variant="contained"
onClick={() => {
onCancel()
}}
>
{cancelText}
</Button>
<Button
color="primary"
variant="contained"
onClick={() => {
onSubmit()
}}
>
{submitText}
</Button>
</DialogActions>
</Dialog>
)
})

export default ConfirmDialog
26 changes: 16 additions & 10 deletions packages/core/util/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,19 @@ export function clusterData({
}) {
// compute distance between each data point and every other data point
// N x N matrix where N = data.length
let start = performance.now()
let stopTokenCheckerStart = performance.now()
let progressStart = performance.now()
const distances: number[][] = []

for (let i = 0; i < data.length; i++) {
if (performance.now() - start > 400) {
const r = performance.now()
if (r - stopTokenCheckerStart > 400) {
checkStopToken(stopToken)
start = performance.now()
stopTokenCheckerStart = performance.now()
}
if (onProgress) {
onProgress(`Making distance matrix: ${toP(i / (data.length - 1))}%`)
if (r - progressStart > 50) {
onProgress?.(`Making distance matrix: ${toP(i / (data.length - 1))}%`)
progressStart = performance.now()
}

// create a row for this data point
Expand All @@ -85,14 +88,17 @@ export function clusterData({
// keep track of all tree slices
let clustersGivenK = []

start = performance.now()
stopTokenCheckerStart = performance.now()
progressStart = performance.now()
for (let iteration = 0; iteration < data.length; iteration++) {
if (performance.now() - start > 400) {
const r = performance.now()
if (r - stopTokenCheckerStart > 400) {
checkStopToken(stopToken)
start = performance.now()
stopTokenCheckerStart = performance.now()
}
if (onProgress) {
onProgress(`Clustering: ${toP((iteration + 1) / data.length)}%`)
if (r - progressStart > 50) {
onProgress?.(`Clustering: ${toP((iteration + 1) / data.length)}%`)
progressStart = performance.now()
}

// add current tree slice
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const SessionManager = observer(function ({
}}
/>
}
label="Show only favorites?"
label="Show favorites only?"
/>

<Button
Expand Down
23 changes: 0 additions & 23 deletions products/jbrowse-desktop/electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,31 +156,8 @@ interface SessionSnap {

let mainWindow: electron.BrowserWindow | null

async function updatePreconfiguredSessions() {
try {
const response = await fetch('https://jbrowse.org/genomes/sessions.json')
if (!response.ok) {
throw new Error(`HTTP ${response.status} ${response.statusText}`)
}
const data = await response.json()
for (const [key, value] of Object.entries(data)) {
// if there is not a 'gravestone' (.deleted file), then repopulate it on
// startup, this allows the user to delete even defaults if they want to
if (!fs.existsSync(`${getQuickstartPath(key)}.deleted`)) {
fs.writeFileSync(getQuickstartPath(key), JSON.stringify(value, null, 2))
}
}
} catch (e) {
// just console.error
console.error('Failed to fetch sessions.json', e)
}
}

async function createWindow() {
// no need to await, just update in background
// eslint-disable-next-line @typescript-eslint/no-floating-promises
updatePreconfiguredSessions()

const mainWindowState = windowStateKeeper({
defaultWidth: 1400,
defaultHeight: 800,
Expand Down
1 change: 1 addition & 0 deletions products/jbrowse-desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"rxjs": "^7.0.0",
"sanitize-filename": "^1.6.3",
"semver": "^7.3.5",
"swr": "^2.3.3",
"tss-react": "^4.4.1",
"use-query-params": "^2.0.0"
},
Expand Down
2 changes: 1 addition & 1 deletion products/jbrowse-desktop/src/components/Loader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { observer } from 'mobx-react'
import { StringParam, useQueryParam } from 'use-query-params'

import JBrowse from './JBrowse'
import StartScreen from './StartScreen'
import StartScreen from './StartScreen/StartScreen'
import { loadPluginManager } from './StartScreen/util'

import type PluginManager from '@jbrowse/core/PluginManager'
Expand Down
24 changes: 24 additions & 0 deletions products/jbrowse-desktop/src/components/StartScreen/Checkbox2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { Checkbox, FormControlLabel } from '@mui/material'

export default function Checkbox2({
checked,
disabled,
label,
onChange,
className,
}: {
checked: boolean
disabled?: boolean
label: React.ReactNode
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void
className?: string
}) {
return (
<FormControlLabel
className={className}
disabled={disabled}
label={label}
control={<Checkbox checked={checked} onChange={onChange} />}
/>
)
}
Loading