@jbrowse/cli 2.6.2 → 2.7.0
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/README.md +274 -206
- package/bin/dev +17 -0
- package/bin/dev.cmd +3 -0
- package/bin/run +6 -3
- package/lib/base.js +32 -80
- package/lib/commands/add-assembly.js +29 -27
- package/lib/commands/add-connection.js +43 -37
- package/lib/commands/add-track-json.js +9 -10
- package/lib/commands/add-track.js +74 -73
- package/lib/commands/admin-server.js +7 -7
- package/lib/commands/create.js +14 -16
- package/lib/commands/remove-track.js +9 -11
- package/lib/commands/set-default-session.js +14 -17
- package/lib/commands/text-index.js +86 -101
- package/lib/commands/upgrade.js +13 -14
- package/lib/fetchWithProxy.js +1 -1
- package/lib/index.js +2 -2
- package/lib/types/common.js +2 -2
- package/lib/types/gff3Adapter.js +54 -88
- package/lib/types/vcfAdapter.js +58 -93
- package/oclif.manifest.json +918 -1
- package/package.json +10 -12
package/lib/types/gff3Adapter.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
4
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
-
var m = o[Symbol.asyncIterator], i;
|
|
6
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
7
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
8
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
9
|
-
};
|
|
10
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
11
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
13
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
14
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
15
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
16
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
17
|
-
function fulfill(value) { resume("next", value); }
|
|
18
|
-
function reject(value) { resume("throw", value); }
|
|
19
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
20
|
-
};
|
|
21
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
@@ -27,78 +8,63 @@ const cli_progress_1 = require("cli-progress");
|
|
|
27
8
|
const zlib_1 = require("zlib");
|
|
28
9
|
const readline_1 = __importDefault(require("readline"));
|
|
29
10
|
const util_1 = require("../util");
|
|
30
|
-
function indexGff3({ config, attributesToIndex, inLocation, outLocation, typesToExclude, quiet, }) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
async function* indexGff3({ config, attributesToIndex, inLocation, outLocation, typesToExclude, quiet, }) {
|
|
12
|
+
const { trackId } = config;
|
|
13
|
+
// progress bar code was aided by blog post at
|
|
14
|
+
// https://webomnizz.com/download-a-file-with-progressbar-using-node-js/
|
|
15
|
+
const progressBar = new cli_progress_1.SingleBar({
|
|
16
|
+
format: '{bar} ' + trackId + ' {percentage}% | ETA: {eta}s',
|
|
17
|
+
etaBuffer: 2000,
|
|
18
|
+
}, cli_progress_1.Presets.shades_classic);
|
|
19
|
+
let receivedBytes = 0;
|
|
20
|
+
const { totalBytes, stream } = await (0, util_1.getLocalOrRemoteStream)(inLocation, outLocation);
|
|
21
|
+
if (!quiet) {
|
|
22
|
+
progressBar.start(totalBytes, 0);
|
|
23
|
+
}
|
|
24
|
+
stream.on('data', chunk => {
|
|
25
|
+
receivedBytes += chunk.length;
|
|
26
|
+
progressBar.update(receivedBytes);
|
|
27
|
+
});
|
|
28
|
+
const rl = readline_1.default.createInterface({
|
|
29
|
+
input: inLocation.match(/.b?gz$/) ? stream.pipe((0, zlib_1.createGunzip)()) : stream,
|
|
30
|
+
});
|
|
31
|
+
for await (const line of rl) {
|
|
32
|
+
if (!line.trim()) {
|
|
33
|
+
continue;
|
|
44
34
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
input: inLocation.match(/.b?gz$/) ? stream.pipe((0, zlib_1.createGunzip)()) : stream,
|
|
51
|
-
});
|
|
52
|
-
try {
|
|
53
|
-
for (var _d = true, rl_1 = __asyncValues(rl), rl_1_1; rl_1_1 = yield __await(rl_1.next()), _a = rl_1_1.done, !_a; _d = true) {
|
|
54
|
-
_c = rl_1_1.value;
|
|
55
|
-
_d = false;
|
|
56
|
-
const line = _c;
|
|
57
|
-
if (!line.trim()) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
else if (line.startsWith('#')) {
|
|
61
|
-
continue;
|
|
62
|
-
}
|
|
63
|
-
else if (line.startsWith('>')) {
|
|
64
|
-
break;
|
|
65
|
-
}
|
|
66
|
-
const [seq_id, , type, start, end, , , , col9] = line.split('\t');
|
|
67
|
-
const locStr = `${seq_id}:${start}..${end}`;
|
|
68
|
-
if (!typesToExclude.includes(type)) {
|
|
69
|
-
// turns gff3 attrs into a map, and converts the arrays into space
|
|
70
|
-
// separated strings
|
|
71
|
-
const col9attrs = Object.fromEntries(col9
|
|
72
|
-
.split(';')
|
|
73
|
-
.map(f => f.trim())
|
|
74
|
-
.filter(f => !!f)
|
|
75
|
-
.map(f => f.split('='))
|
|
76
|
-
.map(([key, val]) => [
|
|
77
|
-
key.trim(),
|
|
78
|
-
decodeURIComponent(val).trim().split(',').join(' '),
|
|
79
|
-
]));
|
|
80
|
-
const attrs = attributesToIndex
|
|
81
|
-
.map(attr => col9attrs[attr])
|
|
82
|
-
.filter((f) => !!f);
|
|
83
|
-
if (attrs.length) {
|
|
84
|
-
const record = JSON.stringify([
|
|
85
|
-
encodeURIComponent(locStr),
|
|
86
|
-
encodeURIComponent(trackId),
|
|
87
|
-
...attrs.map(a => encodeURIComponent(a)),
|
|
88
|
-
]).replaceAll(',', '|');
|
|
89
|
-
yield yield __await(`${record} ${[...new Set(attrs)].join(' ')}\n`);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
35
|
+
else if (line.startsWith('#')) {
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
else if (line.startsWith('>')) {
|
|
39
|
+
break;
|
|
93
40
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
41
|
+
const [seq_id, , type, start, end, , , , col9] = line.split('\t');
|
|
42
|
+
const locStr = `${seq_id}:${start}..${end}`;
|
|
43
|
+
if (!typesToExclude.includes(type)) {
|
|
44
|
+
// turns gff3 attrs into a map, and converts the arrays into space
|
|
45
|
+
// separated strings
|
|
46
|
+
const col9attrs = Object.fromEntries(col9
|
|
47
|
+
.split(';')
|
|
48
|
+
.map(f => f.trim())
|
|
49
|
+
.filter(f => !!f)
|
|
50
|
+
.map(f => f.split('='))
|
|
51
|
+
.map(([key, val]) => [
|
|
52
|
+
key.trim(),
|
|
53
|
+
decodeURIComponent(val).trim().split(',').join(' '),
|
|
54
|
+
]));
|
|
55
|
+
const attrs = attributesToIndex
|
|
56
|
+
.map(attr => col9attrs[attr])
|
|
57
|
+
.filter((f) => !!f);
|
|
58
|
+
if (attrs.length) {
|
|
59
|
+
const record = JSON.stringify([
|
|
60
|
+
encodeURIComponent(locStr),
|
|
61
|
+
encodeURIComponent(trackId),
|
|
62
|
+
...attrs.map(a => encodeURIComponent(a)),
|
|
63
|
+
]).replaceAll(',', '|');
|
|
64
|
+
yield `${record} ${[...new Set(attrs)].join(' ')}\n`;
|
|
98
65
|
}
|
|
99
|
-
finally { if (e_1) throw e_1.error; }
|
|
100
66
|
}
|
|
101
|
-
|
|
102
|
-
|
|
67
|
+
}
|
|
68
|
+
progressBar.stop();
|
|
103
69
|
}
|
|
104
70
|
exports.indexGff3 = indexGff3;
|
package/lib/types/vcfAdapter.js
CHANGED
|
@@ -1,23 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
|
-
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
4
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
-
var m = o[Symbol.asyncIterator], i;
|
|
6
|
-
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
7
|
-
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
8
|
-
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
9
|
-
};
|
|
10
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
11
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
12
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
13
|
-
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
14
|
-
function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
|
|
15
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
16
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
17
|
-
function fulfill(value) { resume("next", value); }
|
|
18
|
-
function reject(value) { resume("throw", value); }
|
|
19
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
20
|
-
};
|
|
21
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
4
|
};
|
|
@@ -27,82 +8,66 @@ const cli_progress_1 = require("cli-progress");
|
|
|
27
8
|
const zlib_1 = require("zlib");
|
|
28
9
|
const readline_1 = __importDefault(require("readline"));
|
|
29
10
|
const util_1 = require("../util");
|
|
30
|
-
function indexVcf({ config, attributesToIndex, inLocation, outLocation, quiet, }) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
async function* indexVcf({ config, attributesToIndex, inLocation, outLocation, quiet, }) {
|
|
12
|
+
const { trackId } = config;
|
|
13
|
+
// progress bar code was aided by blog post at
|
|
14
|
+
// https://webomnizz.com/download-a-file-with-progressbar-using-node-js/
|
|
15
|
+
const progressBar = new cli_progress_1.SingleBar({
|
|
16
|
+
format: '{bar} ' + trackId + ' {percentage}% | ETA: {eta}s',
|
|
17
|
+
etaBuffer: 2000,
|
|
18
|
+
}, cli_progress_1.Presets.shades_classic);
|
|
19
|
+
let receivedBytes = 0;
|
|
20
|
+
const { totalBytes, stream } = await (0, util_1.getLocalOrRemoteStream)(inLocation, outLocation);
|
|
21
|
+
if (!quiet) {
|
|
22
|
+
progressBar.start(totalBytes, 0);
|
|
23
|
+
}
|
|
24
|
+
stream.on('data', chunk => {
|
|
25
|
+
receivedBytes += chunk.length;
|
|
26
|
+
progressBar.update(receivedBytes);
|
|
27
|
+
});
|
|
28
|
+
const gzStream = inLocation.match(/.b?gz$/)
|
|
29
|
+
? stream.pipe((0, zlib_1.createGunzip)())
|
|
30
|
+
: stream;
|
|
31
|
+
const rl = readline_1.default.createInterface({
|
|
32
|
+
input: gzStream,
|
|
33
|
+
});
|
|
34
|
+
for await (const line of rl) {
|
|
35
|
+
if (line.startsWith('#')) {
|
|
36
|
+
continue;
|
|
44
37
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
64
|
-
const [ref, pos, id, _ref, _alt, _qual, _filter, info] = line.split('\t');
|
|
65
|
-
// turns gff3 attrs into a map, and converts the arrays into space
|
|
66
|
-
// separated strings
|
|
67
|
-
const fields = Object.fromEntries(info
|
|
68
|
-
.split(';')
|
|
69
|
-
.map(f => f.trim())
|
|
70
|
-
.filter(f => !!f)
|
|
71
|
-
.map(f => f.split('='))
|
|
72
|
-
.map(([key, val]) => [
|
|
73
|
-
key.trim(),
|
|
74
|
-
val ? decodeURIComponent(val).trim().split(',').join(' ') : undefined,
|
|
75
|
-
]));
|
|
76
|
-
const end = fields.END;
|
|
77
|
-
const locStr = `${ref}:${pos}..${end || +pos + 1}`;
|
|
78
|
-
if (id === '.') {
|
|
79
|
-
continue;
|
|
80
|
-
}
|
|
81
|
-
const infoAttrs = attributesToIndex
|
|
82
|
-
.map(attr => fields[attr])
|
|
83
|
-
.filter((f) => !!f);
|
|
84
|
-
const ids = id.split(',');
|
|
85
|
-
for (let i = 0; i < ids.length; i++) {
|
|
86
|
-
const id = ids[i];
|
|
87
|
-
const attrs = [id];
|
|
88
|
-
const record = JSON.stringify([
|
|
89
|
-
encodeURIComponent(locStr),
|
|
90
|
-
encodeURIComponent(trackId),
|
|
91
|
-
encodeURIComponent(id || ''),
|
|
92
|
-
...infoAttrs.map(a => encodeURIComponent(a || '')),
|
|
93
|
-
]).replaceAll(',', '|');
|
|
94
|
-
yield yield __await(`${record} ${[...new Set(attrs)].join(' ')}\n`);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
+
const [ref, pos, id, _ref, _alt, _qual, _filter, info] = line.split('\t');
|
|
40
|
+
// turns gff3 attrs into a map, and converts the arrays into space
|
|
41
|
+
// separated strings
|
|
42
|
+
const fields = Object.fromEntries(info
|
|
43
|
+
.split(';')
|
|
44
|
+
.map(f => f.trim())
|
|
45
|
+
.filter(f => !!f)
|
|
46
|
+
.map(f => f.split('='))
|
|
47
|
+
.map(([key, val]) => [
|
|
48
|
+
key.trim(),
|
|
49
|
+
val ? decodeURIComponent(val).trim().split(',').join(' ') : undefined,
|
|
50
|
+
]));
|
|
51
|
+
const end = fields.END;
|
|
52
|
+
const locStr = `${ref}:${pos}..${end || +pos + 1}`;
|
|
53
|
+
if (id === '.') {
|
|
54
|
+
continue;
|
|
97
55
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
56
|
+
const infoAttrs = attributesToIndex
|
|
57
|
+
.map(attr => fields[attr])
|
|
58
|
+
.filter((f) => !!f);
|
|
59
|
+
const ids = id.split(',');
|
|
60
|
+
for (const id of ids) {
|
|
61
|
+
const attrs = [id];
|
|
62
|
+
const record = JSON.stringify([
|
|
63
|
+
encodeURIComponent(locStr),
|
|
64
|
+
encodeURIComponent(trackId),
|
|
65
|
+
encodeURIComponent(id || ''),
|
|
66
|
+
...infoAttrs.map(a => encodeURIComponent(a || '')),
|
|
67
|
+
]).replaceAll(',', '|');
|
|
68
|
+
yield `${record} ${[...new Set(attrs)].join(' ')}\n`;
|
|
104
69
|
}
|
|
105
|
-
|
|
106
|
-
|
|
70
|
+
}
|
|
71
|
+
progressBar.stop();
|
|
107
72
|
}
|
|
108
73
|
exports.indexVcf = indexVcf;
|