Skip to content
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

Add pif.gz option to synteny import form #4573

Merged
merged 2 commits into from
Sep 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ function getAdapter({
assembly1,
assembly2,
fileLocation,
indexFileLocation,
bed1Location,
bed2Location,
}: {
radioOption: string
assembly1: string
assembly2: string
fileLocation?: FileLocation
indexFileLocation?: FileLocation
bed1Location?: FileLocation
bed2Location?: FileLocation
}) {
Expand Down Expand Up @@ -73,6 +75,13 @@ function getAdapter({
bed2Location,
assemblyNames: [assembly1, assembly2],
}
} else if (radioOption === '.pif.gz') {
return {
type: 'PairwiseIndexedPAFAdapter',
pifGzLocation: fileLocation,
index: { location: indexFileLocation },
assemblyNames: [assembly1, assembly2],
}
} else {
throw new Error(
`Unknown to detect type ${radioOption} from filename (select radio button to clarify)`,
Expand All @@ -82,174 +91,206 @@ function getAdapter({

type Conf = SnapshotIn<AnyConfigurationModel>

const OpenTrack = observer(
({
assembly1,
assembly2,
setSessionTrackData,
}: {
sessionTrackData: Conf
assembly1: string
assembly2: string
setSessionTrackData: (arg: Conf) => void
}) => {
const [bed2Location, setBed2Location] = useState<FileLocation>()
const [bed1Location, setBed1Location] = useState<FileLocation>()
const [fileLocation, setFileLocation] = useState<FileLocation>()
const [value, setValue] = useState('')
const [error, setError] = useState<unknown>()
const fileName = getName(fileLocation)
const ImportCustomTrack = observer(function ({
assembly1,
assembly2,
setSessionTrackData,
}: {
sessionTrackData: Conf
assembly1: string
assembly2: string
setSessionTrackData: (arg: Conf) => void
}) {
const [bed2Location, setBed2Location] = useState<FileLocation>()
const [bed1Location, setBed1Location] = useState<FileLocation>()
const [fileLocation, setFileLocation] = useState<FileLocation>()
const [indexFileLocation, setIndexFileLocation] = useState<FileLocation>()
const [value, setValue] = useState('')
const [error, setError] = useState<unknown>()
const fileName = getName(fileLocation)

const radioOption = value || (fileName ? extName(stripGz(fileName)) : '')
const radioOption = value || (fileName ? extName(stripGz(fileName)) : '')

useEffect(() => {
try {
if (fileLocation) {
const fn = fileName ? basename(fileName) : 'MyTrack'
const trackId = `${fn}-${Date.now()}`
setError(undefined)
useEffect(() => {
try {
if (fileLocation) {
const fn = fileName ? basename(fileName) : 'MyTrack'
const trackId = `${fn}-${Date.now()}`
setError(undefined)

setSessionTrackData({
trackId,
name: fn,
assemblyNames: [assembly2, assembly1],
type: 'SyntenyTrack',
adapter: getAdapter({
radioOption,
assembly1,
assembly2,
fileLocation,
bed1Location,
bed2Location,
}),
})
}
} catch (e) {
console.error(e)
setError(e)
setSessionTrackData({
trackId,
name: fn,
assemblyNames: [assembly2, assembly1],
type: 'SyntenyTrack',
adapter: getAdapter({
radioOption,
assembly1,
assembly2,
fileLocation,
indexFileLocation,
bed1Location,
bed2Location,
}),
})
}
}, [
fileName,
assembly1,
assembly2,
bed1Location,
bed2Location,
fileLocation,
radioOption,
setSessionTrackData,
])
return (
<Paper style={{ padding: 12 }}>
{error ? <ErrorMessage error={error} /> : null}
<Typography style={{ textAlign: 'center' }}>
Add a .paf, .out (MashMap), .delta (Mummer), .chain, .anchors or
.anchors.simple (MCScan) file to view in the dotplot. These file types
can also be gzipped. The first assembly should be the query sequence
(e.g. left column of the PAF) and the second assembly should be the
target sequence (e.g. right column of the PAF)
</Typography>
<RadioGroup
value={radioOption}
onChange={event => {
setValue(event.target.value)
}}
>
<Grid container justifyContent="center">
<Grid item>
<FormControlLabel value=".paf" control={<Radio />} label=".paf" />
</Grid>
<Grid item>
<FormControlLabel value=".out" control={<Radio />} label=".out" />
</Grid>
<Grid item>
<FormControlLabel
value=".delta"
control={<Radio />}
label=".delta"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".chain"
control={<Radio />}
label=".chain"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".anchors"
control={<Radio />}
label=".anchors"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".anchors.simple"
control={<Radio />}
label=".anchors.simple"
/>
</Grid>
</Grid>
</RadioGroup>
} catch (e) {
console.error(e)
setError(e)
}
}, [
fileName,
assembly1,
assembly2,
bed1Location,
bed2Location,
fileLocation,
indexFileLocation,
radioOption,
setSessionTrackData,
])
return (
<Paper style={{ padding: 12 }}>
{error ? <ErrorMessage error={error} /> : null}
<Typography style={{ textAlign: 'center' }}>
Add a .paf, .out (MashMap), .delta (Mummer), .chain, .anchors or
.anchors.simple (MCScan) file to view. These file types can also be
gzipped. The first assembly should be the query sequence (e.g. left
column of the PAF) and the second assembly should be the target sequence
(e.g. right column of the PAF)
</Typography>
<RadioGroup
value={radioOption}
onChange={event => {
setValue(event.target.value)
}}
>
<Grid container justifyContent="center">
<Grid item>
{value === '.anchors' || value === '.anchors.simple' ? (
<div>
<div style={{ margin: 20 }}>
Open the {value} and .bed files for both genome assemblies
from the MCScan (Python version) pipeline{' '}
<a href="https://github.com/tanghaibao/jcvi/wiki/MCscan-(Python-version)">
(more info)
</a>
<FormControlLabel value=".paf" control={<Radio />} label=".paf" />
</Grid>
<Grid item>
<FormControlLabel value=".out" control={<Radio />} label=".out" />
</Grid>

<Grid item>
<FormControlLabel
value=".delta"
control={<Radio />}
label=".delta"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".chain"
control={<Radio />}
label=".chain"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".anchors"
control={<Radio />}
label=".anchors"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".anchors.simple"
control={<Radio />}
label=".anchors.simple"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".pif.gz"
control={<Radio />}
label=".pif.gz"
/>
</Grid>
</Grid>
</RadioGroup>
<Grid container justifyContent="center">
<Grid item>
{value === '.anchors' || value === '.anchors.simple' ? (
<div>
<div style={{ margin: 20 }}>
Open the {value} and .bed files for both genome assemblies from
the MCScan (Python version) pipeline{' '}
<a href="https://github.com/tanghaibao/jcvi/wiki/MCscan-(Python-version)">
(more info)
</a>
</div>
<div style={{ display: 'flex' }}>
<div>
<FileSelector
name=".anchors file"
description=""
location={fileLocation}
setLocation={loc => {
setFileLocation(loc)
}}
/>
</div>
<div style={{ display: 'flex' }}>
<div>
<FileSelector
name=".anchors file"
description=""
location={fileLocation}
setLocation={loc => {
setFileLocation(loc)
}}
/>
</div>
<div>
<FileSelector
name="genome 1 .bed (left column of anchors file)"
description=""
location={bed1Location}
setLocation={loc => {
setBed1Location(loc)
}}
/>
</div>
<div>
<FileSelector
name="genome 2 .bed (right column of anchors file)"
description=""
location={bed2Location}
setLocation={loc => {
setBed2Location(loc)
}}
/>
</div>
<div>
<FileSelector
name="genome 1 .bed (left column of anchors file)"
description=""
location={bed1Location}
setLocation={loc => {
setBed1Location(loc)
}}
/>
</div>
<div>
<FileSelector
name="genome 2 .bed (right column of anchors file)"
description=""
location={bed2Location}
setLocation={loc => {
setBed2Location(loc)
}}
/>
</div>
</div>
) : (
<FileSelector
name={value ? `${value} location` : ''}
description=""
location={fileLocation}
setLocation={loc => {
setFileLocation(loc)
}}
/>
)}
</Grid>
</div>
) : value === '.pif.gz' ? (
<div style={{ display: 'flex' }}>
<div>
<FileSelector
name={`${value} location`}
description=""
location={fileLocation}
setLocation={loc => {
setFileLocation(loc)
}}
/>
</div>
<div>
<FileSelector
name={`${value} index location`}
description=""
location={indexFileLocation}
setLocation={loc => {
setIndexFileLocation(loc)
}}
/>
</div>
</div>
) : (
<FileSelector
name={value ? `${value} location` : ''}
description=""
location={fileLocation}
setLocation={loc => {
setFileLocation(loc)
}}
/>
)}
</Grid>
</Paper>
)
},
)
</Grid>
</Paper>
)
})

export default OpenTrack
export default ImportCustomTrack
Loading