@jbrowse/cli 3.5.1 → 3.6.1
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/dist/base.js +5 -0
- package/dist/bin.js +3 -0
- package/dist/commands/add-assembly.js +143 -0
- package/dist/commands/add-connection.js +177 -0
- package/dist/commands/add-track-json.js +81 -0
- package/dist/commands/add-track-utils/adapter-utils.js +304 -0
- package/dist/commands/add-track-utils/file-operations.js +36 -0
- package/dist/commands/add-track-utils/track-config.js +63 -0
- package/dist/commands/add-track-utils/validators.js +74 -0
- package/dist/commands/add-track.js +193 -0
- package/dist/commands/admin-server-utils.js +238 -0
- package/dist/commands/admin-server.js +51 -0
- package/dist/commands/assembly-utils.js +410 -0
- package/dist/commands/create.js +121 -0
- package/dist/commands/make-pif-utils/cigar-utils.js +29 -0
- package/dist/commands/make-pif-utils/file-utils.js +38 -0
- package/dist/commands/make-pif-utils/pif-generator.js +64 -0
- package/dist/commands/make-pif-utils/validators.js +22 -0
- package/dist/commands/make-pif.js +58 -0
- package/dist/commands/remove-track.js +58 -0
- package/dist/commands/set-default-session.js +104 -0
- package/dist/commands/sort-bed-utils/constants.js +12 -0
- package/dist/commands/sort-bed-utils/process-utils.js +23 -0
- package/dist/commands/sort-bed-utils/sort-utils.js +24 -0
- package/dist/commands/sort-bed-utils/validators.js +22 -0
- package/dist/commands/sort-bed.js +49 -0
- package/dist/commands/sort-gff-utils/constants.js +13 -0
- package/dist/commands/sort-gff-utils/process-utils.js +23 -0
- package/dist/commands/sort-gff-utils/sort-utils.js +55 -0
- package/dist/commands/sort-gff-utils/validators.js +21 -0
- package/dist/commands/sort-gff.js +49 -0
- package/dist/commands/text-index-utils/adapter-utils.js +63 -0
- package/dist/commands/text-index-utils/aggregate.js +87 -0
- package/dist/commands/text-index-utils/config-utils.js +59 -0
- package/dist/commands/text-index-utils/file-list.js +31 -0
- package/dist/commands/text-index-utils/index.js +9 -0
- package/dist/commands/text-index-utils/indexing-utils.js +84 -0
- package/dist/commands/text-index-utils/per-track.js +65 -0
- package/dist/commands/text-index-utils/validators.js +20 -0
- package/dist/commands/text-index.js +113 -0
- package/dist/commands/track-utils.js +85 -0
- package/dist/commands/upgrade.js +122 -0
- package/dist/index.js +119 -0
- package/dist/utils.js +154 -0
- package/package.json +13 -38
- 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/index.js +0 -6
- package/oclif.manifest.json +0 -1169
- /package/{lib → dist}/fetchWithProxy.js +0 -0
- /package/{lib → dist}/types/common.js +0 -0
- /package/{lib → dist}/types/gff3Adapter.js +0 -0
- /package/{lib → dist}/types/vcfAdapter.js +0 -0
- /package/{lib → dist}/util.js +0 -0
|
@@ -1,170 +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
|
-
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const core_1 = require("@oclif/core");
|
|
9
|
-
const json_parse_better_errors_1 = __importDefault(require("json-parse-better-errors"));
|
|
10
|
-
const base_1 = __importDefault(require("../base"));
|
|
11
|
-
const fetchWithProxy_1 = __importDefault(require("../fetchWithProxy"));
|
|
12
|
-
class AddConnection extends base_1.default {
|
|
13
|
-
async run() {
|
|
14
|
-
const { args: runArgs, flags: runFlags } = await this.parse(AddConnection);
|
|
15
|
-
const output = runFlags.target || runFlags.out || '.';
|
|
16
|
-
const isDir = fs_1.default.lstatSync(output).isDirectory();
|
|
17
|
-
this.target = isDir ? `${output}/config.json` : output;
|
|
18
|
-
const { connectionUrlOrPath } = runArgs;
|
|
19
|
-
const { assemblyNames, type, name, config, connectionId } = runFlags;
|
|
20
|
-
const { skipCheck, force } = runFlags;
|
|
21
|
-
const url = await this.resolveURL(connectionUrlOrPath, !(skipCheck || force));
|
|
22
|
-
const configContents = await this.readJsonFile(this.target);
|
|
23
|
-
this.debug(`Using config file ${this.target}`);
|
|
24
|
-
if (!configContents.assemblies?.length) {
|
|
25
|
-
this.error('No assemblies found. Please add one before adding connections', { exit: 120 });
|
|
26
|
-
}
|
|
27
|
-
const configType = type || this.determineConnectionType(url);
|
|
28
|
-
const id = connectionId ||
|
|
29
|
-
[configType, assemblyNames, +Date.now()].filter(f => !!f).join('-');
|
|
30
|
-
const connectionConfig = {
|
|
31
|
-
type: configType,
|
|
32
|
-
name: name || id,
|
|
33
|
-
...(configType === 'UCSCTrackHubConnection'
|
|
34
|
-
? {
|
|
35
|
-
hubTxtLocation: {
|
|
36
|
-
uri: url,
|
|
37
|
-
locationType: 'UriLocation',
|
|
38
|
-
},
|
|
39
|
-
}
|
|
40
|
-
: {}),
|
|
41
|
-
...(configType === 'JBrowse1Connection'
|
|
42
|
-
? {
|
|
43
|
-
dataDirLocation: {
|
|
44
|
-
uri: url,
|
|
45
|
-
locationType: 'UriLocation',
|
|
46
|
-
},
|
|
47
|
-
}
|
|
48
|
-
: {}),
|
|
49
|
-
connectionId: id,
|
|
50
|
-
assemblyNames: assemblyNames
|
|
51
|
-
? assemblyNames.split(',')
|
|
52
|
-
: type === 'JBrowse1Connection'
|
|
53
|
-
? [configContents.assemblies[0]?.name]
|
|
54
|
-
: undefined,
|
|
55
|
-
...(config ? (0, json_parse_better_errors_1.default)(config) : {}),
|
|
56
|
-
};
|
|
57
|
-
if (!configContents.connections) {
|
|
58
|
-
configContents.connections = [];
|
|
59
|
-
}
|
|
60
|
-
const idx = configContents.connections.findIndex(c => c.connectionId === connectionId);
|
|
61
|
-
if (idx !== -1) {
|
|
62
|
-
if (runFlags.force || runFlags.overwrite) {
|
|
63
|
-
configContents.connections[idx] = connectionConfig;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
this.error(`Cannot add connection with id ${connectionId}, a connection with that id already exists.\nUse --overwrite if you would like to replace the existing connection`, { exit: 150 });
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
configContents.connections.push(connectionConfig);
|
|
71
|
-
}
|
|
72
|
-
this.debug(`Writing configuration to file ${this.target}`);
|
|
73
|
-
await this.writeJsonFile(this.target, configContents);
|
|
74
|
-
this.log(`${idx !== -1 ? 'Overwrote' : 'Added'} connection "${name}" ${idx !== -1 ? 'in' : 'to'} ${this.target}`);
|
|
75
|
-
}
|
|
76
|
-
async resolveURL(location, check = true) {
|
|
77
|
-
let locationUrl;
|
|
78
|
-
try {
|
|
79
|
-
locationUrl = new URL(location);
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
this.error('The location provided is not a valid URL', { exit: 160 });
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
if (check) {
|
|
86
|
-
const response = await (0, fetchWithProxy_1.default)(`${locationUrl}`, { method: 'HEAD' });
|
|
87
|
-
if (!response.ok) {
|
|
88
|
-
this.error(`Response returned with code ${response.status}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return locationUrl.href;
|
|
92
|
-
}
|
|
93
|
-
catch (error) {
|
|
94
|
-
// ignore
|
|
95
|
-
this.error(`Unable to fetch from URL, ${error}`, { exit: 170 });
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
determineConnectionType(url) {
|
|
99
|
-
if (path_1.default.basename(url) === 'hub.txt') {
|
|
100
|
-
return 'UCSCTrackHubConnection';
|
|
101
|
-
}
|
|
102
|
-
if (url.includes('jbrowse/data')) {
|
|
103
|
-
return 'JBrowse1Connection';
|
|
104
|
-
}
|
|
105
|
-
return 'custom';
|
|
106
|
-
}
|
|
107
|
-
isValidJSON(str) {
|
|
108
|
-
try {
|
|
109
|
-
JSON.parse(str);
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
catch (error) {
|
|
113
|
-
return false;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
AddConnection.description = 'Add a connection to a JBrowse 2 configuration';
|
|
118
|
-
AddConnection.examples = [
|
|
119
|
-
'$ jbrowse add-connection http://mysite.com/jbrowse/data/ -a hg19',
|
|
120
|
-
'$ jbrowse add-connection http://mysite.com/jbrowse/custom_data_folder/ --type JBrowse1Connection -a hg38',
|
|
121
|
-
'$ jbrowse add-connection http://mysite.com/path/to/hub.txt',
|
|
122
|
-
'$ jbrowse add-connection http://mysite.com/path/to/custom_hub_name.txt --type UCSCTrackHubConnection',
|
|
123
|
-
`$ jbrowse add-connection http://mysite.com/path/to/custom --type custom --config '{"uri":{"url":"https://mysite.com/path/to/custom"}, "locationType": "UriLocation"}' -a hg19`,
|
|
124
|
-
'$ jbrowse add-connection https://mysite.com/path/to/hub.txt --connectionId newId --name newName --target /path/to/jb2/installation/config.json',
|
|
125
|
-
];
|
|
126
|
-
AddConnection.args = {
|
|
127
|
-
connectionUrlOrPath: core_1.Args.string({
|
|
128
|
-
required: true,
|
|
129
|
-
description: 'URL of data directory\nFor hub file, usually called hub.txt\nFor JBrowse 1, location of JB1 data directory similar to http://mysite.com/jbrowse/data/ ',
|
|
130
|
-
}),
|
|
131
|
-
};
|
|
132
|
-
AddConnection.flags = {
|
|
133
|
-
type: core_1.Flags.string({
|
|
134
|
-
char: 't',
|
|
135
|
-
description: 'type of connection, ex. JBrowse1Connection, UCSCTrackHubConnection, custom',
|
|
136
|
-
}),
|
|
137
|
-
assemblyNames: core_1.Flags.string({
|
|
138
|
-
char: 'a',
|
|
139
|
-
description: 'For UCSC, optional: Comma separated list of assembly name(s) to filter from this connection. For JBrowse: a single assembly name',
|
|
140
|
-
}),
|
|
141
|
-
config: core_1.Flags.string({
|
|
142
|
-
char: 'c',
|
|
143
|
-
description: `Any extra config settings to add to connection in JSON object format, such as '{"uri":"url":"https://sample.com"}, "locationType": "UriLocation"}'`,
|
|
144
|
-
}),
|
|
145
|
-
connectionId: core_1.Flags.string({
|
|
146
|
-
description: `Id for the connection that must be unique to JBrowse. Defaults to 'connectionType-assemblyName-currentTime'`,
|
|
147
|
-
}),
|
|
148
|
-
name: core_1.Flags.string({
|
|
149
|
-
char: 'n',
|
|
150
|
-
description: 'Name of the connection. Defaults to connectionId if not provided',
|
|
151
|
-
}),
|
|
152
|
-
target: core_1.Flags.string({
|
|
153
|
-
description: 'path to config file in JB2 installation directory to write out to.',
|
|
154
|
-
}),
|
|
155
|
-
out: core_1.Flags.string({
|
|
156
|
-
description: 'synonym for target',
|
|
157
|
-
}),
|
|
158
|
-
help: core_1.Flags.help({ char: 'h' }),
|
|
159
|
-
skipCheck: core_1.Flags.boolean({
|
|
160
|
-
description: "Don't check whether or not the data directory URL exists or if you are in a JBrowse directory",
|
|
161
|
-
}),
|
|
162
|
-
overwrite: core_1.Flags.boolean({
|
|
163
|
-
description: 'Overwrites any existing connections if same connection id',
|
|
164
|
-
}),
|
|
165
|
-
force: core_1.Flags.boolean({
|
|
166
|
-
char: 'f',
|
|
167
|
-
description: 'Equivalent to `--skipCheck --overwrite`',
|
|
168
|
-
}),
|
|
169
|
-
};
|
|
170
|
-
exports.default = AddConnection;
|
|
@@ -1,67 +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
|
-
const fs_1 = require("fs");
|
|
7
|
-
const core_1 = require("@oclif/core");
|
|
8
|
-
const base_1 = __importDefault(require("../base"));
|
|
9
|
-
class AddTrackJson extends base_1.default {
|
|
10
|
-
async run() {
|
|
11
|
-
const { args, flags: runFlags } = await this.parse(AddTrackJson);
|
|
12
|
-
const output = runFlags.target || runFlags.out || '.';
|
|
13
|
-
const isDir = (await fs_1.promises.lstat(output)).isDirectory();
|
|
14
|
-
this.target = isDir ? `${output}/config.json` : output;
|
|
15
|
-
const { track: inputtedTrack } = args;
|
|
16
|
-
this.debug(`Sequence location is: ${inputtedTrack}`);
|
|
17
|
-
const { update } = runFlags;
|
|
18
|
-
const config = await this.readJsonFile(this.target);
|
|
19
|
-
this.debug(`Found existing config file ${this.target}`);
|
|
20
|
-
const track = await this.readInlineOrFileJson(inputtedTrack);
|
|
21
|
-
if (!config.tracks) {
|
|
22
|
-
config.tracks = [];
|
|
23
|
-
}
|
|
24
|
-
const idx = config.tracks.findIndex(({ trackId }) => trackId === track.trackId);
|
|
25
|
-
if (idx !== -1) {
|
|
26
|
-
const existing = config.tracks[idx]?.name;
|
|
27
|
-
this.debug(`Found existing track ${existing} in configuration`);
|
|
28
|
-
if (update) {
|
|
29
|
-
this.debug(`Overwriting track ${existing} in configuration`);
|
|
30
|
-
config.tracks[idx] = track;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this.error(`Cannot add track ${track.name}, a track with that trackId already exists: ${existing}`, { exit: 160 });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
config.tracks.push(track);
|
|
38
|
-
}
|
|
39
|
-
this.debug(`Writing configuration to file ${this.target}`);
|
|
40
|
-
await this.writeJsonFile(this.target, config);
|
|
41
|
-
this.log(`${idx !== -1 ? 'Overwrote' : 'Added'} assembly "${track.name}" ${idx !== -1 ? 'in' : 'to'} ${this.target}`);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
AddTrackJson.description = 'Add a track configuration directly from a JSON hunk to the JBrowse 2 configuration';
|
|
45
|
-
AddTrackJson.examples = [
|
|
46
|
-
'$ jbrowse add-track-json track.json',
|
|
47
|
-
'$ jbrowse add-track-json track.json --update',
|
|
48
|
-
];
|
|
49
|
-
AddTrackJson.args = {
|
|
50
|
-
track: core_1.Args.string({
|
|
51
|
-
required: true,
|
|
52
|
-
description: 'track JSON file or command line arg blob',
|
|
53
|
-
}),
|
|
54
|
-
};
|
|
55
|
-
AddTrackJson.flags = {
|
|
56
|
-
update: core_1.Flags.boolean({
|
|
57
|
-
char: 'u',
|
|
58
|
-
description: 'update the contents of an existing track, matched based on trackId',
|
|
59
|
-
}),
|
|
60
|
-
target: core_1.Flags.string({
|
|
61
|
-
description: 'path to config file in JB2 installation directory to write out to.\nCreates ./config.json if nonexistent',
|
|
62
|
-
}),
|
|
63
|
-
out: core_1.Flags.string({
|
|
64
|
-
description: 'synonym for target',
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
exports.default = AddTrackJson;
|