import React, { useState } from 'react' import { FileSelector } from '@jbrowse/core/ui' import { Alert, FormControl, FormControlLabel, Radio, RadioGroup, } from '@mui/material' import { observer } from 'mobx-react' import { makeStyles } from 'tss-react/mui' import { launchView } from './launchView' import TextField2 from '../../../components/TextField2' import { getGeneDisplayName, getLinearGenomeView } from '../../util' import LaunchPanelContent from '../LaunchPanelContent' import SubmitCancelActions from '../SubmitCancelActions' import TranscriptSelector from '../TranscriptSelector' import { useTranscriptSelection } from '../useTranscriptSelection' import type { AbstractTrackModel, Feature, FileLocation, } from '@jbrowse/core/util' const useStyles = makeStyles()({ textAreaFont: { fontFamily: 'Courier New', }, inputContainer: { marginBottom: 30, }, fileContainer: { maxWidth: 500, }, msaInput: { marginBottom: 20, }, queryNameInput: { marginTop: 20, }, warningAlert: { marginTop: 10, }, }) const ManualMSALoader = observer(function PreLoadedMSA2({ model, feature, handleClose, }: { model: AbstractTrackModel feature: Feature handleClose: () => void }) { const view = getLinearGenomeView(model) const { classes } = useStyles() const [launchViewError, setLaunchViewError] = useState() const [inputMethod, setInputMethod] = useState<'file' | 'text'>('file') const [msaText, setMsaText] = useState('') const [treeText, setTreeText] = useState('') const [msaFileLocation, setMsaFileLocation] = useState() const [treeFileLocation, setTreeFileLocation] = useState() const [querySeqName, setQuerySeqName] = useState('') const transcriptSelection = useTranscriptSelection({ feature, view }) const { selectedTranscript, error } = transcriptSelection const e = launchViewError ?? error return ( <> { setInputMethod(event.target.value as 'file' | 'text') }} > } label="Open files" /> } label="Paste text" />
{inputMethod === 'file' ? (
) : ( <> { setMsaText(event.target.value) }} /> { setTreeText(event.target.value) }} /> )}
{ setQuerySeqName(event.target.value) }} /> {!querySeqName.trim() ? ( Without specifying the MSA row name, clicking on the MSA will not navigate to the corresponding genome position, and hovering highlights will not work. ) : null}
{ try { if (selectedTranscript) { setLaunchViewError(undefined) launchView({ newViewTitle: getGeneDisplayName(selectedTranscript), view, feature: selectedTranscript, querySeqName: querySeqName.trim(), ...(inputMethod === 'file' ? { msaFilehandle: msaFileLocation, treeFilehandle: treeFileLocation, } : { data: { msa: msaText, tree: treeText, }, }), }) handleClose() } } catch (err) { console.error(err) setLaunchViewError(err) } }} onCancel={handleClose} /> ) }) export default ManualMSALoader