@gmod/tabix 1.5.7 → 1.5.8
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 +5 -1
- package/README.md +19 -22
- package/dist/tabixIndexedFile.d.ts +1 -1
- package/esm/tabixIndexedFile.d.ts +1 -1
- package/package.json +1 -1
- package/src/tabixIndexedFile.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
## [1.5.
|
|
1
|
+
## [1.5.8](https://github.com/GMOD/tabix-js/compare/v1.5.7...v1.5.8) (2023-03-24)
|
|
2
|
+
|
|
2
3
|
|
|
3
4
|
|
|
5
|
+
- Make yieldTime optional
|
|
6
|
+
|
|
7
|
+
## [1.5.7](https://github.com/GMOD/tabix-js/compare/v1.5.6...v1.5.7) (2023-03-24)
|
|
4
8
|
|
|
5
9
|
- Add yieldTime parameter
|
|
6
10
|
- Improve typescripting
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Read Tabix-indexed files using either .tbi or .csi indexes.
|
|
|
14
14
|
|
|
15
15
|
### Importing the module
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```typescript
|
|
18
18
|
// import with require in node.js
|
|
19
19
|
const { TabixIndexedFile } = require('@gmod/tabix')
|
|
20
20
|
|
|
@@ -28,7 +28,7 @@ Basic usage of TabixIndexedFile under node.js supplies a path and optionally a
|
|
|
28
28
|
tbiPath to the constructor. If no tbiPath is supplied, it assumes that the
|
|
29
29
|
path+'.tbi' is the location of the tbiPath.
|
|
30
30
|
|
|
31
|
-
```
|
|
31
|
+
```typescript
|
|
32
32
|
// basic usage under node.js provides a file path on the filesystem to bgzipped file
|
|
33
33
|
// it assumes the tbi file is path+'.tbi' if no tbiPath is supplied
|
|
34
34
|
const tbiIndexed = new TabixIndexedFile({
|
|
@@ -43,7 +43,7 @@ The renameRefSeqs callback makes it so that you can use
|
|
|
43
43
|
file.getLines('1',0,100,...) even when the file itself contains names like
|
|
44
44
|
'chr1' (can also do the reverse by customizing the renameRefSeqs callback)
|
|
45
45
|
|
|
46
|
-
```
|
|
46
|
+
```typescript
|
|
47
47
|
// can also open tabix files that have a .csi index
|
|
48
48
|
// note also usage of renameRefSeqs callback to trim chr off the chr names
|
|
49
49
|
const csiIndexed = new TabixIndexedFile({
|
|
@@ -59,12 +59,12 @@ The basic usage of fetching remote files is done by supplying a
|
|
|
59
59
|
[generic-filehandle](https://github.com/GMOD/generic-filehandle) module
|
|
60
60
|
RemoteFile filehandle, as seen below
|
|
61
61
|
|
|
62
|
-
```
|
|
62
|
+
```typescript
|
|
63
63
|
// use a remote file or other filehandle, note RemoteFile comes from https://github.com/GMOD/generic-filehandle
|
|
64
|
-
const {RemoteFile} = require('generic-filehandle')
|
|
64
|
+
const { RemoteFile } = require('generic-filehandle')
|
|
65
65
|
const remoteTbiIndexed = new TabixIndexedFile({
|
|
66
66
|
filehandle: new RemoteFile('http://yourhost/file.vcf.gz'),
|
|
67
|
-
tbiFilehandle: new RemoteFile('http://yourhost/file.vcf.gz.tbi') // can also be csiFilehandle
|
|
67
|
+
tbiFilehandle: new RemoteFile('http://yourhost/file.vcf.gz.tbi'), // can also be csiFilehandle
|
|
68
68
|
})
|
|
69
69
|
```
|
|
70
70
|
|
|
@@ -72,12 +72,12 @@ This works in both the browser and in node.js, but note that in node.js you have
|
|
|
72
72
|
to also supply a custom fetch function to the RemoteFile constructor e.g. like
|
|
73
73
|
this
|
|
74
74
|
|
|
75
|
-
```
|
|
75
|
+
```typescript
|
|
76
76
|
// for node.js you have to manually supply a fetch function e.g. node-fetch to RemoteFile
|
|
77
77
|
const fetch = require('node-fetch')
|
|
78
78
|
const remoteTbiIndexedForNodeJs = new TabixIndexedFile({
|
|
79
|
-
filehandle: new RemoteFile('http://yourhost/file.vcf.gz', {fetch}),
|
|
80
|
-
tbiFilehandle: new RemoteFile('http://yourhost/file.vcf.gz.tbi', {fetch}) // can also be csiFilehandle
|
|
79
|
+
filehandle: new RemoteFile('http://yourhost/file.vcf.gz', { fetch }),
|
|
80
|
+
tbiFilehandle: new RemoteFile('http://yourhost/file.vcf.gz.tbi', { fetch }), // can also be csiFilehandle
|
|
81
81
|
})
|
|
82
82
|
```
|
|
83
83
|
|
|
@@ -91,13 +91,12 @@ Important: the `start` and `end` values that are supplied to `getLines` are
|
|
|
91
91
|
0-based half-open coordinates. This is different from the 1-based values that
|
|
92
92
|
are supplied to the tabix command line tool
|
|
93
93
|
|
|
94
|
-
```
|
|
94
|
+
```typescript
|
|
95
95
|
// iterate over lines in the specified region
|
|
96
96
|
const lines = []
|
|
97
|
-
await tbiIndexed.getLines('ctgA',200,300, function(line, fileOffset) {
|
|
98
|
-
|
|
97
|
+
await tbiIndexed.getLines('ctgA', 200, 300, function (line, fileOffset) {
|
|
98
|
+
lines.push(line)
|
|
99
99
|
})
|
|
100
|
-
|
|
101
100
|
```
|
|
102
101
|
|
|
103
102
|
After running this, your `lines` array would contain an array of lines from the
|
|
@@ -106,14 +105,13 @@ file that match your query range
|
|
|
106
105
|
You can also supply some extra arguments to getLines with this format, but these
|
|
107
106
|
are sort of obscure and only used in some circumstances
|
|
108
107
|
|
|
109
|
-
```
|
|
108
|
+
```typescript
|
|
110
109
|
const lines = []
|
|
111
110
|
const aborter = new AbortController()
|
|
112
|
-
await tbiIndexed.getLines('ctgA',200,300, {
|
|
111
|
+
await tbiIndexed.getLines('ctgA', 200, 300, {
|
|
113
112
|
lineCallback: (line, fileOffset) => lines.push(line),
|
|
114
|
-
signal: aborter.signal // an optional AbortSignal from an AbortController
|
|
113
|
+
signal: aborter.signal, // an optional AbortSignal from an AbortController
|
|
115
114
|
})
|
|
116
|
-
|
|
117
115
|
```
|
|
118
116
|
|
|
119
117
|
After running the above demo, lines is now an array of strings, containing the
|
|
@@ -129,7 +127,7 @@ Notes about the returned values of `getLines`:
|
|
|
129
127
|
- if getLines is called with an undefined `end` parameter it gets all lines from
|
|
130
128
|
start going to the end of the contig e.g.
|
|
131
129
|
|
|
132
|
-
```
|
|
130
|
+
```typescript
|
|
133
131
|
const lines = []
|
|
134
132
|
await tbiIndexed.getLines('ctgA', 0, undefined, line=>lines.push(line))`
|
|
135
133
|
console.log(lines)
|
|
@@ -137,18 +135,17 @@ console.log(lines)
|
|
|
137
135
|
|
|
138
136
|
### lineCount
|
|
139
137
|
|
|
140
|
-
```
|
|
138
|
+
```typescript
|
|
141
139
|
// get the approximate number of data lines in the
|
|
142
140
|
// file for the given reference sequence, excluding header, comment, and whitespace lines
|
|
143
141
|
// uses the extra bin from tabix
|
|
144
142
|
const numLines = await tbiIndexed.lineCount('ctgA')
|
|
145
143
|
// or const numLines = await tbiIndexed.lineCount('ctgA', { signal: aborter.signal })
|
|
146
|
-
|
|
147
144
|
```
|
|
148
145
|
|
|
149
146
|
### getHeader
|
|
150
147
|
|
|
151
|
-
```
|
|
148
|
+
```typescript
|
|
152
149
|
// get the "header text" string from the file, which is the first contiguous
|
|
153
150
|
// set of lines in the file that all start with a "meta" character (usually #)
|
|
154
151
|
const headerText = await tbiIndexed.getHeader()
|
|
@@ -157,7 +154,7 @@ const headerText = await tbiIndexed.getHeader()
|
|
|
157
154
|
|
|
158
155
|
#### getHeaderBuffer
|
|
159
156
|
|
|
160
|
-
```
|
|
157
|
+
```typescript
|
|
161
158
|
// or if you want a nodejs Buffer object instead, there is getHeaderBuffer()
|
|
162
159
|
const headerBuffer = await tbiIndexed.getHeaderBuffer()
|
|
163
160
|
// or const headerBuffer = await tbiIndexed.getHeaderBuffer({ signal: aborter.signal })
|
|
@@ -35,7 +35,7 @@ export default class TabixIndexedFile {
|
|
|
35
35
|
tbiFilehandle?: GenericFilehandle;
|
|
36
36
|
csiPath?: string;
|
|
37
37
|
csiFilehandle?: GenericFilehandle;
|
|
38
|
-
yieldTime
|
|
38
|
+
yieldTime?: number;
|
|
39
39
|
chunkSizeLimit?: number;
|
|
40
40
|
renameRefSeqs?: (n: string) => string;
|
|
41
41
|
chunkCacheSize?: number;
|
|
@@ -35,7 +35,7 @@ export default class TabixIndexedFile {
|
|
|
35
35
|
tbiFilehandle?: GenericFilehandle;
|
|
36
36
|
csiPath?: string;
|
|
37
37
|
csiFilehandle?: GenericFilehandle;
|
|
38
|
-
yieldTime
|
|
38
|
+
yieldTime?: number;
|
|
39
39
|
chunkSizeLimit?: number;
|
|
40
40
|
renameRefSeqs?: (n: string) => string;
|
|
41
41
|
chunkCacheSize?: number;
|
package/package.json
CHANGED
package/src/tabixIndexedFile.ts
CHANGED
|
@@ -68,7 +68,7 @@ export default class TabixIndexedFile {
|
|
|
68
68
|
tbiFilehandle?: GenericFilehandle
|
|
69
69
|
csiPath?: string
|
|
70
70
|
csiFilehandle?: GenericFilehandle
|
|
71
|
-
yieldTime
|
|
71
|
+
yieldTime?: number
|
|
72
72
|
chunkSizeLimit?: number
|
|
73
73
|
renameRefSeqs?: (n: string) => string
|
|
74
74
|
chunkCacheSize?: number
|