@gmod/bbi 1.0.27 → 1.0.31
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 +27 -0
- package/README.md +42 -27
- package/dist/bbi.d.ts +18 -15
- package/dist/bbi.js +361 -593
- package/dist/bigbed.d.ts +7 -16
- package/dist/bigbed.js +285 -455
- package/dist/bigwig.d.ts +2 -2
- package/dist/bigwig.js +88 -110
- package/dist/blockView.d.ts +2 -1
- package/dist/blockView.js +404 -508
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -35
- package/dist/range.js +115 -178
- package/dist/util.js +110 -114
- package/esm/bbi.d.ts +84 -0
- package/esm/bbi.js +259 -0
- package/esm/bigbed.d.ts +12 -0
- package/esm/bigbed.js +182 -0
- package/esm/bigwig.d.ts +13 -0
- package/esm/bigwig.js +35 -0
- package/esm/blockView.d.ts +42 -0
- package/esm/blockView.js +323 -0
- package/esm/index.d.ts +3 -0
- package/esm/index.js +7 -0
- package/esm/range.d.ts +18 -0
- package/esm/range.js +126 -0
- package/esm/util.d.ts +24 -0
- package/esm/util.js +74 -0
- package/package.json +17 -27
- package/dist/declares.d.js +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
## [1.0.31](https://github.com/GMOD/bbi-js/compare/v1.0.30...v1.0.31) (2021-12-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
- Add esm module builds with less babelification for smaller bundle sizes
|
|
6
|
+
|
|
7
|
+
## [1.0.30](https://github.com/GMOD/bbi-js/compare/v1.0.29...v1.0.30) (2020-06-25)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
- Use abortable-promise-cache instead of abortable-memoize
|
|
12
|
+
- Allow opts parameter to getHeader instead of just abortsignal
|
|
13
|
+
|
|
14
|
+
## [1.0.29](https://github.com/GMOD/bbi-js/compare/v1.0.28...v1.0.29) (2020-01-28)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
- Accidentally made the package include itself as dependency in 1.0.28, republish
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## [1.0.28](https://github.com/GMOD/bbi-js/compare/v1.0.27...v1.0.28) (2020-01-28)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
- Change typescript interface to use object keys instead of Map type for refsByName, refsById
|
|
26
|
+
- Typescript only release change
|
|
27
|
+
|
|
1
28
|
## [1.0.27](https://github.com/GMOD/bbi-js/compare/v1.0.26...v1.0.27) (2020-01-10)
|
|
2
29
|
|
|
3
30
|
|
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# bbi-js
|
|
2
2
|
|
|
3
3
|
[](https://npmjs.org/package/@gmod/bbi)
|
|
4
|
-
[](https://codecov.io/gh/GMOD/bbi-js/branch/master)
|
|
5
|
+
[](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
|
|
14
|
+
const file = new BigWig({
|
|
15
15
|
path: 'volvox.bw'
|
|
16
16
|
});
|
|
17
17
|
(async () => {
|
|
18
|
-
await
|
|
19
|
-
const feats = await
|
|
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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
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
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
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.
|
|
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
|
@@ -35,18 +35,23 @@ export interface Header {
|
|
|
35
35
|
extHeaderOffset: number;
|
|
36
36
|
isBigEndian: boolean;
|
|
37
37
|
fileType: string;
|
|
38
|
-
refsByName:
|
|
39
|
-
|
|
38
|
+
refsByName: {
|
|
39
|
+
[key: string]: number;
|
|
40
|
+
};
|
|
41
|
+
refsByNumber: {
|
|
42
|
+
[key: number]: RefInfo;
|
|
43
|
+
};
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
export interface RequestOptions {
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
headers?: Record<string, string>;
|
|
48
|
+
[key: string]: unknown;
|
|
44
49
|
}
|
|
45
50
|
export declare abstract class BBI {
|
|
46
51
|
protected bbi: GenericFilehandle;
|
|
47
|
-
protected headerCache:
|
|
52
|
+
protected headerCache: any;
|
|
48
53
|
protected renameRefSeqs: (a: string) => string;
|
|
49
|
-
getHeader
|
|
54
|
+
getHeader(opts?: RequestOptions | AbortSignal): any;
|
|
50
55
|
constructor(options?: {
|
|
51
56
|
filehandle?: GenericFilehandle;
|
|
52
57
|
path?: string;
|
|
@@ -57,8 +62,8 @@ export declare abstract class BBI {
|
|
|
57
62
|
private _getMainHeader;
|
|
58
63
|
private _isBigEndian;
|
|
59
64
|
private _readChromTree;
|
|
60
|
-
protected getUnzoomedView(
|
|
61
|
-
protected abstract getView(scale: number,
|
|
65
|
+
protected getUnzoomedView(opts: RequestOptions): Promise<BlockView>;
|
|
66
|
+
protected abstract getView(scale: number, opts: RequestOptions): Promise<BlockView>;
|
|
62
67
|
/**
|
|
63
68
|
* Gets features from a BigWig file
|
|
64
69
|
*
|
|
@@ -67,15 +72,13 @@ export declare abstract class BBI {
|
|
|
67
72
|
* @param end - The end of a region
|
|
68
73
|
* @param opts - An object containing basesPerSpan (e.g. pixels per basepair) or scale used to infer the zoomLevel to use
|
|
69
74
|
*/
|
|
70
|
-
getFeatureStream(refName: string, start: number, end: number, opts?: {
|
|
71
|
-
basesPerSpan?: number;
|
|
75
|
+
getFeatureStream(refName: string, start: number, end: number, opts?: RequestOptions & {
|
|
72
76
|
scale?: number;
|
|
73
|
-
signal?: AbortSignal;
|
|
74
|
-
}): Promise<Observable<Feature[]>>;
|
|
75
|
-
getFeatures(refName: string, start: number, end: number, opts?: {
|
|
76
77
|
basesPerSpan?: number;
|
|
78
|
+
}): Promise<Observable<Feature[]>>;
|
|
79
|
+
getFeatures(refName: string, start: number, end: number, opts?: RequestOptions & {
|
|
77
80
|
scale?: number;
|
|
78
|
-
|
|
81
|
+
basesPerSpan?: number;
|
|
79
82
|
}): Promise<Feature[]>;
|
|
80
83
|
}
|
|
81
84
|
export {};
|