@jbrowse/cli 3.5.1 → 3.6.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 +291 -607
- package/bin/run +1 -6
- package/bundle/index.js +4459 -0
- package/package.json +12 -37
- package/bin/dev +0 -17
- package/bin/dev.cmd +0 -3
- package/bin/run.cmd +0 -3
- package/lib/base.js +0 -157
- package/lib/commands/add-assembly.js +0 -491
- package/lib/commands/add-connection.js +0 -170
- package/lib/commands/add-track-json.js +0 -67
- package/lib/commands/add-track.js +0 -564
- package/lib/commands/admin-server.js +0 -153
- package/lib/commands/create.js +0 -111
- package/lib/commands/make-pif.js +0 -116
- package/lib/commands/remove-track.js +0 -37
- package/lib/commands/set-default-session.js +0 -98
- package/lib/commands/sort-bed.js +0 -45
- package/lib/commands/sort-gff.js +0 -45
- package/lib/commands/text-index.js +0 -380
- package/lib/commands/upgrade.js +0 -109
- package/lib/fetchWithProxy.js +0 -12
- package/lib/index.js +0 -6
- package/lib/types/common.js +0 -128
- package/lib/types/gff3Adapter.js +0 -73
- package/lib/types/vcfAdapter.js +0 -76
- package/lib/util.js +0 -35
- package/oclif.manifest.json +0 -1169
package/lib/types/gff3Adapter.js
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.indexGff3 = indexGff3;
|
|
7
|
-
const readline_1 = __importDefault(require("readline"));
|
|
8
|
-
const zlib_1 = require("zlib");
|
|
9
|
-
const cli_progress_1 = require("cli-progress");
|
|
10
|
-
const util_1 = require("../util");
|
|
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
|
-
// @ts-expect-error
|
|
25
|
-
stream.on('data', chunk => {
|
|
26
|
-
receivedBytes += chunk.length;
|
|
27
|
-
progressBar.update(receivedBytes);
|
|
28
|
-
});
|
|
29
|
-
const rl = readline_1.default.createInterface({
|
|
30
|
-
// @ts-expect-error
|
|
31
|
-
input: /.b?gz$/.exec(inLocation) ? stream.pipe((0, zlib_1.createGunzip)()) : stream,
|
|
32
|
-
});
|
|
33
|
-
for await (const line of rl) {
|
|
34
|
-
if (!line.trim()) {
|
|
35
|
-
continue;
|
|
36
|
-
}
|
|
37
|
-
else if (line.startsWith('#')) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
else if (line.startsWith('>')) {
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
const [seq_id, , type, start, end, , , , col9] = line.split('\t');
|
|
44
|
-
const locStr = `${seq_id}:${start}..${end}`;
|
|
45
|
-
if (!typesToExclude.includes(type)) {
|
|
46
|
-
// turns gff3 attrs into a map, and converts the arrays into space
|
|
47
|
-
// separated strings
|
|
48
|
-
const col9attrs = Object.fromEntries(col9
|
|
49
|
-
.split(';')
|
|
50
|
-
.map(f => f.trim())
|
|
51
|
-
.filter(f => !!f)
|
|
52
|
-
.map(f => f.split('='))
|
|
53
|
-
.map(([key, val]) => [
|
|
54
|
-
key.trim(),
|
|
55
|
-
val
|
|
56
|
-
? (0, util_1.decodeURIComponentNoThrow)(val).trim().split(',').join(' ')
|
|
57
|
-
: undefined,
|
|
58
|
-
]));
|
|
59
|
-
const attrs = attributesToIndex
|
|
60
|
-
.map(attr => col9attrs[attr])
|
|
61
|
-
.filter((f) => !!f);
|
|
62
|
-
if (attrs.length) {
|
|
63
|
-
const record = JSON.stringify([
|
|
64
|
-
encodeURIComponent(locStr),
|
|
65
|
-
encodeURIComponent(trackId),
|
|
66
|
-
...attrs.map(a => encodeURIComponent(a)),
|
|
67
|
-
]).replaceAll(',', '|');
|
|
68
|
-
yield `${record} ${[...new Set(attrs)].join(' ')}\n`;
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
progressBar.stop();
|
|
73
|
-
}
|
package/lib/types/vcfAdapter.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.indexVcf = indexVcf;
|
|
7
|
-
const readline_1 = __importDefault(require("readline"));
|
|
8
|
-
const zlib_1 = require("zlib");
|
|
9
|
-
const cli_progress_1 = require("cli-progress");
|
|
10
|
-
const util_1 = require("../util");
|
|
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
|
-
// @ts-expect-error
|
|
25
|
-
stream.on('data', chunk => {
|
|
26
|
-
receivedBytes += chunk.length;
|
|
27
|
-
progressBar.update(receivedBytes);
|
|
28
|
-
});
|
|
29
|
-
const gzStream = /.b?gz$/.exec(inLocation)
|
|
30
|
-
? // @ts-expect-error
|
|
31
|
-
stream.pipe((0, zlib_1.createGunzip)())
|
|
32
|
-
: stream;
|
|
33
|
-
const rl = readline_1.default.createInterface({
|
|
34
|
-
input: gzStream,
|
|
35
|
-
});
|
|
36
|
-
for await (const line of rl) {
|
|
37
|
-
if (line.startsWith('#')) {
|
|
38
|
-
continue;
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
41
|
-
const [ref, pos, id, _ref, _alt, _qual, _filter, info] = line.split('\t');
|
|
42
|
-
// turns gff3 attrs into a map, and converts the arrays into space
|
|
43
|
-
// separated strings
|
|
44
|
-
const fields = Object.fromEntries(info
|
|
45
|
-
.split(';')
|
|
46
|
-
.map(f => f.trim())
|
|
47
|
-
.filter(f => !!f)
|
|
48
|
-
.map(f => f.split('='))
|
|
49
|
-
.map(([key, val]) => [
|
|
50
|
-
key.trim(),
|
|
51
|
-
val
|
|
52
|
-
? (0, util_1.decodeURIComponentNoThrow)(val).trim().split(',').join(' ')
|
|
53
|
-
: undefined,
|
|
54
|
-
]));
|
|
55
|
-
const end = fields.END;
|
|
56
|
-
const locStr = `${ref}:${pos}..${end || +pos + 1}`;
|
|
57
|
-
if (id === '.') {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
const infoAttrs = attributesToIndex
|
|
61
|
-
.map(attr => fields[attr])
|
|
62
|
-
.filter((f) => !!f);
|
|
63
|
-
const ids = id.split(',');
|
|
64
|
-
for (const id of ids) {
|
|
65
|
-
const attrs = [id];
|
|
66
|
-
const record = JSON.stringify([
|
|
67
|
-
encodeURIComponent(locStr),
|
|
68
|
-
encodeURIComponent(trackId),
|
|
69
|
-
encodeURIComponent(id || ''),
|
|
70
|
-
...infoAttrs.map(a => encodeURIComponent(a || '')),
|
|
71
|
-
]).replaceAll(',', '|');
|
|
72
|
-
yield `${record} ${[...new Set(attrs)].join(' ')}\n`;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
progressBar.stop();
|
|
76
|
-
}
|
package/lib/util.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getLocalOrRemoteStream = getLocalOrRemoteStream;
|
|
7
|
-
exports.decodeURIComponentNoThrow = decodeURIComponentNoThrow;
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
const path_1 = __importDefault(require("path"));
|
|
10
|
-
const common_1 = require("./types/common");
|
|
11
|
-
async function getLocalOrRemoteStream(uri, out) {
|
|
12
|
-
if ((0, common_1.isURL)(uri)) {
|
|
13
|
-
const result = await (0, common_1.createRemoteStream)(uri);
|
|
14
|
-
return {
|
|
15
|
-
totalBytes: +(result.headers.get('Content-Length') || 0),
|
|
16
|
-
stream: result.body,
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
const filename = path_1.default.isAbsolute(uri) ? uri : path_1.default.join(out, uri);
|
|
21
|
-
return {
|
|
22
|
-
totalBytes: fs_1.default.statSync(filename).size,
|
|
23
|
-
stream: fs_1.default.createReadStream(filename),
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function decodeURIComponentNoThrow(uri) {
|
|
28
|
-
try {
|
|
29
|
-
return decodeURIComponent(uri);
|
|
30
|
-
}
|
|
31
|
-
catch (e) {
|
|
32
|
-
// avoid throwing exception on a failure to decode URI component
|
|
33
|
-
return uri;
|
|
34
|
-
}
|
|
35
|
-
}
|