@gmod/bbi 3.0.0 → 4.0.0
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.
- package/CHANGELOG.md +45 -15
- package/README.md +43 -16
- package/dist/bbi.d.ts +5 -5
- package/dist/bbi.js +17 -23
- package/dist/bbi.js.map +1 -1
- package/dist/bigbed.d.ts +11 -4
- package/dist/bigbed.js +23 -16
- package/dist/bigbed.js.map +1 -1
- package/dist/bigwig.d.ts +1 -1
- package/dist/bigwig.js +2 -2
- package/dist/bigwig.js.map +1 -1
- package/{esm/blockView.d.ts → dist/block-view.d.ts} +1 -1
- package/dist/{blockView.js → block-view.js} +28 -19
- package/dist/block-view.js.map +1 -0
- package/dist/range.js +3 -4
- package/dist/range.js.map +1 -1
- package/dist/unzip-pako.d.ts +1 -0
- package/dist/unzip-pako.js.map +1 -1
- package/dist/unzip.d.ts +1 -2
- package/dist/unzip.js +1 -1
- package/dist/unzip.js.map +1 -1
- package/dist/util.js +12 -12
- package/dist/util.js.map +1 -1
- package/esm/bbi.d.ts +5 -5
- package/esm/bbi.js +14 -20
- package/esm/bbi.js.map +1 -1
- package/esm/bigbed.d.ts +11 -4
- package/esm/bigbed.js +8 -12
- package/esm/bigbed.js.map +1 -1
- package/esm/bigwig.d.ts +1 -1
- package/esm/bigwig.js +1 -1
- package/esm/bigwig.js.map +1 -1
- package/{dist/blockView.d.ts → esm/block-view.d.ts} +1 -1
- package/esm/{blockView.js → block-view.js} +26 -17
- package/esm/block-view.js.map +1 -0
- package/esm/range.js +3 -4
- package/esm/range.js.map +1 -1
- package/esm/unzip-pako.d.ts +1 -0
- package/esm/unzip-pako.js.map +1 -1
- package/esm/unzip.d.ts +1 -2
- package/esm/unzip.js +1 -2
- package/esm/unzip.js.map +1 -1
- package/esm/util.js +12 -12
- package/esm/util.js.map +1 -1
- package/package.json +15 -15
- package/src/bbi.ts +30 -35
- package/src/bigbed.ts +12 -23
- package/src/bigwig.ts +1 -1
- package/src/{blockView.ts → block-view.ts} +31 -21
- package/src/range.ts +3 -4
- package/src/unzip-pako.ts +1 -0
- package/src/unzip.ts +1 -2
- package/src/util.ts +11 -11
- package/CHANGELOG.md.orig +0 -200
- package/dist/blockView.js.map +0 -1
- package/esm/blockView.js.map +0 -1
- package/src/declare.d.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
# [
|
|
1
|
+
# [4.0.0](https://github.com/GMOD/bbi-js/compare/v3.0.1...v4.0.0) (2023-05-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
- Improve typescripting, refactoring
|
|
6
|
+
- Options argument only accepts {signal}, not just signal now
|
|
2
7
|
|
|
8
|
+
## [3.0.1](https://github.com/GMOD/bbi-js/compare/v3.0.0...v3.0.1) (2023-04-21)
|
|
3
9
|
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
- explicit buffer import ([#53](https://github.com/GMOD/bbi-js/issues/53))
|
|
13
|
+
([2699c98](https://github.com/GMOD/bbi-js/commit/2699c983dea380bbb56773058ba3f233c833d9c8))
|
|
14
|
+
|
|
15
|
+
* Add explicit Buffer import
|
|
16
|
+
|
|
17
|
+
# [3.0.0](https://github.com/GMOD/bbi-js/compare/v2.0.5...v3.0.0) (2023-01-11)
|
|
4
18
|
|
|
5
19
|
- Update to rxjs 7
|
|
6
20
|
|
|
@@ -38,7 +52,9 @@
|
|
|
38
52
|
|
|
39
53
|
### Reverts
|
|
40
54
|
|
|
41
|
-
- Revert "Use subarray instead of slice since slice is deprecated under node
|
|
55
|
+
- Revert "Use subarray instead of slice since slice is deprecated under node
|
|
56
|
+
xref 'https://nodejs.org/api/buffer.html#bufslicestart-end'"
|
|
57
|
+
([44116cc](https://github.com/GMOD/bbi-js/commit/44116cce54601727d37f1c449bfcc60c1b4e602d))
|
|
42
58
|
|
|
43
59
|
* Back to slice instead of subarray, as subarray returned a UInt8Array instead
|
|
44
60
|
of a true Buffer
|
|
@@ -64,11 +80,13 @@
|
|
|
64
80
|
|
|
65
81
|
## [1.0.29](https://github.com/GMOD/bbi-js/compare/v1.0.28...v1.0.29) (2020-01-28)
|
|
66
82
|
|
|
67
|
-
- Accidentally made the package include itself as dependency in 1.0.28,
|
|
83
|
+
- Accidentally made the package include itself as dependency in 1.0.28,
|
|
84
|
+
republish
|
|
68
85
|
|
|
69
86
|
## [1.0.28](https://github.com/GMOD/bbi-js/compare/v1.0.27...v1.0.28) (2020-01-28)
|
|
70
87
|
|
|
71
|
-
- Change typescript interface to use object keys instead of Map type for
|
|
88
|
+
- Change typescript interface to use object keys instead of Map type for
|
|
89
|
+
refsByName, refsById
|
|
72
90
|
- Typescript only release change
|
|
73
91
|
|
|
74
92
|
## [1.0.27](https://github.com/GMOD/bbi-js/compare/v1.0.26...v1.0.27) (2020-01-10)
|
|
@@ -80,11 +98,13 @@ Thanks to @skinner for both of these contributions!
|
|
|
80
98
|
|
|
81
99
|
## [1.0.26](https://github.com/GMOD/bbi-js/compare/v1.0.25...v1.0.26) (2019-11-10)
|
|
82
100
|
|
|
83
|
-
- Fix important bug with fixed step bigwig files not using the proper start
|
|
101
|
+
- Fix important bug with fixed step bigwig files not using the proper start
|
|
102
|
+
coordinate
|
|
84
103
|
|
|
85
104
|
## [1.0.25](https://github.com/GMOD/bbi-js/compare/v1.0.24...v1.0.25) (2019-11-03)
|
|
86
105
|
|
|
87
|
-
- Add fix for files with a large header, if autoSql is large in a bigbed file
|
|
106
|
+
- Add fix for files with a large header, if autoSql is large in a bigbed file
|
|
107
|
+
would be likely scenario
|
|
88
108
|
|
|
89
109
|
## [1.0.24](https://github.com/GMOD/bbi-js/compare/v1.0.23...v1.0.24) (2019-10-29)
|
|
90
110
|
|
|
@@ -109,22 +129,26 @@ Thanks to @skinner for both of these contributions!
|
|
|
109
129
|
|
|
110
130
|
## [1.0.19](https://github.com/GMOD/bbi-js/compare/v1.0.18...v1.0.19) (2019-05-02)
|
|
111
131
|
|
|
112
|
-
- Add regression fix since 1.0.16 for uncompressed files. Thanks to @lidaof for
|
|
132
|
+
- Add regression fix since 1.0.16 for uncompressed files. Thanks to @lidaof for
|
|
133
|
+
reporting!
|
|
113
134
|
|
|
114
135
|
## [1.0.18](https://github.com/GMOD/bbi-js/compare/v1.0.17...v1.0.18) (2019-05-02)
|
|
115
136
|
|
|
116
137
|
- Improve error handling of the observables (issue #20, pull #21)
|
|
117
|
-
- Bump generic-filehandle to 1.0.9 to fix compatibility with native browser
|
|
138
|
+
- Bump generic-filehandle to 1.0.9 to fix compatibility with native browser
|
|
139
|
+
fetch
|
|
118
140
|
|
|
119
141
|
## [1.0.17](https://github.com/GMOD/bbi-js/compare/v1.0.16...v1.0.17) (2019-04-30)
|
|
120
142
|
|
|
121
143
|
- Use some standard rxjs notions for combining operator results
|
|
122
|
-
- Add parsing of the extraIndex data in BigBed, allowing you to call
|
|
144
|
+
- Add parsing of the extraIndex data in BigBed, allowing you to call
|
|
145
|
+
bigbed.searchExtraIndex(name[,opts])
|
|
123
146
|
|
|
124
147
|
## [1.0.16](https://github.com/GMOD/bbi-js/compare/v1.0.15...v1.0.16) (2019-04-23)
|
|
125
148
|
|
|
126
149
|
- Pre-compile binary-parser instances for faster
|
|
127
|
-
- Important: fixed bug that caused bigwig summary blocks to not be returned in
|
|
150
|
+
- Important: fixed bug that caused bigwig summary blocks to not be returned in
|
|
151
|
+
output
|
|
128
152
|
|
|
129
153
|
## [1.0.15](https://github.com/GMOD/bbi-js/compare/v1.0.14...v1.0.15) (2019-04-18)
|
|
130
154
|
|
|
@@ -149,12 +173,15 @@ Thanks to @skinner for both of these contributions!
|
|
|
149
173
|
|
|
150
174
|
## [1.0.10](https://github.com/GMOD/bbi-js/compare/v1.0.9...v1.0.10) (2019-04-09)
|
|
151
175
|
|
|
152
|
-
- Fix misinterpretation of variable step wig files in this module (the span is
|
|
176
|
+
- Fix misinterpretation of variable step wig files in this module (the span is
|
|
177
|
+
not variable in variable step files, only the step, use bedGraphToBigWig for
|
|
178
|
+
variable span)
|
|
153
179
|
- Improved docs
|
|
154
180
|
|
|
155
181
|
## [1.0.9](https://github.com/GMOD/bbi-js/compare/v1.0.8...v1.0.9) (2019-04-05)
|
|
156
182
|
|
|
157
|
-
- Added caching of networking requests (thanks @rbuels for the
|
|
183
|
+
- Added caching of networking requests (thanks @rbuels for the
|
|
184
|
+
abortable-promise-cache module!)
|
|
158
185
|
- Fix some type errors on the range class
|
|
159
186
|
- Correct using span on fixed size wiggle types
|
|
160
187
|
|
|
@@ -166,7 +193,8 @@ Thanks to @skinner for both of these contributions!
|
|
|
166
193
|
## [1.0.7](https://github.com/GMOD/bbi-js/compare/v1.0.6...v1.0.7) (2019-04-01)
|
|
167
194
|
|
|
168
195
|
- Added getFeatureStream which returns an Observable from rxjs
|
|
169
|
-
- Added url option to BigWig and BigBed constructors to allow usage of
|
|
196
|
+
- Added url option to BigWig and BigBed constructors to allow usage of
|
|
197
|
+
RemoteFile filehandle
|
|
170
198
|
- Added typescript backend for better processing
|
|
171
199
|
|
|
172
200
|
## [1.0.6](https://github.com/GMOD/bbi-js/compare/v1.0.5...v1.0.6) (2019-03-15)
|
|
@@ -179,7 +207,8 @@ Thanks to @skinner for both of these contributions!
|
|
|
179
207
|
|
|
180
208
|
## [1.0.4](https://github.com/GMOD/bbi-js/compare/v1.0.3...v1.0.4) (2019-01-28)
|
|
181
209
|
|
|
182
|
-
- Add renameRefSeqs functionality where you can apply a callback to the refseq
|
|
210
|
+
- Add renameRefSeqs functionality where you can apply a callback to the refseq
|
|
211
|
+
names
|
|
183
212
|
- Consistently apply start/end coordinate filters at different zoom levels
|
|
184
213
|
|
|
185
214
|
## [1.0.3](https://github.com/GMOD/bbi-js/compare/v1.0.2...v1.0.3) (2019-01-27)
|
|
@@ -192,7 +221,8 @@ Thanks to @skinner for both of these contributions!
|
|
|
192
221
|
|
|
193
222
|
## [1.0.1](https://github.com/GMOD/bbi-js/compare/v1.0.0...v1.0.1) (2019-01-24)
|
|
194
223
|
|
|
195
|
-
- Added exports for BigWig and BigBed. const {BigWig, BigBed} =
|
|
224
|
+
- Added exports for BigWig and BigBed. const {BigWig, BigBed} =
|
|
225
|
+
require('@gmod/bbi')
|
|
196
226
|
|
|
197
227
|
# 1.0.0 (2019-01-23)
|
|
198
228
|
|
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ A parser for bigwig and bigbed file formats
|
|
|
10
10
|
|
|
11
11
|
If using locally
|
|
12
12
|
|
|
13
|
-
```
|
|
13
|
+
```typescript
|
|
14
14
|
const { BigWig } = require('@gmod/bbi')
|
|
15
15
|
const file = new BigWig({
|
|
16
16
|
path: 'volvox.bw',
|
|
@@ -21,10 +21,11 @@ const file = new BigWig({
|
|
|
21
21
|
})()
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
-
If using remotely, you can use it in combination with generic-filehandle or your
|
|
24
|
+
If using remotely, you can use it in combination with generic-filehandle or your
|
|
25
|
+
own implementation of something like generic-filehandle
|
|
25
26
|
https://github.com/GMOD/generic-filehandle/
|
|
26
27
|
|
|
27
|
-
```
|
|
28
|
+
```typescript
|
|
28
29
|
const { BigWig } = require('@gmod/bbi')
|
|
29
30
|
const { RemoteFile } = require('generic-filehandle')
|
|
30
31
|
|
|
@@ -53,7 +54,11 @@ Accepts an object containing either
|
|
|
53
54
|
|
|
54
55
|
- path - path to a local file
|
|
55
56
|
- url - path to a url
|
|
56
|
-
- filehandle - a filehandle instance that you can implement as a custom class
|
|
57
|
+
- filehandle - a filehandle instance that you can implement as a custom class
|
|
58
|
+
yourself. path and url are based on
|
|
59
|
+
https://www.npmjs.com/package/generic-filehandle but by implementing a class
|
|
60
|
+
containing the Filehandle interface specified therein, you can pass it to this
|
|
61
|
+
module
|
|
57
62
|
|
|
58
63
|
### BigWig
|
|
59
64
|
|
|
@@ -62,15 +67,20 @@ Accepts an object containing either
|
|
|
62
67
|
- refName - a name of a chromosome in the file
|
|
63
68
|
- start - a 0-based half open start coordinate
|
|
64
69
|
- end - a 0-based half open end coordinate
|
|
65
|
-
- opts.scale - indicates zoom level to use, specified as pxPerBp, e.g. being
|
|
70
|
+
- opts.scale - indicates zoom level to use, specified as pxPerBp, e.g. being
|
|
71
|
+
zoomed out, you might have 100bp per pixel so opts.scale would be 1/100. the
|
|
72
|
+
zoom level that is returned is the one which has reductionLevel<=2/opts.scale
|
|
73
|
+
(reductionLevel is a property of the zoom level structure in the bigwig file
|
|
74
|
+
data)
|
|
66
75
|
- opts.basesPerScale - optional, inverse of opts.scale e.g. bpPerPx
|
|
67
76
|
- opts.signal - optional, an AbortSignal to halt processing
|
|
68
77
|
|
|
69
|
-
Returns a promise to an array of features. If an incorrect refName or no
|
|
78
|
+
Returns a promise to an array of features. If an incorrect refName or no
|
|
79
|
+
features are found the result is an empty array.
|
|
70
80
|
|
|
71
81
|
Example:
|
|
72
82
|
|
|
73
|
-
```
|
|
83
|
+
```typescript
|
|
74
84
|
const feats = await bigwig.getFeatures('chr1', 0, 100)
|
|
75
85
|
// returns array of features with start, end, score
|
|
76
86
|
// coordinates on returned data are are 0-based half open
|
|
@@ -80,7 +90,9 @@ const feats = await bigwig.getFeatures('chr1', 0, 100)
|
|
|
80
90
|
|
|
81
91
|
### Understanding scale and reductionLevel
|
|
82
92
|
|
|
83
|
-
Here is what the reductionLevel structure looks like in a file. The zoomLevel
|
|
93
|
+
Here is what the reductionLevel structure looks like in a file. The zoomLevel
|
|
94
|
+
that is chosen is the first reductionLevel<2\*opts.basesPerScale (or
|
|
95
|
+
reductionLevel<2/opts.scale) when scanning backwards through this list
|
|
84
96
|
|
|
85
97
|
[ { reductionLevel: 40, ... },
|
|
86
98
|
{ reductionLevel: 160, ... },
|
|
@@ -92,9 +104,10 @@ Here is what the reductionLevel structure looks like in a file. The zoomLevel th
|
|
|
92
104
|
|
|
93
105
|
#### getFeatureStream(refName, start, end, opts)
|
|
94
106
|
|
|
95
|
-
Same as getFeatures but returns an RxJS observable stream, useful for very large
|
|
107
|
+
Same as getFeatures but returns an RxJS observable stream, useful for very large
|
|
108
|
+
queries
|
|
96
109
|
|
|
97
|
-
```
|
|
110
|
+
```typescript
|
|
98
111
|
const observer = await bigwig.getFeatureStream('chr1', 0, 100)
|
|
99
112
|
observer.subscribe(
|
|
100
113
|
chunk => {
|
|
@@ -118,7 +131,8 @@ observer.subscribe(
|
|
|
118
131
|
- end - a 0-based half open end coordinate
|
|
119
132
|
- opts.signal - optional, an AbortSignal to halt processing
|
|
120
133
|
|
|
121
|
-
returns a promise to an array of features. no concept of zoom levels is used
|
|
134
|
+
returns a promise to an array of features. no concept of zoom levels is used
|
|
135
|
+
with bigwig data
|
|
122
136
|
|
|
123
137
|
#### getFeatureStream(refName, start, end, opts)
|
|
124
138
|
|
|
@@ -126,20 +140,30 @@ Similar to BigWig, returns an RxJS observable for a observable stream
|
|
|
126
140
|
|
|
127
141
|
#### searchExtraIndex(name, opts)
|
|
128
142
|
|
|
129
|
-
Specific, to bigbed files, this method searches the bigBed "extra indexes",
|
|
143
|
+
Specific, to bigbed files, this method searches the bigBed "extra indexes",
|
|
144
|
+
there can be multiple indexes e.g. for the gene ID and gene name columns. See
|
|
145
|
+
the usage of -extraIndex in bedToBigBed here
|
|
146
|
+
https://genome.ucsc.edu/goldenpath/help/bigBed.html
|
|
130
147
|
|
|
131
148
|
This function accepts two arguments
|
|
132
149
|
|
|
133
150
|
- name: a string to search for in the BigBed extra indices
|
|
134
151
|
- opts: an opject that can optionally contain opts.signal, an abort signal
|
|
135
152
|
|
|
136
|
-
Returns a Promise to an array of Features, with an extra field indicating the
|
|
153
|
+
Returns a Promise to an array of Features, with an extra field indicating the
|
|
154
|
+
field that was matched
|
|
137
155
|
|
|
138
156
|
### How to parse BigBed results
|
|
139
157
|
|
|
140
|
-
The BigBed line contents are returned as a raw text line e.g. {start: 0,
|
|
158
|
+
The BigBed line contents are returned as a raw text line e.g. {start: 0,
|
|
159
|
+
end:100, rest: "ENST00000456328.2\t1000\t..."} where "rest" contains tab
|
|
160
|
+
delimited text for the fields from 4 and on in the BED format. Since BED files
|
|
161
|
+
from BigBed format often come with autoSql (a description of all the columns) it
|
|
162
|
+
can be useful to parse it with BED parser that can handle autoSql. The rest line
|
|
163
|
+
can be parsed by the @gmod/bed module, which is not by default integrated with
|
|
164
|
+
this module, but can be combined with it as follows
|
|
141
165
|
|
|
142
|
-
```
|
|
166
|
+
```typescript
|
|
143
167
|
import {BigBed} from '@gmod/bbi'
|
|
144
168
|
import BED from '@gmod/bed'
|
|
145
169
|
|
|
@@ -190,7 +214,10 @@ Features after parsing with @gmod/bed:
|
|
|
190
214
|
|
|
191
215
|
## Academic Use
|
|
192
216
|
|
|
193
|
-
This package was written with funding from the [NHGRI](http://genome.gov) as
|
|
217
|
+
This package was written with funding from the [NHGRI](http://genome.gov) as
|
|
218
|
+
part of the [JBrowse](http://jbrowse.org) project. If you use it in an academic
|
|
219
|
+
project that you publish, please cite the most recent JBrowse paper, which will
|
|
220
|
+
be linked from [jbrowse.org](http://jbrowse.org).
|
|
194
221
|
|
|
195
222
|
## License
|
|
196
223
|
|
package/dist/bbi.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { GenericFilehandle } from 'generic-filehandle';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
-
import { BlockView } from './
|
|
3
|
+
import { BlockView } from './block-view';
|
|
4
4
|
export interface Feature {
|
|
5
5
|
start: number;
|
|
6
6
|
end: number;
|
|
@@ -51,8 +51,8 @@ export declare abstract class BBI {
|
|
|
51
51
|
protected bbi: GenericFilehandle;
|
|
52
52
|
private headerP?;
|
|
53
53
|
protected renameRefSeqs: (a: string) => string;
|
|
54
|
-
getHeader(opts?: RequestOptions
|
|
55
|
-
constructor(
|
|
54
|
+
getHeader(opts?: RequestOptions): Promise<Header>;
|
|
55
|
+
constructor(args: {
|
|
56
56
|
filehandle?: GenericFilehandle;
|
|
57
57
|
path?: string;
|
|
58
58
|
url?: string;
|
|
@@ -62,8 +62,8 @@ export declare abstract class BBI {
|
|
|
62
62
|
private _getMainHeader;
|
|
63
63
|
private _isBigEndian;
|
|
64
64
|
private _readChromTree;
|
|
65
|
-
protected getUnzoomedView(opts
|
|
66
|
-
protected abstract getView(scale: number, opts
|
|
65
|
+
protected getUnzoomedView(opts?: RequestOptions): Promise<BlockView>;
|
|
66
|
+
protected abstract getView(scale: number, opts?: RequestOptions): Promise<BlockView>;
|
|
67
67
|
/**
|
|
68
68
|
* Gets features from a BigWig file
|
|
69
69
|
*
|
package/dist/bbi.js
CHANGED
|
@@ -10,11 +10,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.BBI = void 0;
|
|
13
|
+
const buffer_1 = require("buffer");
|
|
13
14
|
const binary_parser_1 = require("binary-parser");
|
|
14
15
|
const generic_filehandle_1 = require("generic-filehandle");
|
|
15
16
|
const rxjs_1 = require("rxjs");
|
|
16
17
|
const operators_1 = require("rxjs/operators");
|
|
17
|
-
const
|
|
18
|
+
const block_view_1 = require("./block-view");
|
|
18
19
|
const BIG_WIG_MAGIC = -2003829722;
|
|
19
20
|
const BIG_BED_MAGIC = -2021002517;
|
|
20
21
|
function toString(arr) {
|
|
@@ -82,10 +83,9 @@ class BBI {
|
|
|
82
83
|
* @param abortSignal - abort the operation, can be null
|
|
83
84
|
* @return a Header object
|
|
84
85
|
*/
|
|
85
|
-
getHeader(opts
|
|
86
|
-
const options = 'aborted' in opts ? { signal: opts } : opts;
|
|
86
|
+
getHeader(opts) {
|
|
87
87
|
if (!this.headerP) {
|
|
88
|
-
this.headerP = this._getHeader(
|
|
88
|
+
this.headerP = this._getHeader(opts).catch(e => {
|
|
89
89
|
this.headerP = undefined;
|
|
90
90
|
throw e;
|
|
91
91
|
});
|
|
@@ -98,8 +98,8 @@ class BBI {
|
|
|
98
98
|
* @param url - a URL string
|
|
99
99
|
* @param renameRefSeqs - an optional method to rename the internal reference sequences using a mapping function
|
|
100
100
|
*/
|
|
101
|
-
constructor(
|
|
102
|
-
const { filehandle, renameRefSeqs = s => s, path, url } =
|
|
101
|
+
constructor(args) {
|
|
102
|
+
const { filehandle, renameRefSeqs = s => s, path, url } = args;
|
|
103
103
|
this.renameRefSeqs = renameRefSeqs;
|
|
104
104
|
if (filehandle) {
|
|
105
105
|
this.bbi = filehandle;
|
|
@@ -123,7 +123,7 @@ class BBI {
|
|
|
123
123
|
}
|
|
124
124
|
_getMainHeader(opts, requestSize = 2000) {
|
|
125
125
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const { buffer } = yield this.bbi.read(Buffer.alloc(requestSize), 0, requestSize, 0, opts);
|
|
126
|
+
const { buffer } = yield this.bbi.read(buffer_1.Buffer.alloc(requestSize), 0, requestSize, 0, opts);
|
|
127
127
|
const isBigEndian = this._isBigEndian(buffer);
|
|
128
128
|
const ret = getParsers(isBigEndian);
|
|
129
129
|
const header = ret.headerParser.parse(buffer);
|
|
@@ -171,7 +171,7 @@ class BBI {
|
|
|
171
171
|
unzoomedDataOffset += 1;
|
|
172
172
|
}
|
|
173
173
|
const off = unzoomedDataOffset - chromTreeOffset;
|
|
174
|
-
const { buffer } = yield this.bbi.read(Buffer.alloc(off), 0, off, Number(chromTreeOffset), opts);
|
|
174
|
+
const { buffer } = yield this.bbi.read(buffer_1.Buffer.alloc(off), 0, off, Number(chromTreeOffset), opts);
|
|
175
175
|
const p = getParsers(isBE);
|
|
176
176
|
const { keySize } = p.chromTreeParser.parse(buffer);
|
|
177
177
|
const leafNodeParser = new binary_parser_1.Parser()
|
|
@@ -230,7 +230,7 @@ class BBI {
|
|
|
230
230
|
getUnzoomedView(opts) {
|
|
231
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
232
232
|
const { unzoomedIndexOffset, refsByName, uncompressBufSize, isBigEndian, fileType, } = yield this.getHeader(opts);
|
|
233
|
-
return new
|
|
233
|
+
return new block_view_1.BlockView(this.bbi, refsByName, unzoomedIndexOffset, isBigEndian, uncompressBufSize > 0, fileType);
|
|
234
234
|
});
|
|
235
235
|
}
|
|
236
236
|
/**
|
|
@@ -241,33 +241,27 @@ class BBI {
|
|
|
241
241
|
* @param end - The end of a region
|
|
242
242
|
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use
|
|
243
243
|
*/
|
|
244
|
-
getFeatureStream(refName, start, end, opts
|
|
245
|
-
scale: 1,
|
|
246
|
-
}) {
|
|
244
|
+
getFeatureStream(refName, start, end, opts) {
|
|
247
245
|
return __awaiter(this, void 0, void 0, function* () {
|
|
248
246
|
yield this.getHeader(opts);
|
|
249
247
|
const chrName = this.renameRefSeqs(refName);
|
|
250
248
|
let view;
|
|
251
|
-
|
|
252
|
-
|
|
249
|
+
const { basesPerSpan, scale } = opts || {};
|
|
250
|
+
if (basesPerSpan) {
|
|
251
|
+
view = yield this.getView(1 / basesPerSpan, opts);
|
|
253
252
|
}
|
|
254
|
-
else if (
|
|
255
|
-
view = yield this.getView(
|
|
253
|
+
else if (scale) {
|
|
254
|
+
view = yield this.getView(scale, opts);
|
|
256
255
|
}
|
|
257
256
|
else {
|
|
258
257
|
view = yield this.getView(1, opts);
|
|
259
258
|
}
|
|
260
|
-
|
|
261
|
-
throw new Error('unable to get block view for data');
|
|
262
|
-
}
|
|
263
|
-
return new rxjs_1.Observable((observer) => {
|
|
259
|
+
return new rxjs_1.Observable(observer => {
|
|
264
260
|
view.readWigData(chrName, start, end, observer, opts);
|
|
265
261
|
});
|
|
266
262
|
});
|
|
267
263
|
}
|
|
268
|
-
getFeatures(refName, start, end, opts
|
|
269
|
-
scale: 1,
|
|
270
|
-
}) {
|
|
264
|
+
getFeatures(refName, start, end, opts) {
|
|
271
265
|
return __awaiter(this, void 0, void 0, function* () {
|
|
272
266
|
const ob = yield this.getFeatureStream(refName, start, end, opts);
|
|
273
267
|
const ret = yield (0, rxjs_1.firstValueFrom)(ob.pipe((0, operators_1.toArray)()));
|
package/dist/bbi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bbi.js","sourceRoot":"","sources":["../src/bbi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iDAAsC;AACtC,2DAA6E;AAC7E,+
|
|
1
|
+
{"version":3,"file":"bbi.js","sourceRoot":"","sources":["../src/bbi.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA+B;AAC/B,iDAAsC;AACtC,2DAA6E;AAC7E,+BAAiD;AACjD,8CAAwC;AACxC,6CAAwC;AAExC,MAAM,aAAa,GAAG,CAAC,UAAU,CAAA;AACjC,MAAM,aAAa,GAAG,CAAC,UAAU,CAAA;AAEjC,SAAS,QAAQ,CAAC,GAAe;IAC/B,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;AACtC,CAAC;AAyCD;;;;GAIG;AACH,SAAS,UAAU,CAAC,IAAa;IAC/B,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAA;IAClC,MAAM,YAAY,GAAG,IAAI,sBAAM,EAAE;SAC9B,SAAS,CAAC,EAAE,CAAC;SACb,KAAK,CAAC,OAAO,CAAC;SACd,MAAM,CAAC,SAAS,CAAC;SACjB,MAAM,CAAC,eAAe,CAAC;SACvB,MAAM,CAAC,iBAAiB,CAAC;SACzB,MAAM,CAAC,oBAAoB,CAAC;SAC5B,MAAM,CAAC,qBAAqB,CAAC;SAC7B,MAAM,CAAC,YAAY,CAAC;SACpB,MAAM,CAAC,mBAAmB,CAAC;SAC3B,MAAM,CAAC,UAAU,CAAC,CAAC,iCAAiC;SACpD,MAAM,CAAC,oBAAoB,CAAC;SAC5B,MAAM,CAAC,mBAAmB,CAAC;SAC3B,MAAM,CAAC,iBAAiB,CAAC,CAAC,oCAAoC;SAC9D,KAAK,CAAC,YAAY,EAAE;QACnB,MAAM,EAAE,eAAe;QACvB,IAAI,EAAE,IAAI,sBAAM,EA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
-
|
|
3
|
+
interface Index {
|
|
4
|
+
type: number;
|
|
5
|
+
fieldcount: number;
|
|
6
|
+
offset: number;
|
|
7
|
+
field: number;
|
|
8
|
+
}
|
|
3
9
|
export declare function filterUndef<T>(ts: (T | undefined)[]): T[];
|
|
4
10
|
export declare class BigBed extends BBI {
|
|
5
|
-
readIndicesCache:
|
|
6
|
-
readIndices(opts?:
|
|
7
|
-
protected getView(_scale: number, opts
|
|
11
|
+
readIndicesCache: AbortablePromiseCache<RequestOptions, Index[]>;
|
|
12
|
+
readIndices(opts?: RequestOptions): Promise<Index[]>;
|
|
13
|
+
protected getView(_scale: number, opts?: RequestOptions): Promise<import("./block-view").BlockView>;
|
|
8
14
|
private _readIndices;
|
|
9
15
|
private searchExtraIndexBlocks;
|
|
10
16
|
searchExtraIndex(name: string, opts?: RequestOptions): Promise<Feature[]>;
|
|
11
17
|
}
|
|
18
|
+
export {};
|
package/dist/bigbed.js
CHANGED
|
@@ -8,11 +8,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
+
var t = {};
|
|
13
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
+
t[p] = s[p];
|
|
15
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
+
t[p[i]] = s[p[i]];
|
|
19
|
+
}
|
|
20
|
+
return t;
|
|
21
|
+
};
|
|
11
22
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
23
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
24
|
};
|
|
14
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
26
|
exports.BigBed = exports.filterUndef = void 0;
|
|
27
|
+
const buffer_1 = require("buffer");
|
|
16
28
|
const binary_parser_1 = require("binary-parser");
|
|
17
29
|
const rxjs_1 = require("rxjs");
|
|
18
30
|
const operators_1 = require("rxjs/operators");
|
|
@@ -28,20 +40,15 @@ class BigBed extends bbi_1.BBI {
|
|
|
28
40
|
super(...arguments);
|
|
29
41
|
this.readIndicesCache = new abortable_promise_cache_1.default({
|
|
30
42
|
cache: new quick_lru_1.default({ maxSize: 1 }),
|
|
31
|
-
fill: (args, signal) =>
|
|
32
|
-
return this._readIndices(Object.assign(Object.assign({}, args), { signal }));
|
|
33
|
-
}),
|
|
43
|
+
fill: (args, signal) => this._readIndices(Object.assign(Object.assign({}, args), { signal })),
|
|
34
44
|
});
|
|
35
45
|
}
|
|
36
46
|
readIndices(opts = {}) {
|
|
37
|
-
const
|
|
38
|
-
return this.readIndicesCache.get(JSON.stringify(
|
|
47
|
+
const { signal } = opts, rest = __rest(opts, ["signal"]);
|
|
48
|
+
return this.readIndicesCache.get(JSON.stringify(rest), opts, signal);
|
|
39
49
|
}
|
|
40
50
|
/*
|
|
41
51
|
* retrieve unzoomed view for any scale
|
|
42
|
-
* @param scale - unused
|
|
43
|
-
* @param abortSignal - an optional AbortSignal to kill operation
|
|
44
|
-
* @return promise for a BlockView
|
|
45
52
|
*/
|
|
46
53
|
getView(_scale, opts) {
|
|
47
54
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -56,7 +63,7 @@ class BigBed extends bbi_1.BBI {
|
|
|
56
63
|
_readIndices(opts) {
|
|
57
64
|
return __awaiter(this, void 0, void 0, function* () {
|
|
58
65
|
const { extHeaderOffset, isBigEndian } = yield this.getHeader(opts);
|
|
59
|
-
const { buffer: data } = yield this.bbi.read(Buffer.alloc(64), 0, 64, Number(extHeaderOffset));
|
|
66
|
+
const { buffer: data } = yield this.bbi.read(buffer_1.Buffer.alloc(64), 0, 64, Number(extHeaderOffset));
|
|
60
67
|
const le = isBigEndian ? 'big' : 'little';
|
|
61
68
|
const ret = new binary_parser_1.Parser()
|
|
62
69
|
.endianess(le)
|
|
@@ -71,7 +78,7 @@ class BigBed extends bbi_1.BBI {
|
|
|
71
78
|
}
|
|
72
79
|
const blocklen = 20;
|
|
73
80
|
const len = blocklen * count;
|
|
74
|
-
const { buffer } = yield this.bbi.read(Buffer.alloc(len), 0, len, Number(offset));
|
|
81
|
+
const { buffer } = yield this.bbi.read(buffer_1.Buffer.alloc(len), 0, len, Number(offset));
|
|
75
82
|
const extParser = new binary_parser_1.Parser()
|
|
76
83
|
.endianess(le)
|
|
77
84
|
.int16('type')
|
|
@@ -98,12 +105,12 @@ class BigBed extends bbi_1.BBI {
|
|
|
98
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
99
106
|
const { isBigEndian } = yield this.getHeader(opts);
|
|
100
107
|
const indices = yield this.readIndices(opts);
|
|
101
|
-
if (
|
|
108
|
+
if (indices.length === 0) {
|
|
102
109
|
return [];
|
|
103
110
|
}
|
|
104
111
|
const locs = indices.map((index) => __awaiter(this, void 0, void 0, function* () {
|
|
105
112
|
const { offset, field } = index;
|
|
106
|
-
const { buffer: data } = yield this.bbi.read(Buffer.alloc(32), 0, 32, Number(offset), opts);
|
|
113
|
+
const { buffer: data } = yield this.bbi.read(buffer_1.Buffer.alloc(32), 0, 32, Number(offset), opts);
|
|
107
114
|
const le = isBigEndian ? 'big' : 'little';
|
|
108
115
|
const p = new binary_parser_1.Parser()
|
|
109
116
|
.endianess(le)
|
|
@@ -143,7 +150,7 @@ class BigBed extends bbi_1.BBI {
|
|
|
143
150
|
const bptReadNode = (nodeOffset) => __awaiter(this, void 0, void 0, function* () {
|
|
144
151
|
const val = Number(nodeOffset);
|
|
145
152
|
const len = 4 + blockSize * (keySize + valSize);
|
|
146
|
-
const { buffer } = yield this.bbi.read(Buffer.alloc(len), 0, len, val, opts);
|
|
153
|
+
const { buffer } = yield this.bbi.read(buffer_1.Buffer.alloc(len), 0, len, val, opts);
|
|
147
154
|
const node = bpt.parse(buffer);
|
|
148
155
|
if (node.leafkeys) {
|
|
149
156
|
let lastOffset;
|
|
@@ -180,7 +187,7 @@ class BigBed extends bbi_1.BBI {
|
|
|
180
187
|
searchExtraIndex(name, opts = {}) {
|
|
181
188
|
return __awaiter(this, void 0, void 0, function* () {
|
|
182
189
|
const blocks = yield this.searchExtraIndexBlocks(name, opts);
|
|
183
|
-
if (
|
|
190
|
+
if (blocks.length === 0) {
|
|
184
191
|
return [];
|
|
185
192
|
}
|
|
186
193
|
const view = yield this.getUnzoomedView(opts);
|
|
@@ -188,8 +195,8 @@ class BigBed extends bbi_1.BBI {
|
|
|
188
195
|
return new rxjs_1.Observable(observer => {
|
|
189
196
|
view.readFeatures(observer, [block], opts);
|
|
190
197
|
}).pipe((0, operators_1.reduce)((acc, curr) => acc.concat(curr)), (0, operators_1.map)(x => {
|
|
191
|
-
for (
|
|
192
|
-
|
|
198
|
+
for (const element of x) {
|
|
199
|
+
element.field = block.field;
|
|
193
200
|
}
|
|
194
201
|
return x;
|
|
195
202
|
}));
|
package/dist/bigbed.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bigbed.js","sourceRoot":"","sources":["../src/bigbed.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bigbed.js","sourceRoot":"","sources":["../src/bigbed.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA+B;AAC/B,iDAAsC;AACtC,+BAAwD;AACxD,8CAA4C;AAC5C,sFAA2D;AAC3D,0DAAgC;AAEhC,+BAAoD;AAgBpD,SAAgB,WAAW,CAAI,EAAqB;IAClD,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC,CAAgB,EAAU,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AACrD,CAAC;AAFD,kCAEC;AAED,MAAa,MAAO,SAAQ,SAAG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