@gmod/tabix 1.5.4 → 1.5.6

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,15 @@
1
+ ## [1.5.6](https://github.com/GMOD/tabix-js/compare/v1.5.5...v1.5.6) (2023-02-28)
2
+
3
+
4
+
5
+ - Add fix for fileOffset being stable in presence of Unicode characters (#137)
6
+
7
+ ## [1.5.5](https://github.com/GMOD/tabix-js/compare/v1.5.4...v1.5.5) (2022-12-17)
8
+
9
+
10
+
11
+ - Use es2015 for nodejs build
12
+
1
13
  ## [1.5.4](https://github.com/GMOD/tabix-js/compare/v1.5.3...v1.5.4) (2022-07-18)
2
14
 
3
15
 
package/README.md CHANGED
@@ -2,9 +2,7 @@
2
2
 
3
3
  [![NPM version](https://img.shields.io/npm/v/@gmod/tabix.svg?style=flat-square)](https://npmjs.org/package/@gmod/tabix)
4
4
  [![Coverage Status](https://img.shields.io/codecov/c/github/GMOD/tabix-js/master.svg?style=flat-square)](https://codecov.io/gh/GMOD/tabix-js/branch/master)
5
- [![Build Status](https://img.shields.io/github/workflow/status/GMOD/tabix-js/Push/master?logo=github&style=flat-query)](https://github.com/GMOD/tabix-js/actions?query=branch%3Amaster+workflow%3APush+)
6
-
7
-
5
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/GMOD/tabix-js/push.yml?branch=master)](https://github.com/GMOD/tabix-js/actions)
8
6
 
9
7
  Read Tabix-indexed files using either .tbi or .csi indexes.
10
8
 
@@ -14,23 +12,21 @@ Read Tabix-indexed files using either .tbi or .csi indexes.
14
12
 
15
13
  ## Usage
16
14
 
17
-
18
15
  ### Importing the module
19
16
 
20
17
  ```js
21
-
22
18
  // import with require in node.js
23
- const {TabixIndexedFile} = require('@gmod/tabix')
19
+ const { TabixIndexedFile } = require('@gmod/tabix')
24
20
 
25
21
  // or with es6 imports, this will also give typescript types
26
- import {TabixIndexedFile} from '@gmod/tabix'
22
+ import { TabixIndexedFile } from '@gmod/tabix'
27
23
  ```
28
24
 
29
-
30
25
  ### TabixIndexedFile constructor
31
26
 
32
-
33
- Basic usage of TabixIndexedFile under node.js supplies a path and optionally a tbiPath to the constructor. If no tbiPath is supplied, it assumes that the path+'.tbi' is the location of the tbiPath.
27
+ Basic usage of TabixIndexedFile under node.js supplies a path and optionally a
28
+ tbiPath to the constructor. If no tbiPath is supplied, it assumes that the
29
+ path+'.tbi' is the location of the tbiPath.
34
30
 
35
31
  ```
36
32
  // basic usage under node.js provides a file path on the filesystem to bgzipped file
@@ -42,7 +38,10 @@ const tbiIndexed = new TabixIndexedFile({
42
38
 
43
39
  ```
44
40
 
45
- You can also use CSI indexes. Note also the usage of the renameRefSeqs callback. The renameRefSeqs callback makes it so that you can use file.getLines('1',0,100,...) even when the file itself contains names like 'chr1' (can also do the reverse by customizing the renameRefSeqs callback)
41
+ You can also use CSI indexes. Note also the usage of the renameRefSeqs callback.
42
+ The renameRefSeqs callback makes it so that you can use
43
+ file.getLines('1',0,100,...) even when the file itself contains names like
44
+ 'chr1' (can also do the reverse by customizing the renameRefSeqs callback)
46
45
 
47
46
  ```
48
47
  // can also open tabix files that have a .csi index
@@ -56,9 +55,9 @@ const csiIndexed = new TabixIndexedFile({
56
55
 
57
56
  #### TabixIndexedFile constructor with remote files
58
57
 
59
-
60
- The basic usage of fetching remote files is done by supplying a [generic-filehandle](https://github.com/GMOD/generic-filehandle) module RemoteFile filehandle, as seen below
61
-
58
+ The basic usage of fetching remote files is done by supplying a
59
+ [generic-filehandle](https://github.com/GMOD/generic-filehandle) module
60
+ RemoteFile filehandle, as seen below
62
61
 
63
62
  ```
64
63
  // use a remote file or other filehandle, note RemoteFile comes from https://github.com/GMOD/generic-filehandle
@@ -69,9 +68,9 @@ const remoteTbiIndexed = new TabixIndexedFile({
69
68
  })
70
69
  ```
71
70
 
72
-
73
- This works in both the browser and in node.js, but note that in node.js you have to also supply a custom fetch function to the RemoteFile constructor e.g. like this
74
-
71
+ This works in both the browser and in node.js, but note that in node.js you have
72
+ to also supply a custom fetch function to the RemoteFile constructor e.g. like
73
+ this
75
74
 
76
75
  ```
77
76
  // for node.js you have to manually supply a fetch function e.g. node-fetch to RemoteFile
@@ -82,15 +81,15 @@ const remoteTbiIndexedForNodeJs = new TabixIndexedFile({
82
81
  })
83
82
  ```
84
83
 
85
-
86
84
  ### getLines
87
85
 
86
+ The basic function this module provides is just called `getLines` and it returns
87
+ text contents from the tabix file (it unzips the bgzipped data) and supplies it
88
+ to a callback that you provide one line at a time.
88
89
 
89
- The basic function this module provides is just called `getLines` and it returns text contents from the tabix file (it unzips the bgzipped data) and supplies it to a callback that you provide one line at a time.
90
-
91
-
92
- Important: the `start` and `end` values that are supplied to `getLines` are 0-based half-open coordinates. This is different from the 1-based values that are supplied to the tabix command line tool
93
-
90
+ Important: the `start` and `end` values that are supplied to `getLines` are
91
+ 0-based half-open coordinates. This is different from the 1-based values that
92
+ are supplied to the tabix command line tool
94
93
 
95
94
  ```
96
95
  // iterate over lines in the specified region
@@ -101,11 +100,11 @@ await tbiIndexed.getLines('ctgA',200,300, function(line, fileOffset) {
101
100
 
102
101
  ```
103
102
 
104
- After running this, your `lines` array would contain an array of lines from the file that match your query range
105
-
106
-
107
- You can also supply some extra arguments to getLines with this format, but these are sort of obscure and only used in some circumstances
103
+ After running this, your `lines` array would contain an array of lines from the
104
+ file that match your query range
108
105
 
106
+ You can also supply some extra arguments to getLines with this format, but these
107
+ are sort of obscure and only used in some circumstances
109
108
 
110
109
  ```
111
110
  const lines = []
@@ -117,14 +116,18 @@ await tbiIndexed.getLines('ctgA',200,300, {
117
116
 
118
117
  ```
119
118
 
120
- After running the above demo, lines is now an array of strings, containing the lines from the tabix file
119
+ After running the above demo, lines is now an array of strings, containing the
120
+ lines from the tabix file
121
121
 
122
122
  Notes about the returned values of `getLines`:
123
123
 
124
124
  - commented (meta) lines are skipped.
125
125
  - line strings do not include any trailing whitespace characters.
126
- - the callback is also called with a `fileOffset` that can be used to uniquely identify lines based on their virtual file offset where the line is found in the file
127
- - if getLines is called with an undefined `end` parameter it gets all lines from start going to the end of the contig e.g.
126
+ - the callback is also called with a `fileOffset` that can be used to uniquely
127
+ identify lines based on their virtual file offset where the line is found in
128
+ the file
129
+ - if getLines is called with an undefined `end` parameter it gets all lines from
130
+ start going to the end of the contig e.g.
128
131
 
129
132
  ```
130
133
  const lines = []
@@ -132,12 +135,8 @@ await tbiIndexed.getLines('ctgA', 0, undefined, line=>lines.push(line))`
132
135
  console.log(lines)
133
136
  ```
134
137
 
135
-
136
-
137
-
138
138
  ### lineCount
139
139
 
140
-
141
140
  ```
142
141
  // get the approximate number of data lines in the
143
142
  // file for the given reference sequence, excluding header, comment, and whitespace lines
@@ -147,7 +146,6 @@ const numLines = await tbiIndexed.lineCount('ctgA')
147
146
 
148
147
  ```
149
148
 
150
-
151
149
  ### getHeader
152
150
 
153
151
  ```
@@ -165,10 +163,12 @@ const headerBuffer = await tbiIndexed.getHeaderBuffer()
165
163
  // or const headerBuffer = await tbiIndexed.getHeaderBuffer({ signal: aborter.signal })
166
164
  ```
167
165
 
168
-
169
166
  ## Academic Use
170
167
 
171
- 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).
168
+ This package was written with funding from the [NHGRI](http://genome.gov) as
169
+ part of the [JBrowse](http://jbrowse.org) project. If you use it in an academic
170
+ project that you publish, please cite the most recent JBrowse paper, which will
171
+ be linked from [jbrowse.org](http://jbrowse.org).
172
172
 
173
173
  ## License
174
174
 
package/dist/chunk.js CHANGED
@@ -1,38 +1,36 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // little class representing a chunk in the index
4
- var Chunk = /** @class */ (function () {
4
+ class Chunk {
5
5
  /**
6
6
  * @param {VirtualOffset} minv
7
7
  * @param {VirtualOffset} maxv
8
8
  * @param {number} bin
9
9
  * @param {number} [fetchedSize]
10
10
  */
11
- function Chunk(minv, maxv, bin, fetchedSize) {
12
- if (fetchedSize === void 0) { fetchedSize = undefined; }
11
+ constructor(minv, maxv, bin, fetchedSize = undefined) {
13
12
  this.minv = minv;
14
13
  this.maxv = maxv;
15
14
  this.bin = bin;
16
15
  this._fetchedSize = fetchedSize;
17
16
  }
18
- Chunk.prototype.toUniqueString = function () {
19
- return "".concat(this.minv, "..").concat(this.maxv, " (bin ").concat(this.bin, ", fetchedSize ").concat(this.fetchedSize(), ")");
20
- };
21
- Chunk.prototype.toString = function () {
17
+ toUniqueString() {
18
+ return `${this.minv}..${this.maxv} (bin ${this.bin}, fetchedSize ${this.fetchedSize()})`;
19
+ }
20
+ toString() {
22
21
  return this.toUniqueString();
23
- };
24
- Chunk.prototype.compareTo = function (b) {
22
+ }
23
+ compareTo(b) {
25
24
  return (this.minv.compareTo(b.minv) ||
26
25
  this.maxv.compareTo(b.maxv) ||
27
26
  this.bin - b.bin);
28
- };
29
- Chunk.prototype.fetchedSize = function () {
27
+ }
28
+ fetchedSize() {
30
29
  if (this._fetchedSize !== undefined) {
31
30
  return this._fetchedSize;
32
31
  }
33
32
  return this.maxv.blockPosition + (1 << 16) - this.minv.blockPosition;
34
- };
35
- return Chunk;
36
- }());
33
+ }
34
+ }
37
35
  exports.default = Chunk;
38
36
  //# sourceMappingURL=chunk.js.map
package/dist/chunk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"chunk.js","sourceRoot":"","sources":["../src/chunk.ts"],"names":[],"mappings":";;AAEA,iDAAiD;AACjD;IAME;;;;;OAKG;IACH,eACE,IAAmB,EACnB,IAAmB,EACnB,GAAW,EACX,WAAuB;QAAvB,4BAAA,EAAA,uBAAuB;QAEvB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CA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