@jbrowse/cli 4.3.0 → 5.0.0-beta.2
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 +413 -57
- package/bin/run +1 -1
- package/bundle/index.js +550 -2659
- package/dist/base.js +0 -3
- package/dist/bin.js +2 -1
- package/dist/cliFetch.js +3 -0
- package/dist/commands/add-assembly/index.js +46 -19
- package/dist/commands/add-assembly/utils.js +204 -290
- package/dist/commands/add-connection.js +73 -79
- package/dist/commands/add-track-json.js +24 -12
- package/dist/commands/add-track-utils/adapter-utils.js +222 -288
- package/dist/commands/add-track-utils/file-operations.js +27 -11
- package/dist/commands/add-track-utils/multiwig.js +47 -0
- package/dist/commands/add-track-utils/track-config.js +68 -25
- package/dist/commands/add-track-utils/validators.js +36 -20
- package/dist/commands/add-track.js +201 -62
- package/dist/commands/admin-server/index.js +30 -49
- package/dist/commands/admin-server/utils.js +235 -125
- package/dist/commands/create.js +18 -34
- package/dist/commands/make-density/density-generator.js +180 -0
- package/dist/commands/make-density/index.js +139 -0
- package/dist/commands/make-pif/index.js +128 -11
- package/dist/commands/make-pif/pif-generator.js +249 -43
- package/dist/commands/process-utils.js +13 -2
- package/dist/commands/remove-track.js +20 -13
- package/dist/commands/set-default-session.js +35 -31
- package/dist/commands/shared/config-operations.js +3 -10
- package/dist/commands/shared/density.js +12 -0
- package/dist/commands/shared/sort-utils.js +67 -10
- package/dist/commands/shared/validators.js +38 -3
- package/dist/commands/sort-bed.js +2 -33
- package/dist/commands/sort-gff.js +2 -33
- package/dist/commands/text-index/adapter-utils.js +6 -23
- package/dist/commands/text-index/aggregate.js +40 -34
- package/dist/commands/text-index/command.js +35 -7
- package/dist/commands/text-index/config-utils.js +60 -83
- package/dist/commands/text-index/file-list.js +32 -18
- package/dist/commands/text-index/index.js +4 -4
- package/dist/commands/text-index/indexing-utils.js +49 -73
- package/dist/commands/text-index/per-track.js +44 -31
- package/dist/commands/text-index/validators.js +1 -1
- package/dist/commands/upgrade.js +20 -32
- package/dist/commands/validate/configManifest.generated.js +5765 -0
- package/dist/commands/validate/displayDefaultKeys.js +28 -0
- package/dist/commands/validate/index.js +97 -0
- package/dist/commands/validate/suggest.js +35 -0
- package/dist/commands/validate/types.js +6 -0
- package/dist/commands/validate/validateConfig.js +522 -0
- package/dist/index.js +104 -50
- package/dist/types/common.js +3 -27
- package/dist/utils.js +309 -128
- package/dist/version.js +1 -1
- package/package.json +8 -10
- package/dist/commands/make-pif/cigar-utils.js +0 -24
- package/dist/commands/make-pif/file-utils.js +0 -30
- package/dist/commands/track-utils.js +0 -74
- package/dist/util.js +0 -35
package/dist/index.js
CHANGED
|
@@ -1,35 +1,90 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { parseArgs } from 'util';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
2
|
+
import { parseArgs } from 'node:util';
|
|
3
|
+
import { version } from './version.js';
|
|
4
|
+
// single source of truth for both dispatch and the global help listing, so a
|
|
5
|
+
// new command can never be wired into one but forgotten in the other.
|
|
6
|
+
//
|
|
7
|
+
// Each command is LOADED WHEN IT IS DISPATCHED, not imported here: a static
|
|
8
|
+
// import list makes every invocation pay for every command's module graph, and
|
|
9
|
+
// text-index's parsers alone are most of it. `jbrowse add-track` went from
|
|
10
|
+
// 0.35s to 0.21s of startup, which is the whole of what that command does.
|
|
11
|
+
const registry = [
|
|
12
|
+
{
|
|
13
|
+
name: 'create',
|
|
14
|
+
summary: 'Downloads and installs the latest JBrowse 2 release',
|
|
15
|
+
load: () => import('./commands/create.js').then(m => m.run),
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: 'add-assembly',
|
|
19
|
+
summary: 'Add an assembly to a JBrowse 2 configuration',
|
|
20
|
+
load: () => import('./commands/add-assembly/index.js').then(m => m.run),
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: 'add-track',
|
|
24
|
+
summary: 'Add a track to a JBrowse 2 configuration',
|
|
25
|
+
load: () => import('./commands/add-track.js').then(m => m.run),
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'validate',
|
|
29
|
+
summary: 'Check a configuration for errors, including ones JBrowse accepts silently',
|
|
30
|
+
load: () => import('./commands/validate/index.js').then(m => m.run),
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
name: 'text-index',
|
|
34
|
+
summary: 'Make a text-indexing file for any given track(s)',
|
|
35
|
+
load: () => import('./commands/text-index/index.js').then(m => m.run),
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'admin-server',
|
|
39
|
+
summary: 'Start up a small admin server for JBrowse configuration',
|
|
40
|
+
load: () => import('./commands/admin-server/index.js').then(m => m.run),
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'upgrade',
|
|
44
|
+
summary: 'Upgrades JBrowse 2 to latest version',
|
|
45
|
+
load: () => import('./commands/upgrade.js').then(m => m.run),
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: 'make-pif',
|
|
49
|
+
summary: 'Creates pairwise indexed PAF (PIF), with bgzip and tabix',
|
|
50
|
+
load: () => import('./commands/make-pif/index.js').then(m => m.run),
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: 'make-density',
|
|
54
|
+
summary: 'Counts feature starts per bin into a bigWig density sidecar, with bedGraphToBigWig',
|
|
55
|
+
load: () => import('./commands/make-density/index.js').then(m => m.run),
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
name: 'sort-gff',
|
|
59
|
+
summary: 'Sort a GFF/GTF for tabix: sort -k1,1 -k4,4n, header kept on top',
|
|
60
|
+
load: () => import('./commands/sort-gff.js').then(m => m.run),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'sort-bed',
|
|
64
|
+
summary: 'Sort a BED for tabix: sort -k1,1 -k2,2n, header kept on top',
|
|
65
|
+
load: () => import('./commands/sort-bed.js').then(m => m.run),
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
name: 'add-connection',
|
|
69
|
+
summary: 'Add a connection to a JBrowse 2 configuration',
|
|
70
|
+
load: () => import('./commands/add-connection.js').then(m => m.run),
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
name: 'add-track-json',
|
|
74
|
+
summary: 'Add a track configuration directly from a JSON hunk',
|
|
75
|
+
load: () => import('./commands/add-track-json.js').then(m => m.run),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'remove-track',
|
|
79
|
+
summary: 'Remove a track configuration from a JBrowse 2 configuration',
|
|
80
|
+
load: () => import('./commands/remove-track.js').then(m => m.run),
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: 'set-default-session',
|
|
84
|
+
summary: 'Set a default session with views and tracks',
|
|
85
|
+
load: () => import('./commands/set-default-session.js').then(m => m.run),
|
|
86
|
+
},
|
|
87
|
+
];
|
|
33
88
|
export async function main(args) {
|
|
34
89
|
try {
|
|
35
90
|
const { values: flags, positionals } = parseArgs({
|
|
@@ -64,16 +119,23 @@ export async function main(args) {
|
|
|
64
119
|
showGlobalHelp();
|
|
65
120
|
process.exit(1);
|
|
66
121
|
}
|
|
67
|
-
const command =
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
122
|
+
const command = registry.find(c => c.name === commandName);
|
|
69
123
|
if (!command) {
|
|
70
124
|
console.error(`Error: Unknown command "${commandName}"`);
|
|
71
|
-
console.error(`Available commands: ${
|
|
125
|
+
console.error(`Available commands: ${registry.map(c => c.name).join(', ')}`);
|
|
72
126
|
process.exit(1);
|
|
73
127
|
}
|
|
74
|
-
// Pass the
|
|
75
|
-
|
|
76
|
-
|
|
128
|
+
// Pass everything after the command token to the command. Slicing from the
|
|
129
|
+
// command's actual position (rather than a hardcoded index 0) keeps this
|
|
130
|
+
// correct when a global flag precedes the command, e.g. `jbrowse -v create`
|
|
131
|
+
const commandArgs = args.slice(args.indexOf(commandName) + 1);
|
|
132
|
+
// ...but that slice drops a help flag written before the command, so
|
|
133
|
+
// `jbrowse --help create` used to run create with no args and fail on the
|
|
134
|
+
// missing positional instead of printing its help
|
|
135
|
+
if (flags.help && !commandArgs.some(a => a === '--help' || a === '-h')) {
|
|
136
|
+
commandArgs.push('--help');
|
|
137
|
+
}
|
|
138
|
+
await (await command.load())(commandArgs);
|
|
77
139
|
}
|
|
78
140
|
catch (error) {
|
|
79
141
|
const message = error instanceof Error ? error.message : String(error);
|
|
@@ -93,6 +155,10 @@ Try setting a custom TMPDIR with more available space:
|
|
|
93
155
|
}
|
|
94
156
|
}
|
|
95
157
|
function showGlobalHelp() {
|
|
158
|
+
const width = Math.max(...registry.map(c => c.name.length)) + 2;
|
|
159
|
+
const commandLines = registry
|
|
160
|
+
.map(c => ` ${c.name.padEnd(width)}${c.summary}`)
|
|
161
|
+
.join('\n');
|
|
96
162
|
console.log(`
|
|
97
163
|
JBrowse CLI
|
|
98
164
|
|
|
@@ -100,19 +166,7 @@ USAGE
|
|
|
100
166
|
$ jbrowse <command> [options]
|
|
101
167
|
|
|
102
168
|
COMMANDS
|
|
103
|
-
|
|
104
|
-
add-assembly Add an assembly to a JBrowse 2 configuration
|
|
105
|
-
add-track Add a track to a JBrowse 2 configuration
|
|
106
|
-
text-index Make a text-indexing file for any given track(s)
|
|
107
|
-
admin-server Start up a small admin server for JBrowse configuration
|
|
108
|
-
upgrade Upgrades JBrowse 2 to latest version
|
|
109
|
-
make-pif Creates pairwise indexed PAF (PIF), with bgzip and tabix
|
|
110
|
-
sort-gff Helper utility to sort GFF files for tabix
|
|
111
|
-
sort-bed Helper utility to sort BED files for tabix
|
|
112
|
-
add-connection Add a connection to a JBrowse 2 configuration
|
|
113
|
-
add-track-json Add a track configuration directly from a JSON hunk
|
|
114
|
-
remove-track Remove a track configuration from a JBrowse 2 configuration
|
|
115
|
-
set-default-session Set a default session with views and tracks
|
|
169
|
+
${commandLines}
|
|
116
170
|
|
|
117
171
|
OPTIONS
|
|
118
172
|
-h, --help Show help
|
package/dist/types/common.js
CHANGED
|
@@ -1,27 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
if (!res.ok) {
|
|
5
|
-
throw new Error(`Failed to fetch ${urlIn} status ${res.status} ${await res.text()}`);
|
|
6
|
-
}
|
|
7
|
-
return res;
|
|
8
|
-
}
|
|
9
|
-
export function isURL(FileName) {
|
|
10
|
-
let url;
|
|
11
|
-
try {
|
|
12
|
-
url = new URL(FileName);
|
|
13
|
-
}
|
|
14
|
-
catch (_) {
|
|
15
|
-
return false;
|
|
16
|
-
}
|
|
17
|
-
return url.protocol === 'http:' || url.protocol === 'https:';
|
|
18
|
-
}
|
|
19
|
-
const SUPPORTED_ADAPTERS = new Set([
|
|
20
|
-
'Gff3TabixAdapter',
|
|
21
|
-
'VcfTabixAdapter',
|
|
22
|
-
'Gff3Adapter',
|
|
23
|
-
'VcfAdapter',
|
|
24
|
-
]);
|
|
25
|
-
export function supported(type = '') {
|
|
26
|
-
return SUPPORTED_ADAPTERS.has(type);
|
|
27
|
-
}
|
|
1
|
+
// the indexer package owns both of these: which adapter types text-index can
|
|
2
|
+
// handle, and the URL test its stream opener uses to pick fetch vs fs
|
|
3
|
+
export { isURL, isSupportedIndexingAdapter as supported, } from '@jbrowse/text-indexing-core';
|