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

Fix adapterType dropdown in add track widget #2688

Merged
merged 1 commit into from
Jan 28, 2022
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
5 changes: 1 addition & 4 deletions packages/core/util/tracks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,7 @@ export function guessAdapter(
model?: IAnyStateTreeNode,
) {
if (model) {
// @ts-ignore
const session = getSession(model)

const adapterGuesser = getEnv(session).pluginManager.evaluateExtensionPoint(
const adapterGuesser = getEnv(model).pluginManager.evaluateExtensionPoint(
'Core-guessAdapterForLocation',
(
_file: FileLocation,
Expand Down
37 changes: 22 additions & 15 deletions plugins/alignments/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,15 @@ export default class AlignmentsPlugin extends Plugin {
const regexGuess = /\.cram$/i
const adapterName = 'CramAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
cramLocation: file,
craiLocation: index || makeIndex(file, '.crai'),
}
const obj = {
type: adapterName,
cramLocation: file,
craiLocation: index || makeIndex(file, '.crai'),
}
if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand All @@ -84,15 +87,19 @@ export default class AlignmentsPlugin extends Plugin {
const adapterName = 'BamAdapter'
const fileName = getFileName(file)
const indexName = index && getFileName(index)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
bamLocation: file,
index: {
location: index || makeIndex(file, '.bai'),
indexType: makeIndexType(indexName, 'CSI', 'BAI'),
},
}

const obj = {
type: adapterName,
bamLocation: file,
index: {
location: index || makeIndex(file, '.bai'),
indexType: makeIndexType(indexName, 'CSI', 'BAI'),
},
}
if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
14 changes: 9 additions & 5 deletions plugins/bed/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@ export default class BedPlugin extends Plugin {
const regexGuess = /\.(bb|bigbed)$/i
const adapterName = 'BigBedAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
bigBedLocation: file,
}
const obj = {
type: adapterName,
bigBedLocation: file,
}

if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,9 @@ const TrackAdapterSelector = observer(({ model }: { model: AddTrackModel }) => {
helperText="Select an adapter type"
select
fullWidth
onChange={event => model.setAdapterHint(event.target.value)}
onChange={event => {
model.setAdapterHint(event.target.value)
}}
SelectProps={{
// @ts-ignore
SelectDisplayProps: { 'data-testid': 'adapterTypeSelect' },
Expand Down
13 changes: 8 additions & 5 deletions plugins/gff3/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ export default class extends Plugin {
const regexGuess = /\.gff3?$/i
const adapterName = 'Gff3Adapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
gffLocation: file,
}
const obj = {
type: adapterName,
gffLocation: file,
}
if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
14 changes: 9 additions & 5 deletions plugins/gtf/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,15 @@ export default class GtfPlugin extends Plugin {
const regexGuess = /\.gtf(\.gz)?$/i
const adapterName = 'GtfAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
gtfLocation: file,
}

const obj = {
type: adapterName,
gtfLocation: file,
}
if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
14 changes: 9 additions & 5 deletions plugins/hic/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ export default class HicPlugin extends Plugin {
const regexGuess = /\.hic/i
const adapterName = 'HicAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
hicLocation: file,
}
const obj = {
type: adapterName,
hicLocation: file,
}

if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
45 changes: 28 additions & 17 deletions plugins/sequence/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ export default class SequencePlugin extends Plugin {
const regexGuess = /\.2bit$/i
const adapterName = 'TwoBitAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
twoBitLocation: file,
}
const obj = {
type: adapterName,
twoBitLocation: file,
}
if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down Expand Up @@ -139,12 +142,16 @@ export default class SequencePlugin extends Plugin {
const regexGuess = /\.(fa|fasta|fas|fna|mfa)$/i
const adapterName = 'IndexedFastaAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
fastaLocation: file,
faiLocation: index || makeIndex(file, '.fai'),
}
const obj = {
type: adapterName,
fastaLocation: file,
faiLocation: index || makeIndex(file, '.fai'),
}

if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down Expand Up @@ -191,12 +198,16 @@ export default class SequencePlugin extends Plugin {
const regexGuess = /\.(fa|fasta|fas|fna|mfa)\.b?gz$/i
const adapterName = 'BgzipFastaAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
faiLocation: makeIndex(file, '.fai'),
gziLocation: makeIndex(file, '.gzi'),
}
const obj = {
type: adapterName,
faiLocation: makeIndex(file, '.fai'),
gziLocation: makeIndex(file, '.gzi'),
}

if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
21 changes: 12 additions & 9 deletions plugins/variants/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,18 @@ export default class VariantsPlugin extends Plugin {
const adapterName = 'VcfTabixAdapter'
const fileName = getFileName(file)
const indexName = index && getFileName(index)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
vcfGzLocation: file,
index: {
location: index || makeIndex(file, '.tbi'),
indexType: makeIndexType(indexName, 'CSI', 'TBI'),
},
}
const obj = {
type: adapterName,
vcfGzLocation: file,
index: {
location: index || makeIndex(file, '.tbi'),
indexType: makeIndexType(indexName, 'CSI', 'TBI'),
},
}
if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}
return adapterGuesser(file, index, adapterHint)
}
Expand Down
15 changes: 10 additions & 5 deletions plugins/wiggle/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,12 +103,17 @@ export default class WigglePlugin extends Plugin {
const regexGuess = /\.(bw|bigwig)$/i
const adapterName = 'BigWigAdapter'
const fileName = getFileName(file)
if (regexGuess.test(fileName) || adapterHint === adapterName) {
return {
type: adapterName,
bigWigLocation: file,
}
const obj = {
type: adapterName,
bigWigLocation: file,
}

if (regexGuess.test(fileName) && !adapterHint) {
return obj
} else if (adapterHint === adapterName) {
return obj
}

return adapterGuesser(file, index, adapterHint)
}
},
Expand Down