@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 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
  [![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
@@ -35,18 +35,23 @@ export interface Header {
35
35
  extHeaderOffset: number;
36
36
  isBigEndian: boolean;
37
37
  fileType: string;
38
- refsByName: Map<string, number>;
39
- refsByNumber: Map<number, RefInfo>;
38
+ refsByName: {
39
+ [key: string]: number;
40
+ };
41
+ refsByNumber: {
42
+ [key: number]: RefInfo;
43
+ };
40
44
  }
41
- declare class AbortAwareCache {
42
- private cache;
43
- 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;
44
49
  }
45
50
  export declare abstract class BBI {
46
51
  protected bbi: GenericFilehandle;
47
- protected headerCache: AbortAwareCache;
52
+ protected headerCache: any;
48
53
  protected renameRefSeqs: (a: string) => string;
49
- getHeader: (abortSignal?: AbortSignal) => Promise<Header>;
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(abortSignal?: AbortSignal): Promise<BlockView>;
61
- 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>;
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
- signal?: AbortSignal;
81
+ basesPerSpan?: number;
79
82
  }): Promise<Feature[]>;
80
83
  }
81
84
  export {};