UNPKG

@jbrowse/plugin-linear-genome-view

Version:

JBrowse 2 linear genome view

66 lines (65 loc) 4.37 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { useState } from 'react'; import { Dialog } from '@jbrowse/core/ui'; import { getSession, isSessionWithAddTracks } from '@jbrowse/core/util'; import { makeStyles } from '@jbrowse/core/util/tss-react'; import { getSnapshot } from '@jbrowse/mobx-state-tree'; import { Button, Checkbox, DialogActions, DialogContent, FormControlLabel, FormGroup, TextField, Typography, } from '@mui/material'; import { observer } from 'mobx-react'; const useStyles = makeStyles()({ dialogContent: { width: '40em', }, }); const SequenceSearchDialog = observer(function SequenceSearchDialog({ model, handleClose, }) { const { classes } = useStyles(); const [value, setValue] = useState(''); const [searchForward, setSearchForward] = useState(true); const [searchReverse, setSearchReverse] = useState(true); const [caseInsensitive, setCaseInsensitive] = useState(true); let error; try { new RegExp(value); } catch (e) { error = e; } return (_jsxs(Dialog, { maxWidth: "xl", open: true, onClose: handleClose, title: "Sequence search", children: [_jsxs(DialogContent, { className: classes.dialogContent, children: [_jsx(Typography, { children: "Supply a sequence to search for. A track will be created with the resulting matches once submitted. You can also supply regex style expressions e.g. AACT(C|T)." }), _jsx(TextField, { value: value, onChange: e => { setValue(e.target.value); }, helperText: "Sequence search pattern" }), _jsxs(FormGroup, { children: [_jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: searchForward, onChange: event => { setSearchForward(event.target.checked); } }), label: "Search forward strand" }), _jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: searchReverse, onChange: event => { setSearchReverse(event.target.checked); } }), label: "Search reverse strand" }), _jsx(FormControlLabel, { control: _jsx(Checkbox, { checked: caseInsensitive, onChange: event => { setCaseInsensitive(event.target.checked); } }), label: "Case insensitive" })] }), error ? _jsx(Typography, { color: "error", children: `${error}` }) : null] }), _jsxs(DialogActions, { children: [_jsx(Button, { onClick: () => { if (value) { const trackId = `sequence_search_${Date.now()}`; const session = getSession(model); const { assemblyManager } = session; const assemblyName = model.assemblyNames[0]; if (isSessionWithAddTracks(session)) { session.addTrackConf({ trackId, name: `Sequence search ${value}`, assemblyNames: [assemblyName], type: 'FeatureTrack', adapter: { type: 'SequenceSearchAdapter', search: value, searchForward, searchReverse, caseInsensitive, sequenceAdapter: getSnapshot(assemblyManager.get(assemblyName)?.configuration.sequence .adapter), }, }); model.showTrack(trackId); } } handleClose(); }, variant: "contained", color: "primary", children: "Submit" }), _jsx(Button, { onClick: () => { handleClose(); }, variant: "contained", color: "secondary", children: "Close" })] })] })); }); export default SequenceSearchDialog;