Skip to content

Commit

Permalink
Add pif.gz option to synteny import form
Browse files Browse the repository at this point in the history
  • Loading branch information
cmdcolin committed Sep 18, 2024
1 parent 028d7d0 commit 9741e2f
Show file tree
Hide file tree
Showing 3 changed files with 203 additions and 104 deletions.
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 @@ -96,6 +105,7 @@ const OpenTrack = observer(
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)
Expand All @@ -119,6 +129,7 @@ const OpenTrack = observer(
assembly1,
assembly2,
fileLocation,
indexFileLocation,
bed1Location,
bed2Location,
}),
Expand All @@ -135,6 +146,7 @@ const OpenTrack = observer(
bed1Location,
bed2Location,
fileLocation,
indexFileLocation,
radioOption,
setSessionTrackData,
])
Expand All @@ -143,10 +155,10 @@ const OpenTrack = observer(
{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)
.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}
Expand All @@ -161,6 +173,7 @@ const OpenTrack = observer(
<Grid item>
<FormControlLabel value=".out" control={<Radio />} label=".out" />
</Grid>

<Grid item>
<FormControlLabel
value=".delta"
Expand Down Expand Up @@ -189,6 +202,13 @@ const OpenTrack = observer(
label=".anchors.simple"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".pif.gz"
control={<Radio />}
label=".pif.gz"
/>
</Grid>
</Grid>
</RadioGroup>
<Grid container justifyContent="center">
Expand Down Expand Up @@ -235,6 +255,29 @@ const OpenTrack = observer(
</div>
</div>
</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` : ''}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@ import { ErrorMessage, FileSelector } from '@jbrowse/core/ui'
import { FileLocation } from '@jbrowse/core/util/types'
import { observer } from 'mobx-react'
import { AnyConfigurationModel } from '@jbrowse/core/configuration'
import { extName, getName, stripGz, basename } from './util'
import { basename, extName, getName, stripGz } from './util'

function getAdapter({
radioOption,
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 @@ -96,6 +105,7 @@ const OpenTrack = observer(
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)
Expand All @@ -119,6 +129,7 @@ const OpenTrack = observer(
assembly1,
assembly2,
fileLocation,
indexFileLocation,
bed1Location,
bed2Location,
}),
Expand All @@ -135,6 +146,7 @@ const OpenTrack = observer(
bed1Location,
bed2Location,
fileLocation,
indexFileLocation,
radioOption,
setSessionTrackData,
])
Expand All @@ -143,10 +155,10 @@ const OpenTrack = observer(
{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)
.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}
Expand All @@ -161,6 +173,7 @@ const OpenTrack = observer(
<Grid item>
<FormControlLabel value=".out" control={<Radio />} label=".out" />
</Grid>

<Grid item>
<FormControlLabel
value=".delta"
Expand Down Expand Up @@ -189,6 +202,13 @@ const OpenTrack = observer(
label=".anchors.simple"
/>
</Grid>
<Grid item>
<FormControlLabel
value=".pif.gz"
control={<Radio />}
label=".pif.gz"
/>
</Grid>
</Grid>
</RadioGroup>
<Grid container justifyContent="center">
Expand Down Expand Up @@ -235,6 +255,29 @@ const OpenTrack = observer(
</div>
</div>
</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` : ''}
Expand Down
Loading

0 comments on commit 9741e2f

Please sign in to comment.