@jbrowse/cli 4.0.4 → 4.1.3
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 +269 -111
- package/bin/run +2 -1
- package/bundle/index.js +289 -538
- package/dist/base.js +1 -2
- package/dist/bin.js +2 -4
- package/dist/cliFetch.js +3 -0
- package/dist/commands/add-assembly/index.js +19 -22
- package/dist/commands/add-assembly/utils.js +75 -92
- package/dist/commands/add-connection.js +16 -22
- package/dist/commands/add-track-json.js +13 -16
- package/dist/commands/add-track-utils/adapter-utils.js +6 -13
- package/dist/commands/add-track-utils/file-operations.js +8 -14
- package/dist/commands/add-track-utils/track-config.js +10 -18
- package/dist/commands/add-track-utils/validators.js +15 -27
- package/dist/commands/add-track.js +27 -33
- package/dist/commands/admin-server/index.js +24 -30
- package/dist/commands/admin-server/utils.js +27 -38
- package/dist/commands/create.js +16 -22
- package/dist/commands/make-pif/cigar-utils.js +3 -8
- package/dist/commands/make-pif/file-utils.js +10 -18
- package/dist/commands/make-pif/index.js +13 -16
- package/dist/commands/make-pif/pif-generator.js +14 -23
- package/dist/commands/process-utils.js +1 -4
- package/dist/commands/remove-track.js +8 -11
- package/dist/commands/set-default-session.js +13 -19
- package/dist/commands/shared/config-operations.js +7 -11
- package/dist/commands/shared/sort-utils.js +7 -14
- package/dist/commands/shared/validators.js +4 -8
- package/dist/commands/sort-bed.js +14 -17
- package/dist/commands/sort-gff.js +14 -17
- package/dist/commands/text-index/adapter-utils.js +5 -10
- package/dist/commands/text-index/aggregate.js +12 -15
- package/dist/commands/text-index/command.js +9 -12
- package/dist/commands/text-index/config-utils.js +24 -38
- package/dist/commands/text-index/file-list.js +11 -17
- package/dist/commands/text-index/index.js +4 -11
- package/dist/commands/text-index/indexing-utils.js +59 -43
- package/dist/commands/text-index/per-track.js +13 -16
- package/dist/commands/text-index/validators.js +3 -8
- package/dist/commands/track-utils.js +22 -33
- package/dist/commands/upgrade.js +20 -26
- package/dist/index.js +31 -39
- package/dist/types/common.js +5 -107
- package/dist/util.js +13 -20
- package/dist/utils.js +82 -58
- package/dist/version.js +1 -0
- package/package.json +7 -6
- package/dist/fetchWithProxy.js +0 -12
- package/dist/types/gff3Adapter.js +0 -42
- package/dist/types/streamUtils.js +0 -66
- package/dist/types/vcfAdapter.js +0 -39
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indexGff3 = indexGff3;
|
|
4
|
-
const util_ts_1 = require("../util.js");
|
|
5
|
-
const streamUtils_ts_1 = require("./streamUtils.js");
|
|
6
|
-
async function* indexGff3({ config, attributesToIndex, inLocation, outLocation, typesToExclude, quiet, }) {
|
|
7
|
-
const { trackId } = config;
|
|
8
|
-
const { rl, progressBar } = await (0, streamUtils_ts_1.createIndexingStream)({
|
|
9
|
-
inLocation,
|
|
10
|
-
outLocation,
|
|
11
|
-
trackId,
|
|
12
|
-
quiet,
|
|
13
|
-
});
|
|
14
|
-
const excludeSet = new Set(typesToExclude);
|
|
15
|
-
const encodedTrackId = encodeURIComponent(trackId);
|
|
16
|
-
for await (const line of rl) {
|
|
17
|
-
if (!line.trim()) {
|
|
18
|
-
continue;
|
|
19
|
-
}
|
|
20
|
-
else if (line.startsWith('#')) {
|
|
21
|
-
continue;
|
|
22
|
-
}
|
|
23
|
-
else if (line.startsWith('>')) {
|
|
24
|
-
break;
|
|
25
|
-
}
|
|
26
|
-
const [seq_id, , type, start, end, , , , col9] = line.split('\t');
|
|
27
|
-
if (!excludeSet.has(type)) {
|
|
28
|
-
const col9attrs = (0, streamUtils_ts_1.parseAttributes)(col9, util_ts_1.decodeURIComponentNoThrow);
|
|
29
|
-
const attrs = attributesToIndex
|
|
30
|
-
.map(attr => col9attrs[attr])
|
|
31
|
-
.filter((f) => !!f);
|
|
32
|
-
if (attrs.length > 0) {
|
|
33
|
-
const locStr = `${seq_id}:${start}..${end}`;
|
|
34
|
-
const encodedAttrs = attrs.map(a => `"${encodeURIComponent(a)}"`);
|
|
35
|
-
const record = `["${encodeURIComponent(locStr)}"|"${encodedTrackId}"|${encodedAttrs.join('|')}]`;
|
|
36
|
-
const uniqueAttrs = [...new Set(attrs)];
|
|
37
|
-
yield `${record} ${uniqueAttrs.join(' ')}\n`;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
progressBar.stop();
|
|
42
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createIndexingStream = createIndexingStream;
|
|
4
|
-
exports.parseAttributes = parseAttributes;
|
|
5
|
-
const cli_progress_1 = require("cli-progress");
|
|
6
|
-
const util_ts_1 = require("../util.js");
|
|
7
|
-
async function* readLines(reader, progressBar) {
|
|
8
|
-
const decoder = new TextDecoder();
|
|
9
|
-
let buffer = '';
|
|
10
|
-
let receivedBytes = 0;
|
|
11
|
-
try {
|
|
12
|
-
let result = await reader.read();
|
|
13
|
-
while (!result.done) {
|
|
14
|
-
receivedBytes += result.value.length;
|
|
15
|
-
progressBar.update(receivedBytes);
|
|
16
|
-
buffer += decoder.decode(result.value, { stream: true });
|
|
17
|
-
const lines = buffer.split('\n');
|
|
18
|
-
buffer = lines.pop();
|
|
19
|
-
for (const line of lines) {
|
|
20
|
-
yield line;
|
|
21
|
-
}
|
|
22
|
-
result = await reader.read();
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
finally {
|
|
26
|
-
reader.releaseLock();
|
|
27
|
-
}
|
|
28
|
-
buffer += decoder.decode();
|
|
29
|
-
if (buffer) {
|
|
30
|
-
yield buffer;
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
async function createIndexingStream({ inLocation, outLocation, trackId, quiet, }) {
|
|
34
|
-
const progressBar = new cli_progress_1.SingleBar({
|
|
35
|
-
format: `{bar} ${trackId} {percentage}% | ETA: {eta}s`,
|
|
36
|
-
etaBuffer: 2000,
|
|
37
|
-
}, cli_progress_1.Presets.shades_classic);
|
|
38
|
-
const { totalBytes, stream } = await (0, util_ts_1.getLocalOrRemoteStream)(inLocation, outLocation);
|
|
39
|
-
if (!quiet) {
|
|
40
|
-
progressBar.start(totalBytes, 0);
|
|
41
|
-
}
|
|
42
|
-
if (!stream) {
|
|
43
|
-
throw new Error(`Failed to fetch ${inLocation}: no response body`);
|
|
44
|
-
}
|
|
45
|
-
const inputStream = /.b?gz$/.exec(inLocation)
|
|
46
|
-
? // @ts-ignore root tsconfig includes DOM lib which has incompatible stream types
|
|
47
|
-
stream.pipeThrough(new DecompressionStream('gzip'))
|
|
48
|
-
: stream;
|
|
49
|
-
const rl = readLines(inputStream.getReader(), progressBar);
|
|
50
|
-
return { rl, progressBar };
|
|
51
|
-
}
|
|
52
|
-
function parseAttributes(infoString, decodeFunc) {
|
|
53
|
-
const result = {};
|
|
54
|
-
for (const field of infoString.split(';')) {
|
|
55
|
-
const trimmed = field.trim();
|
|
56
|
-
if (trimmed) {
|
|
57
|
-
const eqIdx = trimmed.indexOf('=');
|
|
58
|
-
if (eqIdx !== -1) {
|
|
59
|
-
const key = trimmed.slice(0, eqIdx).trim();
|
|
60
|
-
const val = trimmed.slice(eqIdx + 1);
|
|
61
|
-
result[key] = decodeFunc(val).trim().replaceAll(',', ' ');
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
package/dist/types/vcfAdapter.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indexVcf = indexVcf;
|
|
4
|
-
const util_ts_1 = require("../util.js");
|
|
5
|
-
const streamUtils_ts_1 = require("./streamUtils.js");
|
|
6
|
-
async function* indexVcf({ config, attributesToIndex, inLocation, outLocation, quiet, }) {
|
|
7
|
-
const { trackId } = config;
|
|
8
|
-
const { rl, progressBar } = await (0, streamUtils_ts_1.createIndexingStream)({
|
|
9
|
-
inLocation,
|
|
10
|
-
outLocation,
|
|
11
|
-
trackId,
|
|
12
|
-
quiet,
|
|
13
|
-
});
|
|
14
|
-
const encodedTrackId = encodeURIComponent(trackId);
|
|
15
|
-
for await (const line of rl) {
|
|
16
|
-
if (line.startsWith('#')) {
|
|
17
|
-
continue;
|
|
18
|
-
}
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
-
const [ref, pos, id, _ref, _alt, _qual, _filter, info] = line.split('\t');
|
|
21
|
-
if (id === '.') {
|
|
22
|
-
continue;
|
|
23
|
-
}
|
|
24
|
-
const fields = (0, streamUtils_ts_1.parseAttributes)(info, util_ts_1.decodeURIComponentNoThrow);
|
|
25
|
-
const end = fields.END;
|
|
26
|
-
const locStr = `${ref}:${pos}..${end || +pos + 1}`;
|
|
27
|
-
const encodedLocStr = encodeURIComponent(locStr);
|
|
28
|
-
const infoAttrs = attributesToIndex
|
|
29
|
-
.map(attr => fields[attr])
|
|
30
|
-
.filter((f) => !!f);
|
|
31
|
-
const encodedInfoAttrs = infoAttrs.map(a => `"${encodeURIComponent(a)}"`);
|
|
32
|
-
for (const variantId of id.split(',')) {
|
|
33
|
-
const encodedId = encodeURIComponent(variantId);
|
|
34
|
-
const record = `["${encodedLocStr}"|"${encodedTrackId}"|"${encodedId}"${encodedInfoAttrs.length > 0 ? `|${encodedInfoAttrs.join('|')}` : ''}]`;
|
|
35
|
-
yield `${record} ${variantId}\n`;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
progressBar.stop();
|
|
39
|
-
}
|