@gmod/bbi 1.0.28 → 1.0.32

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 CHANGED
@@ -1,14 +1,30 @@
1
- ## [1.0.28](https://github.com/GMOD/bbi-js/compare/v1.0.27...v1.0.28) (2020-01-28)
1
+ ## [1.0.32](https://github.com/GMOD/bbi-js/compare/v1.0.31...v1.0.32) (2022-02-16)
2
+
3
+
4
+
5
+ - Use pako to decode on command line instead of using zlib to avoid need to
6
+ manually polyfill zlib
7
+
8
+ ## [1.0.31](https://github.com/GMOD/bbi-js/compare/v1.0.30...v1.0.31) (2021-12-14)
9
+
10
+ - Add esm module builds with less babelification for smaller bundle sizes
11
+
12
+ ## [1.0.30](https://github.com/GMOD/bbi-js/compare/v1.0.29...v1.0.30) (2020-06-25)
13
+
14
+ - Use abortable-promise-cache instead of abortable-memoize
15
+ - Allow opts parameter to getHeader instead of just abortsignal
2
16
 
17
+ ## [1.0.29](https://github.com/GMOD/bbi-js/compare/v1.0.28...v1.0.29) (2020-01-28)
3
18
 
19
+ - Accidentally made the package include itself as dependency in 1.0.28, republish
20
+
21
+ ## [1.0.28](https://github.com/GMOD/bbi-js/compare/v1.0.27...v1.0.28) (2020-01-28)
4
22
 
5
23
  - Change typescript interface to use object keys instead of Map type for refsByName, refsById
6
24
  - Typescript only release change
7
25
 
8
26
  ## [1.0.27](https://github.com/GMOD/bbi-js/compare/v1.0.26...v1.0.27) (2020-01-10)
9
27
 
10
-
11
-
12
28
  - Reduce number of requests needed on initial header
13
29
  - Add definedFieldCount to the returned Header
14
30
 
@@ -16,8 +32,6 @@ Thanks to @skinner for both of these contributions!
16
32
 
17
33
  ## [1.0.26](https://github.com/GMOD/bbi-js/compare/v1.0.25...v1.0.26) (2019-11-10)
18
34
 
19
-
20
-
21
35
  - Fix important bug with fixed step bigwig files not using the proper start coordinate
22
36
 
23
37
  ## [1.0.25](https://github.com/GMOD/bbi-js/compare/v1.0.24...v1.0.25) (2019-11-03)
@@ -26,138 +40,97 @@ Thanks to @skinner for both of these contributions!
26
40
 
27
41
  ## [1.0.24](https://github.com/GMOD/bbi-js/compare/v1.0.23...v1.0.24) (2019-10-29)
28
42
 
29
-
30
-
31
43
  - Fix the uniqueIds generated via the bigbed features
32
44
 
33
45
  ## [1.0.23](https://github.com/GMOD/bbi-js/compare/v1.0.22...v1.0.23) (2019-10-06)
34
46
 
35
-
36
47
  - Small refactor of `filehandle.read()` to make it more robust
37
48
 
38
-
39
49
  ## [1.0.22](https://github.com/GMOD/bbi-js/compare/v1.0.21...v1.0.22) (2019-06-13)
40
50
 
41
-
42
-
43
51
  - Bump generic-filehandle
44
52
  - Add more checks for abort signal to allow early bailing
45
53
 
46
54
  ## [1.0.21](https://github.com/GMOD/bbi-js/compare/v1.0.20...v1.0.21) (2019-05-09)
47
55
 
48
-
49
-
50
56
  - Add fix for reading files with greater than 256 contigs
51
57
 
52
58
  ## [1.0.20](https://github.com/GMOD/bbi-js/compare/v1.0.19...v1.0.20) (2019-05-06)
53
59
 
54
-
55
-
56
60
  - Add fix that prevented accessing the lowest zoom/reduction level
57
61
 
58
62
  ## [1.0.19](https://github.com/GMOD/bbi-js/compare/v1.0.18...v1.0.19) (2019-05-02)
59
63
 
60
-
61
-
62
64
  - Add regression fix since 1.0.16 for uncompressed files. Thanks to @lidaof for reporting!
63
65
 
64
66
  ## [1.0.18](https://github.com/GMOD/bbi-js/compare/v1.0.17...v1.0.18) (2019-05-02)
65
67
 
66
-
67
-
68
68
  - Improve error handling of the observables (issue #20, pull #21)
69
69
  - Bump generic-filehandle to 1.0.9 to fix compatibility with native browser fetch
70
70
 
71
71
  ## [1.0.17](https://github.com/GMOD/bbi-js/compare/v1.0.16...v1.0.17) (2019-04-30)
72
72
 
73
-
74
-
75
73
  - Use some standard rxjs notions for combining operator results
76
74
  - Add parsing of the extraIndex data in BigBed, allowing you to call bigbed.searchExtraIndex(name[,opts])
77
75
 
78
76
  ## [1.0.16](https://github.com/GMOD/bbi-js/compare/v1.0.15...v1.0.16) (2019-04-23)
79
77
 
80
-
81
-
82
78
  - Pre-compile binary-parser instances for faster
83
79
  - Important: fixed bug that caused bigwig summary blocks to not be returned in output
84
80
 
85
81
  ## [1.0.15](https://github.com/GMOD/bbi-js/compare/v1.0.14...v1.0.15) (2019-04-18)
86
82
 
87
-
88
-
89
83
  - Make important performance improvement for BigWig data
90
84
 
91
85
  ## [1.0.14](https://github.com/GMOD/bbi-js/compare/v1.0.12...v1.0.14) (2019-04-17)
92
86
 
93
-
94
-
95
87
  - Improve documentation for integration with @gmod/bed@2
96
88
  - Fix some cases where abortSignal was passed incorrectly to filehandle
97
89
 
98
90
  ## [1.0.13](https://github.com/GMOD/bbi-js/compare/v1.0.12...v1.0.13) (2019-04-14)
99
91
 
100
-
101
-
102
92
  - Added uniqueId to objects returned from BigBed to avoid issue with duplicates
103
93
 
104
94
  ## [1.0.12](https://github.com/GMOD/bbi-js/compare/v1.0.11...v1.0.12) (2019-04-12)
105
95
 
106
96
  - Fix returning bigbed objects on empty regions
107
97
 
108
-
109
98
  ## [1.0.11](https://github.com/GMOD/bbi-js/compare/v1.0.10...v1.0.11) (2019-04-10)
110
99
 
111
-
112
-
113
100
  - Removed polyfill of Array.prototype.flat which modifies global scope
114
101
 
115
102
  ## [1.0.10](https://github.com/GMOD/bbi-js/compare/v1.0.9...v1.0.10) (2019-04-09)
116
103
 
117
-
118
-
119
104
  - Fix misinterpretation of variable step wig files in this module (the span is not variable in variable step files, only the step, use bedGraphToBigWig for variable span)
120
105
  - Improved docs
121
106
 
122
107
  ## [1.0.9](https://github.com/GMOD/bbi-js/compare/v1.0.8...v1.0.9) (2019-04-05)
123
108
 
124
-
125
-
126
109
  - Added caching of networking requests (thanks @rbuels for the abortable-promise-cache module!)
127
110
  - Fix some type errors on the range class
128
111
  - Correct using span on fixed size wiggle types
129
112
 
130
113
  ## [1.0.8](https://github.com/GMOD/bbi-js/compare/v1.0.7...v1.0.8) (2019-04-01)
131
114
 
132
-
133
-
134
115
  - Fix @babel/runtime in deployed package
135
116
  - Bugfix to the url argument to the BigWig/BigBed
136
117
 
137
118
  ## [1.0.7](https://github.com/GMOD/bbi-js/compare/v1.0.6...v1.0.7) (2019-04-01)
138
119
 
139
-
140
-
141
120
  - Added getFeatureStream which returns an Observable from rxjs
142
121
  - Added url option to BigWig and BigBed constructors to allow usage of RemoteFile filehandle
143
122
  - Added typescript backend for better processing
144
123
 
145
124
  ## [1.0.6](https://github.com/GMOD/bbi-js/compare/v1.0.5...v1.0.6) (2019-03-15)
146
125
 
147
-
148
-
149
126
  - Fix issue with fixed step and variable step bigwig files not working at all
150
127
 
151
128
  ## [1.0.5](https://github.com/GMOD/bbi-js/compare/v1.0.4...v1.0.5) (2019-03-07)
152
129
 
153
-
154
-
155
130
  - Fix issue with jest being in deps instead of devDeps
156
131
 
157
132
  ## [1.0.4](https://github.com/GMOD/bbi-js/compare/v1.0.3...v1.0.4) (2019-01-28)
158
133
 
159
-
160
-
161
134
  - Add renameRefSeqs functionality where you can apply a callback to the refseq names
162
135
  - Consistently apply start/end coordinate filters at different zoom levels
163
136
 
@@ -167,19 +140,13 @@ Thanks to @skinner for both of these contributions!
167
140
 
168
141
  ## [1.0.2](https://github.com/GMOD/bbi-js/compare/v1.0.1...v1.0.2) (2019-01-24)
169
142
 
170
-
171
-
172
143
  - Added regenerator-runtime to babel dist compilation
173
144
 
174
145
  ## [1.0.1](https://github.com/GMOD/bbi-js/compare/v1.0.0...v1.0.1) (2019-01-24)
175
146
 
176
-
177
-
178
147
  - Added exports for BigWig and BigBed. const {BigWig, BigBed} = require('@gmod/bbi')
179
148
 
180
149
  # 1.0.0 (2019-01-23)
181
150
 
182
-
183
-
184
151
  - Initial version
185
152
  - Has support for bigwig and bigbed files
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
1
  # bbi-js
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/@gmod/bbi.svg?style=flat-square)](https://npmjs.org/package/@gmod/bbi)
4
- [![Build Status](https://img.shields.io/travis/GMOD/bbi-js/master.svg?style=flat-square)](https://travis-ci.org/GMOD/bbi-js) [![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/bbi-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/bbi-js/branch/master)
5
-
4
+ [![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/bbi-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/bbi-js/branch/master)
5
+ [![Build Status](https://img.shields.io/github/workflow/status/GMOD/bbi-js/Push/master?logo=github&style=flat-query)](https://github.com/GMOD/bbi-js/actions?query=branch%3Amaster+workflow%3APush+)
6
6
 
7
7
  A parser for bigwig and bigbed file formats
8
8
 
@@ -11,14 +11,36 @@ A parser for bigwig and bigbed file formats
11
11
  If using locally
12
12
 
13
13
  const {BigWig} = require('@gmod/bbi');
14
- const ti = new BigWig({
14
+ const file = new BigWig({
15
15
  path: 'volvox.bw'
16
16
  });
17
17
  (async () => {
18
- await ti.getHeader();
19
- const feats = await ti.getFeatures('chr1', 0, 100, { scale: 1 });
18
+ await file.getHeader();
19
+ const feats = await file.getFeatures('chr1', 0, 100, { scale: 1 });
20
20
  })();
21
21
 
22
+ If using remotely, you can use it in combination with generic-filehandle or your own implementation of something like generic-filehandle
23
+ https://github.com/GMOD/generic-filehandle/
24
+
25
+ const {BigWig} = require('@gmod/bbi');
26
+ const {RemoteFile} = require('generic-filehandle')
27
+
28
+ // if running in the browser, RemoteFile will use the the global fetch
29
+ const file = new BigWig({
30
+ filehandle: new RemoteFile('volvox.bw')
31
+ });
32
+
33
+
34
+ // if running under node.js you must supply the fetch function to RemoteFile
35
+ const fetch = require('node-fetch')
36
+ const file = new BigWig({
37
+ filehandle: new RemoteFile('volvox.bw', {fetch})
38
+ });
39
+
40
+ (async () => {
41
+ await file.getHeader();
42
+ const feats = await file.getFeatures('chr1', 0, 100, { scale: 1 });
43
+ })();
22
44
 
23
45
  ## Documentation
24
46
 
@@ -26,22 +48,20 @@ If using locally
26
48
 
27
49
  Accepts an object containing either
28
50
 
29
- * path - path to a local file
30
- * url - path to a url
31
- * filehandle - a filehandle instance that you can implement as a custom class yourself. path and url are based on https://www.npmjs.com/package/generic-filehandle but by implementing a class containing the Filehandle interface specified therein, you can pass it to this module
32
-
51
+ - path - path to a local file
52
+ - url - path to a url
53
+ - filehandle - a filehandle instance that you can implement as a custom class yourself. path and url are based on https://www.npmjs.com/package/generic-filehandle but by implementing a class containing the Filehandle interface specified therein, you can pass it to this module
33
54
 
34
55
  ### BigWig
35
56
 
36
57
  #### getFeatures(refName, start, end, opts)
37
58
 
38
- * refName - a name of a chromosome in the file
39
- * start - a 0-based half open start coordinate
40
- * end - a 0-based half open end coordinate
41
- * opts.scale - indicates zoom level to use, specified as pxPerBp, e.g. being zoomed out, you might have 100bp per pixel so opts.scale would be 1/100. the zoom level that is returned is the one which has reductionLevel<=2/opts.scale (reductionLevel is a property of the zoom level structure in the bigwig file data)
42
- * opts.basesPerScale - optional, inverse of opts.scale e.g. bpPerPx
43
- * opts.signal - optional, an AbortSignal to halt processing
44
-
59
+ - refName - a name of a chromosome in the file
60
+ - start - a 0-based half open start coordinate
61
+ - end - a 0-based half open end coordinate
62
+ - opts.scale - indicates zoom level to use, specified as pxPerBp, e.g. being zoomed out, you might have 100bp per pixel so opts.scale would be 1/100. the zoom level that is returned is the one which has reductionLevel<=2/opts.scale (reductionLevel is a property of the zoom level structure in the bigwig file data)
63
+ - opts.basesPerScale - optional, inverse of opts.scale e.g. bpPerPx
64
+ - opts.signal - optional, an AbortSignal to halt processing
45
65
 
46
66
  Returns a promise to an array of features. If an incorrect refName or no features are found the result is an empty array.
47
67
 
@@ -53,10 +73,9 @@ Example:
53
73
  // no conversion to 1-based as in wig is done)
54
74
  // note refseq is not returned on the object, it is clearly chr1 from the query though
55
75
 
56
-
57
76
  ### Understanding scale and reductionLevel
58
77
 
59
- Here is what the reductionLevel structure looks like in a file. The zoomLevel that is chosen is the first reductionLevel<2*opts.basesPerScale (or reductionLevel<2/opts.scale) when scanning backwards through this list
78
+ Here is what the reductionLevel structure looks like in a file. The zoomLevel that is chosen is the first reductionLevel<2\*opts.basesPerScale (or reductionLevel<2/opts.scale) when scanning backwards through this list
60
79
 
61
80
  [ { reductionLevel: 40, ... },
62
81
  { reductionLevel: 160, ... },
@@ -66,7 +85,6 @@ Here is what the reductionLevel structure looks like in a file. The zoomLevel th
66
85
  { reductionLevel: 40960, ... },
67
86
  { reductionLevel: 163840, ... } ]
68
87
 
69
-
70
88
  #### getFeatureStream(refName, start, end, opts)
71
89
 
72
90
  Same as getFeatures but returns an RxJS observable stream, useful for very large queries
@@ -84,10 +102,10 @@ Same as getFeatures but returns an RxJS observable stream, useful for very large
84
102
 
85
103
  #### getFeatures(refName, start, end, opts)
86
104
 
87
- * refName - a name of a chromosome in the file
88
- * start - a 0-based half open start coordinate
89
- * end - a 0-based half open end coordinate
90
- * opts.signal - optional, an AbortSignal to halt processing
105
+ - refName - a name of a chromosome in the file
106
+ - start - a 0-based half open start coordinate
107
+ - end - a 0-based half open end coordinate
108
+ - opts.signal - optional, an AbortSignal to halt processing
91
109
 
92
110
  returns a promise to an array of features. no concept of zoom levels is used with bigwig data
93
111
 
@@ -108,8 +126,7 @@ Returns a Promise to an array of Features, with an extra field indicating the fi
108
126
 
109
127
  ### How to parse BigBed results
110
128
 
111
- The BigBed line contents are returned as a raw text line e.g. {start: 0, end:100, rest: "ENST00000456328.2\t1000\t..."} where "rest" contains tab delimited text for the fields from 4 and on in the BED format. Since BED files from BigBed format often come with autoSql (a description of all the columns) it can be useful to parse it with BED parser that can handle autoSql. The rest line can be parsed by the @gmod/bed module, which is not by default integrated with this module, but can be combined with it as follows
112
-
129
+ The BigBed line contents are returned as a raw text line e.g. {start: 0, end:100, rest: "ENST00000456328.2\t1000\t..."} where "rest" contains tab delimited text for the fields from 4 and on in the BED format. Since BED files from BigBed format often come with autoSql (a description of all the columns) it can be useful to parse it with BED parser that can handle autoSql. The rest line can be parsed by the @gmod/bed module, which is not by default integrated with this module, but can be combined with it as follows
113
130
 
114
131
  ```js
115
132
  import {BigBed} from '@gmod/bbi'
@@ -156,7 +173,6 @@ Features after parsing with @gmod/bed:
156
173
  spID: 'AL137655' }
157
174
  ```
158
175
 
159
-
160
176
  ## Academic Use
161
177
 
162
178
  This package was written with funding from the [NHGRI](http://genome.gov) as part of the [JBrowse](http://jbrowse.org) project. If you use it in an academic project that you publish, please cite the most recent JBrowse paper, which will be linked from [jbrowse.org](http://jbrowse.org).
@@ -164,4 +180,3 @@ This package was written with funding from the [NHGRI](http://genome.gov) as par
164
180
  ## License
165
181
 
166
182
  MIT © [Colin Diesh](https://github.com/cmdcolin)
167
-
package/dist/bbi.d.ts CHANGED
@@ -42,15 +42,16 @@ export interface Header {
42
42
  [key: number]: RefInfo;
43
43
  };
44
44
  }
45
- declare class AbortAwareCache {
46
- private cache;
47
- abortableMemoize(fn: (signal?: AbortSignal) => Promise<any>): (signal?: AbortSignal) => Promise<any>;
45
+ export interface RequestOptions {
46
+ signal?: AbortSignal;
47
+ headers?: Record<string, string>;
48
+ [key: string]: unknown;
48
49
  }
49
50
  export declare abstract class BBI {
50
51
  protected bbi: GenericFilehandle;
51
- protected headerCache: AbortAwareCache;
52
+ protected headerCache: any;
52
53
  protected renameRefSeqs: (a: string) => string;
53
- getHeader: (abortSignal?: AbortSignal) => Promise<Header>;
54
+ getHeader(opts?: RequestOptions | AbortSignal): any;
54
55
  constructor(options?: {
55
56
  filehandle?: GenericFilehandle;
56
57
  path?: string;
@@ -61,8 +62,8 @@ export declare abstract class BBI {
61
62
  private _getMainHeader;
62
63
  private _isBigEndian;
63
64
  private _readChromTree;
64
- protected getUnzoomedView(abortSignal?: AbortSignal): Promise<BlockView>;
65
- protected abstract getView(scale: number, abortSignal?: AbortSignal): Promise<BlockView>;
65
+ protected getUnzoomedView(opts: RequestOptions): Promise<BlockView>;
66
+ protected abstract getView(scale: number, opts: RequestOptions): Promise<BlockView>;
66
67
  /**
67
68
  * Gets features from a BigWig file
68
69
  *
@@ -71,15 +72,13 @@ export declare abstract class BBI {
71
72
  * @param end - The end of a region
72
73
  * @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use
73
74
  */
74
- getFeatureStream(refName: string, start: number, end: number, opts?: {
75
- basesPerSpan?: number;
75
+ getFeatureStream(refName: string, start: number, end: number, opts?: RequestOptions & {
76
76
  scale?: number;
77
- signal?: AbortSignal;
78
- }): Promise<Observable<Feature[]>>;
79
- getFeatures(refName: string, start: number, end: number, opts?: {
80
77
  basesPerSpan?: number;
78
+ }): Promise<Observable<Feature[]>>;
79
+ getFeatures(refName: string, start: number, end: number, opts?: RequestOptions & {
81
80
  scale?: number;
82
- signal?: AbortSignal;
81
+ basesPerSpan?: number;
83
82
  }): Promise<Feature[]>;
84
83
  }
85
84
  export {};