@jbrowse/plugin-bed 1.4.3 → 1.5.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ export default ConfigurationSchema(
5
5
  {
6
6
  bigBedLocation: {
7
7
  type: 'fileLocation',
8
- defaultValue: { uri: '/path/to/my.bb' },
8
+ defaultValue: { uri: '/path/to/my.bb', locationType: 'UriLocation' },
9
9
  },
10
10
  },
11
11
  { explicitlyTyped: true },
package/src/index.ts CHANGED
@@ -3,6 +3,13 @@ import Plugin from '@jbrowse/core/Plugin'
3
3
  import PluginManager from '@jbrowse/core/PluginManager'
4
4
  import { configSchema as bigBedAdapterConfigSchema } from './BigBedAdapter'
5
5
  import { configSchema as bedTabixAdapterConfigSchema } from './BedTabixAdapter'
6
+ import { FileLocation } from '@jbrowse/core/util/types'
7
+ import {
8
+ makeIndex,
9
+ makeIndexType,
10
+ AdapterGuesser,
11
+ getFileName,
12
+ } from '@jbrowse/core/util/tracks'
6
13
 
7
14
  export default class BedPlugin extends Plugin {
8
15
  name = 'BedPlugin'
@@ -17,6 +24,28 @@ export default class BedPlugin extends Plugin {
17
24
  import('./BigBedAdapter/BigBedAdapter').then(r => r.default),
18
25
  }),
19
26
  )
27
+ pluginManager.addToExtensionPoint(
28
+ 'Core-guessAdapterForLocation',
29
+ (adapterGuesser: AdapterGuesser) => {
30
+ return (
31
+ file: FileLocation,
32
+ index?: FileLocation,
33
+ adapterHint?: string,
34
+ ) => {
35
+ const regexGuess = /\.(bb|bigbed)$/i
36
+ const adapterName = 'BigBedAdapter'
37
+ const fileName = getFileName(file)
38
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
39
+ return {
40
+ type: adapterName,
41
+ bigBedLocation: file,
42
+ }
43
+ }
44
+ return adapterGuesser(file, index, adapterHint)
45
+ }
46
+ },
47
+ )
48
+
20
49
  pluginManager.addAdapterType(
21
50
  () =>
22
51
  new AdapterType({
@@ -26,5 +55,31 @@ export default class BedPlugin extends Plugin {
26
55
  import('./BedTabixAdapter/BedTabixAdapter').then(r => r.default),
27
56
  }),
28
57
  )
58
+ pluginManager.addToExtensionPoint(
59
+ 'Core-guessAdapterForLocation',
60
+ (adapterGuesser: AdapterGuesser) => {
61
+ return (
62
+ file: FileLocation,
63
+ index?: FileLocation,
64
+ adapterHint?: string,
65
+ ) => {
66
+ const regexGuess = /\.bed\.b?gz$/i
67
+ const adapterName = 'BedTabixAdapter'
68
+ const fileName = getFileName(file)
69
+ const indexName = index && getFileName(index)
70
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
71
+ return {
72
+ type: adapterName,
73
+ bedGzLocation: file,
74
+ index: {
75
+ location: index || makeIndex(file, '.tbi'),
76
+ indexType: makeIndexType(indexName, 'CSI', 'TBI'),
77
+ },
78
+ }
79
+ }
80
+ return adapterGuesser(file, index, adapterHint)
81
+ }
82
+ },
83
+ )
29
84
  }
30
85
  }