diff --git a/products/jbrowse-cli/src/commands/add-track.test.ts b/products/jbrowse-cli/src/commands/add-track.test.ts index 1587e32f99..afc257d506 100644 --- a/products/jbrowse-cli/src/commands/add-track.test.ts +++ b/products/jbrowse-cli/src/commands/add-track.test.ts @@ -15,6 +15,7 @@ const base = path.join(__dirname, '..', '..', 'test', 'data') const simpleBam = path.join(base, 'simple.bam') const simpleBai = path.join(base, 'simple.bai') const simpleGff = path.join(base, 'volvox.sort.gff3') +const simpleBed = path.join(base, 'volvox.bed') const simplePaf = path.join(base, 'volvox_inv_indels.paf') const simplePafGz = path.join(base, 'volvox_inv_indels.paf.gz') const simpleDelta = path.join(base, 'volvox_inv_indels.delta') @@ -894,4 +895,26 @@ describe('add-track', () => { }, ]) }) + + setup + .do(initctx) + .command(['add-track', simpleBed, '--load', 'copy']) + .it('adds a bed track', async ctx => { + expect(exists(ctxDir(ctx, 'volvox.bed'))).toBeTruthy() + expect(readConf(ctx).tracks).toEqual([ + { + type: 'FeatureTrack', + trackId: 'volvox', + name: 'volvox', + assemblyNames: ['testAssembly'], + adapter: { + type: 'BedAdapter', + bedLocation: { + uri: 'volvox.bed', + locationType: 'UriLocation', + }, + }, + }, + ]) + }) }) diff --git a/products/jbrowse-cli/src/commands/add-track.ts b/products/jbrowse-cli/src/commands/add-track.ts index f3bf4a107a..7381516bdc 100644 --- a/products/jbrowse-cli/src/commands/add-track.ts +++ b/products/jbrowse-cli/src/commands/add-track.ts @@ -381,27 +381,20 @@ export default class AddTrack extends JBrowseCommand { if (/\.anchors(.simple)?$/i.test(location)) { return { file: location, - bed1: bed1!, - bed2: bed2!, } - } - if (/\.bam$/i.test(location)) { + } else if (/\.bam$/i.test(location)) { return { file: location, index: index || `${location}.bai`, } - } - - if (/\.cram$/i.test(location)) { + } else if (/\.cram$/i.test(location)) { return { file: location, index: index || `${location}.crai`, } - } - - if ( + } else if ( /\.gff3?\.b?gz$/i.test(location) || /\.vcf\.b?gz$/i.test(location) || /\.bed\.b?gz$/i.test(location) @@ -410,30 +403,25 @@ export default class AddTrack extends JBrowseCommand { file: location, index: index || `${location}.tbi`, } - } - - if (/\.(fa|fasta|fas|fna|mfa)$/i.test(location)) { + } else if (/\.(fa|fasta|fas|fna|mfa)$/i.test(location)) { return { file: location, index: index || `${location}.fai`, } - } - - if (/\.(fa|fasta|fas|fna|mfa)\.b?gz$/i.test(location)) { + } else if (/\.(fa|fasta|fas|fna|mfa)\.b?gz$/i.test(location)) { return { file: location, index: `${location}.fai`, index2: `${location}.gzi`, } - } - - if ( + } else if ( /\.2bit$/i.test(location) || /\/trackData.jsonz?$/i.test(location) || /\/sparql$/i.test(location) || /\.out(.gz)?$/i.test(location) || /\.paf(.gz)?$/i.test(location) || /\.delta(.gz)?$/i.test(location) || + /\.bed?$/i.test(location) || /\.(bw|bigwig)$/i.test(location) || /\.(bb|bigbed)$/i.test(location) || /\.vcf$/i.test(location) || @@ -473,24 +461,18 @@ export default class AddTrack extends JBrowseCommand { indexType: index?.toUpperCase().endsWith('CSI') ? 'CSI' : 'BAI', }, } - } - - if (/\.cram$/i.test(location)) { + } else if (/\.cram$/i.test(location)) { return { type: 'CramAdapter', cramLocation: makeLocation(location), craiLocation: makeLocation(`${location}.crai`), } - } - - if (/\.gff3?$/i.test(location)) { + } else if (/\.gff3?$/i.test(location)) { return { type: 'Gff3Adapter', gffLocation: makeLocation(location), } - } - - if (/\.gff3?\.b?gz$/i.test(location)) { + } else if (/\.gff3?\.b?gz$/i.test(location)) { return { type: 'Gff3TabixAdapter', gffGzLocation: makeLocation(location), @@ -499,23 +481,17 @@ export default class AddTrack extends JBrowseCommand { indexType: index?.toUpperCase().endsWith('CSI') ? 'CSI' : 'TBI', }, } - } - - if (/\.gtf?$/i.test(location)) { + } else if (/\.gtf?$/i.test(location)) { return { type: 'GtfAdapter', gtfLocation: makeLocation(location), } - } - - if (/\.vcf$/i.test(location)) { + } else if (/\.vcf$/i.test(location)) { return { type: 'VcfAdapter', vcfLocation: makeLocation(location), } - } - - if (/\.vcf\.b?gz$/i.test(location)) { + } else if (/\.vcf\.b?gz$/i.test(location)) { return { type: 'VcfTabixAdapter', vcfGzLocation: makeLocation(location), @@ -524,21 +500,16 @@ export default class AddTrack extends JBrowseCommand { indexType: index?.toUpperCase().endsWith('CSI') ? 'CSI' : 'TBI', }, } - } - - if (/\.vcf\.idx$/i.test(location)) { + } else if (/\.vcf\.idx$/i.test(location)) { return { type: 'UNSUPPORTED', } - } - - if (/\.bed$/i.test(location)) { + } else if (/\.bed$/i.test(location)) { return { - type: 'UNSUPPORTED', + type: 'BedAdapter', + bedLocation: makeLocation(location), } - } - - if (/\.bed\.b?gz$/i.test(location)) { + } else if (/\.bed\.b?gz$/i.test(location)) { return { type: 'BedTabixAdapter', bedGzLocation: makeLocation(location), @@ -547,116 +518,81 @@ export default class AddTrack extends JBrowseCommand { indexType: index?.toUpperCase().endsWith('CSI') ? 'CSI' : 'TBI', }, } - } - - if (/\.bed$/i.test(location)) { - return { - type: 'BedAdapter', - bedLocation: makeLocation(location), - } - } - - if (/\.(bb|bigbed)$/i.test(location)) { + } else if (/\.(bb|bigbed)$/i.test(location)) { return { type: 'BigBedAdapter', bigBedLocation: makeLocation(location), } - } - - if (/\.(bw|bigwig)$/i.test(location)) { + } else if (/\.(bw|bigwig)$/i.test(location)) { return { type: 'BigWigAdapter', bigWigLocation: makeLocation(location), } - } - - if (/\.(fa|fasta|fna|mfa)$/i.test(location)) { + } else if (/\.(fa|fasta|fna|mfa)$/i.test(location)) { return { type: 'IndexedFastaAdapter', fastaLocation: makeLocation(location), faiLocation: makeLocation(index || `${location}.fai`), } - } - - if (/\.(fa|fasta|fna|mfa)\.b?gz$/i.test(location)) { + } else if (/\.(fa|fasta|fna|mfa)\.b?gz$/i.test(location)) { return { type: 'BgzipFastaAdapter', fastaLocation: makeLocation(location), faiLocation: makeLocation(`${location}.fai`), gziLocation: makeLocation(`${location}.gzi`), } - } - - if (/\.2bit$/i.test(location)) { + } else if (/\.2bit$/i.test(location)) { return { type: 'TwoBitAdapter', twoBitLocation: makeLocation(location), } - } - - if (/\.sizes$/i.test(location)) { + } else if (/\.sizes$/i.test(location)) { return { type: 'UNSUPPORTED', } - } - - if (/\/trackData.jsonz?$/i.test(location)) { + } else if (/\/trackData.jsonz?$/i.test(location)) { return { type: 'NCListAdapter', rootUrlTemplate: makeLocation(location), } - } - - if (/\/sparql$/i.test(location)) { + } else if (/\/sparql$/i.test(location)) { return { type: 'SPARQLAdapter', endpoint: location, } - } - - if (/\.hic$/i.test(location)) { + } else if (/\.hic$/i.test(location)) { return { type: 'HicAdapter', hicLocation: makeLocation(location), } - } - - if (/\.paf(.gz)?$/i.test(location)) { + } else if (/\.paf(.gz)?$/i.test(location)) { return { type: 'PAFAdapter', pafLocation: makeLocation(location), } - } - - if (/\.out(.gz)?$/i.test(location)) { + } else if (/\.out(.gz)?$/i.test(location)) { return { type: 'MashMapAdapter', outLocation: makeLocation(location), } - } - if (/\.chain(.gz)?$/i.test(location)) { + } else if (/\.chain(.gz)?$/i.test(location)) { return { type: 'ChainAdapter', chainLocation: makeLocation(location), } - } - if (/\.delta(.gz)?$/i.test(location)) { + } else if (/\.delta(.gz)?$/i.test(location)) { return { type: 'DeltaAdapter', deltaLocation: makeLocation(location), } - } - - if (/\.anchors(.gz)?$/i.test(location)) { + } else if (/\.anchors(.gz)?$/i.test(location)) { return { type: 'MCScanAnchorsAdapter', mcscanAnchorsLocation: makeLocation(location), bed1Location: bed1 ? makeLocation(bed1) : undefined, bed2Location: bed2 ? makeLocation(bed2) : undefined, } - } - - if (/\.anchors.simple(.gz)?$/i.test(location)) { + } else if (/\.anchors.simple(.gz)?$/i.test(location)) { return { type: 'MCScanSimpleAnchorsAdapter', mcscanSimpleAnchorsLocation: makeLocation(location), @@ -680,6 +616,7 @@ export default class AddTrack extends JBrowseCommand { TwoBitAdapter: 'ReferenceSequenceTrack', VcfTabixAdapter: 'VariantTrack', VcfAdapter: 'VariantTrack', + BedAdapter: 'FeatureTrack', HicAdapter: 'HicTrack', PAFAdapter: 'SyntenyTrack', DeltaAdapter: 'SyntenyTrack', diff --git a/products/jbrowse-cli/test/data/volvox.bed b/products/jbrowse-cli/test/data/volvox.bed new file mode 100644 index 0000000000..7744c32757 --- /dev/null +++ b/products/jbrowse-cli/test/data/volvox.bed @@ -0,0 +1,242 @@ +ctgA 1 50001 +ctgA 1000 20000 +ctgA 1000 1000 +ctgA 1000 1500 +ctgA 1000 2000 +ctgA 1050 3202 +ctgA 1050 7300 +ctgA 1050 1500 +ctgA 1050 1500 +ctgA 1050 9000 +ctgA 1050 9000 +ctgA 1050 9000 +ctgA 1050 1200 +ctgA 1050 1200 +ctgA 1100 2000 +ctgA 1150 7200 +ctgA 1150 1500 +ctgA 1200 1900 +ctgA 1201 1500 +ctgA 1201 1500 +ctgA 1300 9000 +ctgA 1300 1500 +ctgA 1600 3000 +ctgA 1659 1984 +ctgA 1800 2900 +ctgA 3000 3202 +ctgA 3000 3902 +ctgA 3000 3300 +ctgA 3014 6130 +ctgA 3301 3902 +ctgA 4715 5968 +ctgA 5000 5500 +ctgA 5000 5500 +ctgA 5000 5500 +ctgA 5000 5500 +ctgA 5000 5500 +ctgA 5233 5302 +ctgA 5410 7503 +ctgA 5410 5500 +ctgA 5800 6101 +ctgA 6442 6854 +ctgA 6885 7241 +ctgA 7000 7200 +ctgA 7000 7300 +ctgA 7000 7503 +ctgA 7000 7600 +ctgA 7000 7608 +ctgA 7000 7608 +ctgA 7106 7211 +ctgA 7410 7737 +ctgA 7500 8000 +ctgA 7601 9000 +ctgA 7609 9000 +ctgA 7609 9000 +ctgA 7695 8177 +ctgA 8000 9000 +ctgA 8055 8080 +ctgA 8306 8999 +ctgA 8545 8783 +ctgA 8869 8935 +ctgA 9404 9825 +ctgA 10000 11500 +ctgA 11911 15561 +ctgA 12531 12895 +ctgA 13000 17200 +ctgA 13122 13449 +ctgA 13280 16394 +ctgA 13452 13745 +ctgA 13500 13800 +ctgA 13801 14007 +ctgA 13908 13965 +ctgA 13998 14488 +ctgA 14564 14899 +ctgA 14731 17239 +ctgA 15000 15500 +ctgA 15185 15276 +ctgA 15329 15533 +ctgA 15396 16159 +ctgA 15639 15736 +ctgA 15745 15870 +ctgA 16500 17000 +ctgA 17023 17675 +ctgA 17400 23000 +ctgA 17400 17999 +ctgA 17667 17690 +ctgA 18000 18800 +ctgA 18048 18552 +ctgA 18509 18985 +ctgA 18989 19388 +ctgA 19000 19500 +ctgA 19157 22915 +ctgA 19249 19559 +ctgA 19496 19962 +ctgA 19500 20000 +ctgA 19975 20260 +ctgA 20093 20580 +ctgA 20379 20491 +ctgA 20533 21005 +ctgA 20970 21052 +ctgA 21000 21200 +ctgA 21122 21331 +ctgA 21201 23000 +ctgA 21270 21277 +ctgA 21682 22176 +ctgA 21685 22168 +ctgA 21748 25612 +ctgA 22132 24633 +ctgA 22374 22570 +ctgA 22564 22869 +ctgA 22958 23298 +ctgA 23025 23427 +ctgA 23072 23185 +ctgA 23412 23469 +ctgA 23932 23932 +ctgA 24228 24510 +ctgA 24328 24787 +ctgA 24562 28338 +ctgA 24868 25012 +ctgA 25212 25426 +ctgA 25228 25367 +ctgA 25794 25874 +ctgA 26075 26519 +ctgA 26122 26126 +ctgA 26497 26869 +ctgA 26503 26799 +ctgA 26930 26940 +ctgA 26975 27063 +ctgA 27172 27185 +ctgA 27201 27325 +ctgA 27372 27433 +ctgA 27415 27799 +ctgA 27448 27860 +ctgA 27565 27565 +ctgA 27813 28091 +ctgA 27880 27943 +ctgA 27887 28076 +ctgA 28093 28201 +ctgA 28225 28316 +ctgA 28225 28346 +ctgA 28329 28377 +ctgA 28332 30033 +ctgA 28342 28447 +ctgA 28375 28570 +ctgA 28758 29041 +ctgA 28777 29058 +ctgA 28829 29194 +ctgA 29101 29302 +ctgA 29513 29647 +ctgA 29517 29702 +ctgA 29604 29702 +ctgA 29713 30061 +ctgA 29771 29942 +ctgA 29867 29885 +ctgA 30042 30340 +ctgA 30108 30216 +ctgA 30241 30246 +ctgA 30329 30774 +ctgA 30465 30798 +ctgA 30575 30738 +ctgA 30578 31748 +ctgA 30808 31306 +ctgA 30810 31307 +ctgA 31232 31236 +ctgA 31421 31817 +ctgA 31516 31729 +ctgA 31753 32154 +ctgA 31761 31984 +ctgA 32010 32057 +ctgA 32208 32680 +ctgA 32329 32359 +ctgA 32374 32937 +ctgA 32595 32696 +ctgA 32892 32901 +ctgA 33053 33325 +ctgA 33127 33388 +ctgA 33325 35791 +ctgA 33438 33868 +ctgA 33439 33443 +ctgA 33759 34209 +ctgA 34244 34313 +ctgA 34401 34466 +ctgA 34605 34983 +ctgA 35333 35507 +ctgA 35642 35904 +ctgA 36034 38167 +ctgA 36616 37057 +ctgA 36649 40440 +ctgA 37208 37227 +ctgA 37242 38653 +ctgA 37497 40559 +ctgA 39265 39361 +ctgA 39753 40034 +ctgA 40515 40954 +ctgA 41137 41318 +ctgA 41252 41365 +ctgA 41492 41504 +ctgA 41754 41948 +ctgA 41941 42377 +ctgA 42057 42474 +ctgA 42748 42954 +ctgA 42890 43270 +ctgA 43395 43811 +ctgA 43401 43897 +ctgA 44043 44113 +ctgA 44065 44556 +ctgA 44191 44514 +ctgA 44399 44888 +ctgA 44552 45043 +ctgA 44705 47713 +ctgA 44763 45030 +ctgA 45231 45488 +ctgA 45281 45375 +ctgA 45373 45600 +ctgA 45711 46041 +ctgA 45790 46022 +ctgA 45897 46315 +ctgA 46012 48851 +ctgA 46092 46318 +ctgA 46425 46564 +ctgA 46491 46890 +ctgA 46738 47087 +ctgA 46816 46992 +ctgA 46990 48410 +ctgA 47126 47297 +ctgA 47329 47595 +ctgA 47449 47829 +ctgA 47735 47983 +ctgA 47858 47979 +ctgA 48169 48453 +ctgA 48253 48366 +ctgA 48447 48709 +ctgA 48931 49186 +ctgA 49406 49476 +ctgA 49472 49699 +ctgA 49758 50000 +ctgA 49762 50000 +ctgA 49957 50000 +ctgA 49957 50000 +ctgB 1 6079 +ctgB 1659 1984 +ctgB 3014 6130 +ctgB 4715 5968