@jbrowse/plugin-bed 1.7.10 → 2.0.1

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.
Files changed (78) hide show
  1. package/dist/BedAdapter/BedAdapter.d.ts +29 -0
  2. package/dist/BedAdapter/BedAdapter.js +273 -0
  3. package/dist/BedAdapter/BedAdapter.js.map +1 -0
  4. package/dist/BedAdapter/configSchema.d.ts +2 -0
  5. package/dist/BedAdapter/configSchema.js +40 -0
  6. package/dist/BedAdapter/configSchema.js.map +1 -0
  7. package/dist/BedAdapter/index.d.ts +1 -0
  8. package/dist/BedAdapter/index.js +9 -0
  9. package/dist/BedAdapter/index.js.map +1 -0
  10. package/dist/BedTabixAdapter/BedTabixAdapter.d.ts +3 -7
  11. package/dist/BedTabixAdapter/BedTabixAdapter.js +154 -289
  12. package/dist/BedTabixAdapter/BedTabixAdapter.js.map +1 -0
  13. package/dist/BedTabixAdapter/configSchema.js +38 -51
  14. package/dist/BedTabixAdapter/configSchema.js.map +1 -0
  15. package/dist/BedTabixAdapter/index.js +8 -14
  16. package/dist/BedTabixAdapter/index.js.map +1 -0
  17. package/dist/BigBedAdapter/BigBedAdapter.js +228 -335
  18. package/dist/BigBedAdapter/BigBedAdapter.js.map +1 -0
  19. package/dist/BigBedAdapter/configSchema.js +9 -21
  20. package/dist/BigBedAdapter/configSchema.js.map +1 -0
  21. package/dist/BigBedAdapter/index.js +8 -14
  22. package/dist/BigBedAdapter/index.js.map +1 -0
  23. package/dist/index.js +132 -129
  24. package/dist/index.js.map +1 -0
  25. package/dist/util.d.ts +3 -1
  26. package/dist/util.js +161 -121
  27. package/dist/util.js.map +1 -0
  28. package/esm/BedAdapter/BedAdapter.d.ts +29 -0
  29. package/esm/BedAdapter/BedAdapter.js +130 -0
  30. package/esm/BedAdapter/BedAdapter.js.map +1 -0
  31. package/esm/BedAdapter/configSchema.d.ts +2 -0
  32. package/esm/BedAdapter/configSchema.js +38 -0
  33. package/esm/BedAdapter/configSchema.js.map +1 -0
  34. package/esm/BedAdapter/index.d.ts +1 -0
  35. package/esm/BedAdapter/index.js +2 -0
  36. package/esm/BedAdapter/index.js.map +1 -0
  37. package/esm/BedTabixAdapter/BedTabixAdapter.d.ts +19 -0
  38. package/esm/BedTabixAdapter/BedTabixAdapter.js +69 -0
  39. package/esm/BedTabixAdapter/BedTabixAdapter.js.map +1 -0
  40. package/esm/BedTabixAdapter/configSchema.d.ts +2 -0
  41. package/esm/BedTabixAdapter/configSchema.js +38 -0
  42. package/esm/BedTabixAdapter/configSchema.js.map +1 -0
  43. package/esm/BedTabixAdapter/index.d.ts +1 -0
  44. package/esm/BedTabixAdapter/index.js +2 -0
  45. package/esm/BedTabixAdapter/index.js.map +1 -0
  46. package/esm/BigBedAdapter/BigBedAdapter.d.ts +46 -0
  47. package/esm/BigBedAdapter/BigBedAdapter.js +104 -0
  48. package/esm/BigBedAdapter/BigBedAdapter.js.map +1 -0
  49. package/esm/BigBedAdapter/configSchema.d.ts +2 -0
  50. package/esm/BigBedAdapter/configSchema.js +8 -0
  51. package/esm/BigBedAdapter/configSchema.js.map +1 -0
  52. package/esm/BigBedAdapter/index.d.ts +1 -0
  53. package/esm/BigBedAdapter/index.js +2 -0
  54. package/esm/BigBedAdapter/index.js.map +1 -0
  55. package/esm/index.d.ts +6 -0
  56. package/esm/index.js +81 -0
  57. package/esm/index.js.map +1 -0
  58. package/esm/util.d.ts +4 -0
  59. package/esm/util.js +154 -0
  60. package/esm/util.js.map +1 -0
  61. package/package.json +18 -7
  62. package/src/BedAdapter/BedAdapter.test.ts +170 -0
  63. package/src/BedAdapter/BedAdapter.ts +172 -0
  64. package/src/BedAdapter/__snapshots__/BedAdapter.test.ts.snap +437 -0
  65. package/src/BedAdapter/configSchema.ts +45 -0
  66. package/src/BedAdapter/index.ts +1 -0
  67. package/src/BedAdapter/test_data/gwas.bed +20 -0
  68. package/src/BedAdapter/test_data/volvox-autosql.bed +1 -0
  69. package/src/BedAdapter/test_data/volvox-bed12.bed +4 -0
  70. package/src/BedAdapter/test_data/volvox.sort.bed +109 -0
  71. package/src/BedAdapter/test_data/volvox.sort.with.header.bed +121 -0
  72. package/src/BedTabixAdapter/BedTabixAdapter.ts +29 -80
  73. package/src/index.ts +34 -1
  74. package/src/util.ts +65 -6
  75. package/dist/BedTabixAdapter/BedTabixAdapter.test.js +0 -276
  76. package/dist/BigBedAdapter/BigBedAdapter.test.js +0 -63
  77. package/dist/declare.d.js +0 -1
  78. package/dist/index.test.js +0 -24
@@ -0,0 +1,121 @@
1
+ #this is a test header
2
+ #this is a test header
3
+ #this is a test header
4
+ #this is a test header
5
+ #this is a test header
6
+ #this is a test header
7
+ #this is a test header
8
+ #this is a test header
9
+ #this is a test header
10
+ #this is a test header
11
+ #this is a test header
12
+ #this is a test header
13
+ contigA 3000 3009
14
+ contigA 3105 3114
15
+ contigA 3152 3161
16
+ contigA 3171 3180
17
+ contigA 3174 3183
18
+ contigA 3213 3222
19
+ contigA 3465 3474
20
+ contigA 3795 3804
21
+ contigA 4035 4044
22
+ contigA 4073 4082
23
+ contigA 4074 4083
24
+ contigA 4166 4175
25
+ contigA 4179 4188
26
+ contigA 4204 4213
27
+ contigA 4248 4257
28
+ contigA 4260 4269
29
+ contigA 4577 4586
30
+ contigA 4828 4837
31
+ contigA 4901 4910
32
+ contigA 5006 5015
33
+ contigA 5051 5060
34
+ contigA 5201 5210
35
+ contigA 5260 5269
36
+ contigA 5281 5290
37
+ contigA 5349 5358
38
+ contigA 5353 5362
39
+ contigA 5423 5432
40
+ contigA 5457 5466
41
+ contigA 5548 5557
42
+ contigA 5626 5635
43
+ contigA 5835 5844
44
+ contigA 5909 5918
45
+ contigA 5927 5936
46
+ contigA 5969 5978
47
+ contigA 6070 6079
48
+ contigA 6185 6194
49
+ contigA 6285 6294
50
+ contigA 6363 6372
51
+ contigA 6559 6568
52
+ contigA 6834 6843
53
+ contigA 6908 6917
54
+ contigA 6918 6927
55
+ contigA 7141 7150
56
+ contigA 7173 7182
57
+ contigA 7569 7578
58
+ contigA 7619 7628
59
+ contigA 7654 7663
60
+ contigA 7671 7680
61
+ contigA 7707 7716
62
+ contigA 7739 7748
63
+ contigA 8077 8086
64
+ contigA 8128 8137
65
+ contigA 8132 8141
66
+ contigA 8210 8219
67
+ contigA 8267 8276
68
+ contigA 8328 8337
69
+ contigA 8524 8533
70
+ contigA 8659 8668
71
+ contigA 8660 8669
72
+ contigA 8742 8751
73
+ contigA 8811 8820
74
+ contigA 8816 8825
75
+ contigA 8964 8973
76
+ contigA 9048 9057
77
+ contigA 9054 9063
78
+ contigA 9136 9145
79
+ contigA 9243 9252
80
+ contigA 9320 9329
81
+ contigA 9366 9375
82
+ contigA 9525 9534
83
+ contigA 9580 9589
84
+ contigA 9610 9619
85
+ contigA 9744 9753
86
+ contigA 9753 9762
87
+ contigA 9759 9768
88
+ contigA 9807 9816
89
+ contigA 9853 9862
90
+ contigA 9884 9893
91
+ contigA 9920 9929
92
+ contigA 10043 10052
93
+ contigA 10216 10225
94
+ contigA 10217 10226
95
+ contigA 10252 10261
96
+ contigA 10384 10393
97
+ contigA 10498 10507
98
+ contigA 10585 10594
99
+ contigA 10684 10693
100
+ contigA 10781 10790
101
+ contigA 10875 10884
102
+ contigA 11004 11013
103
+ contigA 11095 11104
104
+ contigA 11182 11191
105
+ contigA 11207 11216
106
+ contigA 11241 11250
107
+ contigA 11335 11344
108
+ contigA 11340 11349
109
+ contigA 11535 11544
110
+ contigA 11543 11552
111
+ contigA 11549 11558
112
+ contigA 11653 11662
113
+ contigA 11675 11684
114
+ contigA 11689 11698
115
+ contigA 11774 11783
116
+ contigA 11832 11841
117
+ contigA 12386 12395
118
+ contigA 12408 12417
119
+ contigA 12441 12450
120
+ contigA 12530 12539
121
+ contigA 12738 12747
@@ -4,15 +4,13 @@ import {
4
4
  BaseFeatureDataAdapter,
5
5
  BaseOptions,
6
6
  } from '@jbrowse/core/data_adapters/BaseAdapter'
7
- import { FileLocation, Region } from '@jbrowse/core/util/types'
8
7
  import { openLocation } from '@jbrowse/core/util/io'
9
8
  import { ObservableCreate } from '@jbrowse/core/util/rxjs'
10
- import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
9
+ import { FileLocation, Region, Feature } from '@jbrowse/core/util'
11
10
  import { TabixIndexedFile } from '@gmod/tabix'
12
- import { readConfObject } from '@jbrowse/core/configuration'
13
- import { ucscProcessedTranscript } from '../util'
11
+ import { featureData } from '../util'
14
12
  import PluginManager from '@jbrowse/core/PluginManager'
15
- import { AnyConfigurationModel } from '@jbrowse/core/configuration/configurationSchema'
13
+ import { AnyConfigurationModel } from '@jbrowse/core/configuration'
16
14
  import { getSubAdapterType } from '@jbrowse/core/data_adapters/dataAdapterCache'
17
15
 
18
16
  export default class BedTabixAdapter extends BaseFeatureDataAdapter {
@@ -32,31 +30,20 @@ export default class BedTabixAdapter extends BaseFeatureDataAdapter {
32
30
  pluginManager?: PluginManager,
33
31
  ) {
34
32
  super(config, getSubAdapter, pluginManager)
35
- const bedGzLocation = readConfObject(
36
- config,
37
- 'bedGzLocation',
38
- ) as FileLocation
39
- const index = readConfObject(config, 'index') as {
40
- indexType?: string
41
- location: FileLocation
42
- }
43
- const autoSql = readConfObject(config, 'autoSql') as string
44
- const { location, indexType } = index
33
+ const bedGzLoc = this.getConf('bedGzLocation') as FileLocation
34
+ const type = this.getConf(['index', 'indexType'])
35
+ const loc = this.getConf(['index', 'location'])
36
+ const autoSql = this.getConf('autoSql')
37
+ const pm = this.pluginManager
45
38
 
46
39
  this.bed = new TabixIndexedFile({
47
- filehandle: openLocation(bedGzLocation, this.pluginManager),
48
- csiFilehandle:
49
- indexType === 'CSI'
50
- ? openLocation(location, this.pluginManager)
51
- : undefined,
52
- tbiFilehandle:
53
- indexType !== 'CSI'
54
- ? openLocation(location, this.pluginManager)
55
- : undefined,
40
+ filehandle: openLocation(bedGzLoc, pm),
41
+ csiFilehandle: type === 'CSI' ? openLocation(loc, pm) : undefined,
42
+ tbiFilehandle: type !== 'CSI' ? openLocation(loc, pm) : undefined,
56
43
  chunkCacheSize: 50 * 2 ** 20,
57
44
  })
58
- this.columnNames = readConfObject(config, 'columnNames')
59
- this.scoreColumn = readConfObject(config, 'scoreColumn')
45
+ this.columnNames = this.getConf('columnNames')
46
+ this.scoreColumn = this.getConf('scoreColumn')
60
47
  this.parser = new BED({ autoSql })
61
48
  }
62
49
 
@@ -68,10 +55,6 @@ export default class BedTabixAdapter extends BaseFeatureDataAdapter {
68
55
  return this.bed.getHeader()
69
56
  }
70
57
 
71
- defaultParser(fields: string[], line: string) {
72
- return Object.fromEntries(line.split('\t').map((f, i) => [fields[i], f]))
73
- }
74
-
75
58
  async getNames() {
76
59
  if (this.columnNames.length) {
77
60
  return this.columnNames
@@ -79,12 +62,12 @@ export default class BedTabixAdapter extends BaseFeatureDataAdapter {
79
62
  const header = await this.bed.getHeader()
80
63
  const defs = header.split('\n').filter(f => !!f)
81
64
  const defline = defs[defs.length - 1]
82
- return defline && defline.includes('\t')
65
+ return defline?.includes('\t')
83
66
  ? defline
84
67
  .slice(1)
85
68
  .split('\t')
86
- .map(field => field.trim())
87
- : null
69
+ .map(f => f.trim())
70
+ : undefined
88
71
  }
89
72
 
90
73
  public getFeatures(query: Region, opts: BaseOptions = {}) {
@@ -97,55 +80,21 @@ export default class BedTabixAdapter extends BaseFeatureDataAdapter {
97
80
  // colSame handles special case for tabix where a single column is both
98
81
  // the start and end, this is assumed to be covering the base at this
99
82
  // position (e.g. tabix -s 1 -b 2 -e 2) begin and end are same
100
- const colSame = colStart === colEnd ? 1 : 0
101
83
  const names = await this.getNames()
102
84
  await this.bed.getLines(query.refName, query.start, query.end, {
103
- lineCallback: (line: string, fileOffset: number) => {
104
- const l = line.split('\t')
105
- const refName = l[colRef]
106
- const start = +l[colStart]
107
-
108
- const end = +l[colEnd] + colSame
109
- const uniqueId = `${this.id}-${fileOffset}`
110
- const data = names
111
- ? this.defaultParser(names, line)
112
- : this.parser.parseLine(line, { uniqueId })
113
-
114
- const { blockCount, blockSizes, blockStarts, chromStarts } = data
115
-
116
- if (blockCount) {
117
- const starts = chromStarts || blockStarts || []
118
- const sizes = blockSizes
119
- const blocksOffset = start
120
- data.subfeatures = []
121
-
122
- for (let b = 0; b < blockCount; b += 1) {
123
- const bmin = (starts[b] || 0) + blocksOffset
124
- const bmax = bmin + (sizes[b] || 0)
125
- data.subfeatures.push({
126
- uniqueId: `${uniqueId}-${b}`,
127
- start: bmin,
128
- end: bmax,
129
- type: 'block',
130
- })
131
- }
132
- }
133
-
134
- if (this.scoreColumn) {
135
- data.score = +data[this.scoreColumn]
136
- }
137
- delete data.chrom
138
- delete data.chromStart
139
- delete data.chromEnd
140
- const f = new SimpleFeature({
141
- ...data,
142
- start,
143
- end,
144
- refName,
145
- uniqueId,
146
- })
147
- const r = f.get('thickStart') ? ucscProcessedTranscript(f) : f
148
- observer.next(r)
85
+ lineCallback: (line, fileOffset) => {
86
+ observer.next(
87
+ featureData(
88
+ line,
89
+ colRef,
90
+ colStart,
91
+ colEnd,
92
+ this.scoreColumn,
93
+ this.parser,
94
+ `${this.id}-${fileOffset}`,
95
+ names,
96
+ ),
97
+ )
149
98
  },
150
99
  signal: opts.signal,
151
100
  })
package/src/index.ts CHANGED
@@ -3,12 +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 { configSchema as bedAdapterConfigSchema } from './BedAdapter'
6
7
  import { FileLocation } from '@jbrowse/core/util/types'
7
8
  import {
9
+ getFileName,
8
10
  makeIndex,
9
11
  makeIndexType,
10
12
  AdapterGuesser,
11
- getFileName,
12
13
  } from '@jbrowse/core/util/tracks'
13
14
 
14
15
  export default class BedPlugin extends Plugin {
@@ -59,6 +60,16 @@ export default class BedPlugin extends Plugin {
59
60
  import('./BedTabixAdapter/BedTabixAdapter').then(r => r.default),
60
61
  }),
61
62
  )
63
+
64
+ pluginManager.addAdapterType(
65
+ () =>
66
+ new AdapterType({
67
+ name: 'BedAdapter',
68
+ configSchema: bedAdapterConfigSchema,
69
+ getAdapterClass: () =>
70
+ import('./BedAdapter/BedAdapter').then(r => r.default),
71
+ }),
72
+ )
62
73
  pluginManager.addToExtensionPoint(
63
74
  'Core-guessAdapterForLocation',
64
75
  (adapterGuesser: AdapterGuesser) => {
@@ -85,5 +96,27 @@ export default class BedPlugin extends Plugin {
85
96
  }
86
97
  },
87
98
  )
99
+
100
+ pluginManager.addToExtensionPoint(
101
+ 'Core-guessAdapterForLocation',
102
+ (adapterGuesser: AdapterGuesser) => {
103
+ return (
104
+ file: FileLocation,
105
+ index?: FileLocation,
106
+ adapterHint?: string,
107
+ ) => {
108
+ const regexGuess = /\.bed$/i
109
+ const adapterName = 'BedAdapter'
110
+ const fileName = getFileName(file)
111
+ if (regexGuess.test(fileName) || adapterHint === adapterName) {
112
+ return {
113
+ type: adapterName,
114
+ bedLocation: file,
115
+ }
116
+ }
117
+ return adapterGuesser(file, index, adapterHint)
118
+ }
119
+ },
120
+ )
88
121
  }
89
122
  }
package/src/util.ts CHANGED
@@ -1,4 +1,5 @@
1
- import SimpleFeature, { Feature } from '@jbrowse/core/util/simpleFeature'
1
+ import { SimpleFeature, Feature } from '@jbrowse/core/util'
2
+ import BED from '@gmod/bed'
2
3
 
3
4
  export function ucscProcessedTranscript(feature: Feature) {
4
5
  const children = feature.children()
@@ -97,11 +98,9 @@ export function ucscProcessedTranscript(feature: Feature) {
97
98
  })
98
99
  }
99
100
  })
100
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
101
- const newData: Record<string, any> = {}
102
- feature.tags().forEach(tag => {
103
- newData[tag] = feature.get(tag)
104
- })
101
+ const newData = Object.fromEntries(
102
+ feature.tags().map(tag => [tag, feature.get(tag)]),
103
+ )
105
104
  newData.subfeatures = newChildren
106
105
  newData.type = 'mRNA'
107
106
  newData.uniqueId = feature.id()
@@ -120,3 +119,63 @@ export function ucscProcessedTranscript(feature: Feature) {
120
119
  })
121
120
  return newFeature
122
121
  }
122
+
123
+ function defaultParser(fields: string[], line: string) {
124
+ return Object.fromEntries(line.split('\t').map((f, i) => [fields[i], f]))
125
+ }
126
+
127
+ export function featureData(
128
+ line: string,
129
+ colRef: number,
130
+ colStart: number,
131
+ colEnd: number,
132
+ scoreColumn: string,
133
+ parser: typeof BED,
134
+ uniqueId: string,
135
+ names?: string[],
136
+ ) {
137
+ const l = line.split('\t')
138
+ const refName = l[colRef]
139
+ const start = +l[colStart]
140
+ const colSame = colStart === colEnd ? 1 : 0
141
+
142
+ const end = +l[colEnd] + colSame
143
+ const data = names
144
+ ? defaultParser(names, line)
145
+ : parser.parseLine(line, { uniqueId })
146
+
147
+ const { blockCount, blockSizes, blockStarts, chromStarts } = data
148
+
149
+ if (blockCount) {
150
+ const starts = chromStarts || blockStarts || []
151
+ const sizes = blockSizes
152
+ const blocksOffset = start
153
+ data.subfeatures = []
154
+
155
+ for (let b = 0; b < blockCount; b += 1) {
156
+ const bmin = (starts[b] || 0) + blocksOffset
157
+ const bmax = bmin + (sizes[b] || 0)
158
+ data.subfeatures.push({
159
+ uniqueId: `${uniqueId}-${b}`,
160
+ start: bmin,
161
+ end: bmax,
162
+ type: 'block',
163
+ })
164
+ }
165
+ }
166
+
167
+ if (scoreColumn) {
168
+ data.score = +data[scoreColumn]
169
+ }
170
+ delete data.chrom
171
+ delete data.chromStart
172
+ delete data.chromEnd
173
+ const f = new SimpleFeature({
174
+ ...data,
175
+ start,
176
+ end,
177
+ refName,
178
+ uniqueId,
179
+ })
180
+ return f.get('thickStart') ? ucscProcessedTranscript(f) : f
181
+ }
@@ -1,276 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
6
-
7
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
-
9
- var _operators = require("rxjs/operators");
10
-
11
- var _BedTabixAdapter = _interopRequireDefault(require("./BedTabixAdapter"));
12
-
13
- var _configSchema = _interopRequireDefault(require("./configSchema"));
14
-
15
- test('adapter can fetch features from volvox-bed12.bed.gz', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() {
16
- var adapter, features, featuresArray, featuresJsonArray;
17
- return _regenerator.default.wrap(function _callee$(_context) {
18
- while (1) {
19
- switch (_context.prev = _context.next) {
20
- case 0:
21
- adapter = new _BedTabixAdapter.default(_configSchema.default.create({
22
- bedGzLocation: {
23
- localPath: require.resolve('./test_data/volvox-bed12.bed.gz'),
24
- locationType: 'LocalPathLocation'
25
- },
26
- index: {
27
- location: {
28
- localPath: require.resolve('./test_data/volvox-bed12.bed.gz.tbi'),
29
- locationType: 'LocalPathLocation'
30
- }
31
- }
32
- }));
33
- features = adapter.getFeatures({
34
- refName: 'ctgA',
35
- start: 0,
36
- end: 20000,
37
- assemblyName: 'volvox'
38
- });
39
- _context.t0 = expect;
40
- _context.next = 5;
41
- return adapter.hasDataForRefName('ctgA');
42
-
43
- case 5:
44
- _context.t1 = _context.sent;
45
- (0, _context.t0)(_context.t1).toBe(true);
46
- _context.t2 = expect;
47
- _context.next = 10;
48
- return adapter.hasDataForRefName('ctgB');
49
-
50
- case 10:
51
- _context.t3 = _context.sent;
52
- (0, _context.t2)(_context.t3).toBe(false);
53
- _context.next = 14;
54
- return features.pipe((0, _operators.toArray)()).toPromise();
55
-
56
- case 14:
57
- featuresArray = _context.sent;
58
- featuresJsonArray = featuresArray.map(function (f) {
59
- return f.toJSON();
60
- });
61
- expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
62
-
63
- case 17:
64
- case "end":
65
- return _context.stop();
66
- }
67
- }
68
- }, _callee);
69
- })));
70
- test('adapter can fetch features from volvox.sort.bed.gz simple bed3', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
71
- var adapter, features, featuresArray, featuresJsonArray;
72
- return _regenerator.default.wrap(function _callee2$(_context2) {
73
- while (1) {
74
- switch (_context2.prev = _context2.next) {
75
- case 0:
76
- adapter = new _BedTabixAdapter.default(_configSchema.default.create({
77
- bedGzLocation: {
78
- localPath: require.resolve('./test_data/volvox.sort.bed.gz'),
79
- locationType: 'LocalPathLocation'
80
- },
81
- index: {
82
- location: {
83
- localPath: require.resolve('./test_data/volvox.sort.bed.gz.tbi'),
84
- locationType: 'LocalPathLocation'
85
- }
86
- }
87
- }));
88
- features = adapter.getFeatures({
89
- refName: 'contigA',
90
- start: 0,
91
- end: 20000,
92
- assemblyName: 'volvox'
93
- });
94
- _context2.t0 = expect;
95
- _context2.next = 5;
96
- return adapter.hasDataForRefName('contigA');
97
-
98
- case 5:
99
- _context2.t1 = _context2.sent;
100
- (0, _context2.t0)(_context2.t1).toBe(true);
101
- _context2.t2 = expect;
102
- _context2.next = 10;
103
- return adapter.hasDataForRefName('ctgB');
104
-
105
- case 10:
106
- _context2.t3 = _context2.sent;
107
- (0, _context2.t2)(_context2.t3).toBe(false);
108
- _context2.next = 14;
109
- return features.pipe((0, _operators.toArray)()).toPromise();
110
-
111
- case 14:
112
- featuresArray = _context2.sent;
113
- featuresJsonArray = featuresArray.map(function (f) {
114
- return f.toJSON();
115
- });
116
- expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
117
-
118
- case 17:
119
- case "end":
120
- return _context2.stop();
121
- }
122
- }
123
- }, _callee2);
124
- })));
125
- test('adapter can fetch features bed with autosql', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3() {
126
- var adapter, features, featuresArray, featuresJsonArray;
127
- return _regenerator.default.wrap(function _callee3$(_context3) {
128
- while (1) {
129
- switch (_context3.prev = _context3.next) {
130
- case 0:
131
- adapter = new _BedTabixAdapter.default(_configSchema.default.create({
132
- bedGzLocation: {
133
- localPath: require.resolve('./test_data/volvox-autosql.bed.gz'),
134
- locationType: 'LocalPathLocation'
135
- },
136
- index: {
137
- location: {
138
- localPath: require.resolve('./test_data/volvox-autosql.bed.gz.tbi'),
139
- locationType: 'LocalPathLocation'
140
- }
141
- },
142
- autoSql: "table gdcCancer\n\"somatic variants converted from MAF files obtained through the NCI GDC\"\n (\n string chrom; \"Chromosome (or contig, scaffold, etc.)\"\n uint chromStart; \"Start position in chromosome\"\n uint chromEnd; \"End position in chromosome\"\n string name; \"Name of item\"\n uint score; \"Score from 0-1000\"\n char[1] strand; \"+ or -\"\n uint thickStart; \"Start of where display should be thick (start codon)\"\n uint thickEnd; \"End of where display should be thick (stop codon)\"\n uint reserved; \"Used as itemRgb as of 2004-11-22\"\n int blockCount; \"Number of blocks\"\n int[blockCount] blockSizes; \"Comma separated list of block sizes\"\n int[blockCount] chromStarts; \"Start positions relative to chromStart\"\n string sampleCount; \"Number of samples with this variant\"\n string freq; \"Variant frequency\"\n lstring Hugo_Symbol; \"Hugo symbol\"\n lstring Entrez_Gene_Id; \"Entrez Gene Id\"\n lstring Variant_Classification; \"Class of variant\"\n lstring Variant_Type; \"Type of variant\"\n lstring Reference_Allele; \"Reference allele\"\n lstring Tumor_Seq_Allele1; \"Tumor allele 1\"\n lstring Tumor_Seq_Allele2; \"Tumor allele 2\"\n lstring dbSNP_RS; \"dbSNP RS number\"\n lstring dbSNP_Val_Status; \"dbSNP validation status\"\n lstring days_to_death; \"Number of days till death\"\n lstring cigarettes_per_day; \"Number of cigarettes per day\"\n lstring weight; \"Weight\"\n lstring alcohol_history; \"Any alcohol consumption?\"\n lstring alcohol_intensity; \"Frequency of alcohol consumption\"\n lstring bmi; \"Body mass index\"\n lstring years_smoked; \"Number of years smoked\"\n lstring height; \"Height\"\n lstring gender; \"Gender\"\n lstring project_id; \"TCGA Project id\"\n lstring ethnicity; \"Ethnicity\"\n lstring Tumor_Sample_Barcode; \"Tumor sample barcode\"\n lstring Matched_Norm_Sample_Barcode; \"Matcheds normal sample barcode\"\n lstring case_id; \"Case ID number\"\n)"
143
- }));
144
- features = adapter.getFeatures({
145
- refName: 'ctgA',
146
- start: 0,
147
- end: 20000,
148
- assemblyName: 'volvox'
149
- });
150
- _context3.t0 = expect;
151
- _context3.next = 5;
152
- return adapter.hasDataForRefName('ctgA');
153
-
154
- case 5:
155
- _context3.t1 = _context3.sent;
156
- (0, _context3.t0)(_context3.t1).toBe(true);
157
- _context3.t2 = expect;
158
- _context3.next = 10;
159
- return adapter.hasDataForRefName('ctgB');
160
-
161
- case 10:
162
- _context3.t3 = _context3.sent;
163
- (0, _context3.t2)(_context3.t3).toBe(false);
164
- _context3.next = 14;
165
- return features.pipe((0, _operators.toArray)()).toPromise();
166
-
167
- case 14:
168
- featuresArray = _context3.sent;
169
- featuresJsonArray = featuresArray.map(function (f) {
170
- return f.toJSON();
171
- });
172
- expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
173
-
174
- case 17:
175
- case "end":
176
- return _context3.stop();
177
- }
178
- }
179
- }, _callee3);
180
- })));
181
- test('adapter can fetch bed with header', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee4() {
182
- var adapter, features, featuresArray, featuresJsonArray;
183
- return _regenerator.default.wrap(function _callee4$(_context4) {
184
- while (1) {
185
- switch (_context4.prev = _context4.next) {
186
- case 0:
187
- adapter = new _BedTabixAdapter.default(_configSchema.default.create({
188
- bedGzLocation: {
189
- localPath: require.resolve('./test_data/volvox.sort.with.header.bed.gz'),
190
- locationType: 'LocalPathLocation'
191
- },
192
- index: {
193
- location: {
194
- localPath: require.resolve('./test_data/volvox.sort.with.header.bed.gz.tbi'),
195
- locationType: 'LocalPathLocation'
196
- }
197
- }
198
- }));
199
- features = adapter.getFeatures({
200
- refName: 'contigA',
201
- start: 0,
202
- end: 20000,
203
- assemblyName: 'volvox'
204
- });
205
- _context4.t0 = expect;
206
- _context4.next = 5;
207
- return adapter.hasDataForRefName('contigA');
208
-
209
- case 5:
210
- _context4.t1 = _context4.sent;
211
- (0, _context4.t0)(_context4.t1).toBe(true);
212
- _context4.t2 = expect;
213
- _context4.next = 10;
214
- return adapter.hasDataForRefName('ctgB');
215
-
216
- case 10:
217
- _context4.t3 = _context4.sent;
218
- (0, _context4.t2)(_context4.t3).toBe(false);
219
- _context4.next = 14;
220
- return features.pipe((0, _operators.toArray)()).toPromise();
221
-
222
- case 14:
223
- featuresArray = _context4.sent;
224
- featuresJsonArray = featuresArray.map(function (f) {
225
- return f.toJSON();
226
- });
227
- expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
228
-
229
- case 17:
230
- case "end":
231
- return _context4.stop();
232
- }
233
- }
234
- }, _callee4);
235
- })));
236
- test('adapter can use gwas header', /*#__PURE__*/(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5() {
237
- var adapter, features, featuresArray, featuresJsonArray;
238
- return _regenerator.default.wrap(function _callee5$(_context5) {
239
- while (1) {
240
- switch (_context5.prev = _context5.next) {
241
- case 0:
242
- adapter = new _BedTabixAdapter.default(_configSchema.default.create({
243
- bedGzLocation: {
244
- localPath: require.resolve('./test_data/gwas.bed.gz'),
245
- locationType: 'LocalPathLocation'
246
- },
247
- index: {
248
- location: {
249
- localPath: require.resolve('./test_data/gwas.bed.gz.tbi'),
250
- locationType: 'LocalPathLocation'
251
- }
252
- }
253
- }));
254
- features = adapter.getFeatures({
255
- refName: '1',
256
- start: 0,
257
- end: 100000,
258
- assemblyName: 'hg19'
259
- });
260
- _context5.next = 4;
261
- return features.pipe((0, _operators.toArray)()).toPromise();
262
-
263
- case 4:
264
- featuresArray = _context5.sent;
265
- featuresJsonArray = featuresArray.map(function (f) {
266
- return f.toJSON();
267
- });
268
- expect(featuresJsonArray.slice(0, 10)).toMatchSnapshot();
269
-
270
- case 7:
271
- case "end":
272
- return _context5.stop();
273
- }
274
- }
275
- }, _callee5);
276
- })));