UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

43 lines (42 loc) 3.5 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import { Dialog } from '@jbrowse/core/ui'; import { getSession } from '@jbrowse/core/util'; import { Button, DialogActions, DialogContent, DialogContentText, TextField, } from '@mui/material'; import TranscriptTable from "./TranscriptTable.js"; import { collapseIntrons } from "./util.js"; export default function CollapseIntronsDialog({ view, transcripts, assembly, handleClose, }) { const [showAll, setShowAll] = useState(false); const [windowSize, setWindowSize] = useState('100'); const windowSizeNum = +windowSize; const validWindowSize = !Number.isNaN(windowSizeNum) && windowSizeNum >= 0; return (_jsxs(Dialog, { open: true, maxWidth: "md", onClose: handleClose, title: "Select transcript to collapse", children: [_jsxs(DialogContent, { children: [_jsxs(DialogContentText, { component: "div", children: [_jsx("p", { children: "Select the 'window size' which will be the extra space surrounding splice boundary to include. 10bp will only include a small 10bp region around splice boundary" }), _jsx("p", { children: "By default the union of exons from all transcripts will be used to create the collapsed intron view, but you can optionally use the exons of only a specific transcript by clicking \"Show all transcripts\" and then \"Select\"" })] }), _jsx(TextField, { label: "Number of bp around splice site to include", value: windowSize, onChange: event => { setWindowSize(event.target.value); }, error: windowSize !== '' && !validWindowSize, helperText: windowSize !== '' && !validWindowSize ? 'Must be a non-negative number' : '', type: "number", slotProps: { htmlInput: { min: 0, step: 10, }, }, style: { marginBottom: 16, width: 250 } }), _jsxs(Button, { style: { float: 'right' }, onClick: () => { setShowAll(s => !s); }, children: [!showAll ? 'Show' : 'Hide', " all transcripts (", transcripts.length, ")"] }), showAll ? (_jsx(TranscriptTable, { transcripts: transcripts, view: view, assembly: assembly, padding: windowSizeNum, validPadding: validWindowSize, handleClose: handleClose })) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { size: "small", variant: "contained", color: "primary", disabled: !validWindowSize, onClick: () => { ; (async () => { try { await collapseIntrons({ view, transcripts, assembly, padding: windowSizeNum, }); handleClose(); } catch (e) { getSession(view).notifyError(`${e}`, e); console.error(e); } })(); }, children: "Submit" }), _jsx(Button, { onClick: handleClose, variant: "contained", color: "secondary", children: "Cancel" })] })] })); }