@jbrowse/cli 1.4.3 → 1.5.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 CHANGED
@@ -4,7 +4,7 @@ id: cli
4
4
  toplevel: true
5
5
  ---
6
6
 
7
- This document covers the CLI tools.
7
+ This document covers the CLI tools. Note: for @jbrowse/img static export tool, see https://www.npmjs.com/package/@jbrowse/img
8
8
 
9
9
  ## Installation
10
10
 
@@ -131,16 +131,33 @@ OPTIONS
131
131
  Creates ./config.json if nonexistent
132
132
 
133
133
  EXAMPLES
134
+ # add assembly to installation in current directory. assumes .fai file also exists, and copies GRCh38.fa and
135
+ GRCh38.fa.fai to current directory
134
136
  $ jbrowse add-assembly GRCh38.fa --load copy
135
- $ jbrowse add-assembly GRCh38.fasta.with.custom.extension.xyz --type indexedFasta --load move
136
- $ jbrowse add-assembly myFile.fa.gz --name hg38 --alias GRCh38 --displayName "Homo sapiens (hg38)" --load inPlace
137
+
138
+ # add assembly to a specific jb2 installation path using --out, and copies the .fa and .fa.fai file to /path/to/jb2
139
+ $ jbrowse add-assembly GRCh38.fa --out /path/to/jb2/ --load copy
140
+
141
+ # force indexedFasta for add-assembly without relying on file extension
142
+ $ jbrowse add-assembly GRCh38.xyz --type indexedFasta --load copy
143
+
144
+ # add displayName for an assembly
145
+ $ jbrowse add-assembly myFile.fa.gz --name hg38 --displayName "Homo sapiens (hg38)"
146
+
147
+ # use chrom.sizes file for assembly instead of a fasta file
137
148
  $ jbrowse add-assembly GRCh38.chrom.sizes --load inPlace
149
+
150
+ # add assembly from preconfigured json file, expert option
138
151
  $ jbrowse add-assembly GRCh38.config.json --load copy
152
+
153
+ # add assembly from a 2bit file, also note pointing direct to a URL so no --load flag needed
139
154
  $ jbrowse add-assembly https://example.com/data/sample.2bit
140
- $ jbrowse add-assembly GRCh38.fa --target /path/to/jb2/installation/customconfig.json --load copy
155
+
156
+ # add a bgzip indexed fasta inferred by fa.gz extension. assumes .fa.gz.gzi and .fa.gz.fai files also exists
157
+ $ jbrowse add-assembly myfile.fa.gz --load copy
141
158
  ```
142
159
 
143
- _See code: [src/commands/add-assembly.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/add-assembly.ts)_
160
+ _See code: [src/commands/add-assembly.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/add-assembly.ts)_
144
161
 
145
162
  ## `jbrowse add-connection CONNECTIONURLORPATH`
146
163
 
@@ -160,7 +177,7 @@ OPTIONS
160
177
  file
161
178
 
162
179
  -c, --config=config Any extra config settings to add to connection in JSON object format, such as
163
- '{"uri":"url":"https://sample.com"}}'
180
+ '{"uri":"url":"https://sample.com"}, "locationType": "UriLocation"}'
164
181
 
165
182
  -f, --force Equivalent to `--skipCheck --overwrite`
166
183
 
@@ -189,12 +206,12 @@ EXAMPLES
189
206
  $ jbrowse add-connection http://mysite.com/path/to/custom_hub_name.txt --type UCSCTrackHubConnection --assemblyName
190
207
  hg19
191
208
  $ jbrowse add-connection http://mysite.com/path/to/custom --type custom --config
192
- '{"uri":{"url":"https://mysite.com/path/to/custom"}}' --assemblyName hg19
209
+ '{"uri":{"url":"https://mysite.com/path/to/custom"}, "locationType": "UriLocation"}' --assemblyName hg19
193
210
  $ jbrowse add-connection https://mysite.com/path/to/hub.txt --connectionId newId --name newName --target
194
211
  /path/to/jb2/installation/config.json
195
212
  ```
196
213
 
197
- _See code: [src/commands/add-connection.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/add-connection.ts)_
214
+ _See code: [src/commands/add-connection.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/add-connection.ts)_
198
215
 
199
216
  ## `jbrowse add-track TRACK`
200
217
 
@@ -249,26 +266,26 @@ OPTIONS
249
266
  throughout config
250
267
 
251
268
  EXAMPLES
252
- # --load copy copies my.bam and my.bam.bai to current directory and adds track to config.json
269
+ # copy /path/to/my.bam and /path/to/my.bam.bai to current directory and adds track to config.json
253
270
  $ jbrowse add-track /path/to/my.bam --load copy
254
271
 
255
- # same as above, but specify path to bai file
256
- $ jbrowse add-track /path/to/my.bam --indexFile /path/to/my.bai --load copy
272
+ # copy my.bam and my.bam.bai to /path/to/jb2/bam and adds track entry to /path/to/jb2/bam/config.json
273
+ $ jbrowse add-track my.bam --load copy --out /path/to/jb2 --subDir bam
257
274
 
258
- # --load symlink creates symlink in /path/to/jb2/ directory for this file, and adds track to config.json
259
- $ jbrowse add-track /path/to/my.bam --target /path/to/jb2/config.json --load symlink
275
+ # same as above, but specify path to bai file. needed for if the bai file does not have the extension .bam.bai
276
+ $ jbrowse add-track my.bam --indexFile my.bai --load copy
260
277
 
261
- # no --load flag to add literal URL for this track to config.json
262
- $ jbrowse add-track https://mywebsite.com/my.bam
278
+ # creates symlink for /path/to/my.bam and adds track to config.json
279
+ $ jbrowse add-track /path/to/my.bam --load symlink
263
280
 
264
- # --load move to move the file
265
- $ jbrowse add-track /path/to/my.bam --name 'New Track' --load move
281
+ # add track from URL to config.json, no --load flag needed
282
+ $ jbrowse add-track https://mywebsite.com/my.bam
266
283
 
267
- # --load inPlace puts /url/relative/path.bam in the config without performing any file operations
268
- $ jbrowse add-track /url/relative/path.bam --trackId AlignmentsTrack1 --load url --overwrite
284
+ # --load inPlace adds a track without doing file operations
285
+ $ jbrowse add-track /url/relative/path.bam --load inPlace
269
286
  ```
270
287
 
271
- _See code: [src/commands/add-track.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/add-track.ts)_
288
+ _See code: [src/commands/add-track.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/add-track.ts)_
272
289
 
273
290
  ## `jbrowse add-track-json TRACK`
274
291
 
@@ -293,7 +310,7 @@ EXAMPLES
293
310
  $ jbrowse add-track-json track.json --update
294
311
  ```
295
312
 
296
- _See code: [src/commands/add-track-json.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/add-track-json.ts)_
313
+ _See code: [src/commands/add-track-json.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/add-track-json.ts)_
297
314
 
298
315
  ## `jbrowse admin-server`
299
316
 
@@ -311,8 +328,6 @@ OPTIONS
311
328
 
312
329
  --out=out synonym for target
313
330
 
314
- --skipCheck Don't check whether or not you are in a JBrowse directory
315
-
316
331
  --target=target path to config file in JB2 installation directory to write out to.
317
332
  Creates ./config.json if nonexistent
318
333
 
@@ -321,7 +336,7 @@ EXAMPLES
321
336
  $ jbrowse admin-server -p 8888
322
337
  ```
323
338
 
324
- _See code: [src/commands/admin-server.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/admin-server.ts)_
339
+ _See code: [src/commands/admin-server.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/admin-server.ts)_
325
340
 
326
341
  ## `jbrowse create LOCALPATH`
327
342
 
@@ -349,14 +364,23 @@ OPTIONS
349
364
  --nightly Download the latest development build from the main branch
350
365
 
351
366
  EXAMPLES
367
+ # Download latest release from github, and put in specific path
352
368
  $ jbrowse create /path/to/new/installation
369
+
370
+ # Download latest release from github and force overwrite existing contents at path
353
371
  $ jbrowse create /path/to/new/installation --force
372
+
373
+ # Download latest release from a specific URL
354
374
  $ jbrowse create /path/to/new/installation --url url.com/directjbrowselink.zip
375
+
376
+ # Download a specific tag from github
355
377
  $ jbrowse create /path/to/new/installation --tag v1.0.0
356
- $ jbrowse create --listVersions # Lists out all available versions of JBrowse 2
378
+
379
+ # List available versions
380
+ $ jbrowse create --listVersions
357
381
  ```
358
382
 
359
- _See code: [src/commands/create.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/create.ts)_
383
+ _See code: [src/commands/create.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/create.ts)_
360
384
 
361
385
  ## `jbrowse help [COMMAND]`
362
386
 
@@ -373,7 +397,7 @@ OPTIONS
373
397
  --all see all commands in CLI
374
398
  ```
375
399
 
376
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.0/src/commands/help.ts)_
400
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.2.3/src/commands/help.ts)_
377
401
 
378
402
  ## `jbrowse set-default-session`
379
403
 
@@ -410,7 +434,7 @@ EXAMPLES
410
434
  $ jbrowse set-default-session --currentSession # Prints out current default session
411
435
  ```
412
436
 
413
- _See code: [src/commands/set-default-session.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/set-default-session.ts)_
437
+ _See code: [src/commands/set-default-session.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/set-default-session.ts)_
414
438
 
415
439
  ## `jbrowse text-index`
416
440
 
@@ -466,7 +490,7 @@ EXAMPLES
466
490
  $ jbrowse text-index --file myfile.gff3.gz --file myfile.vcfgz --out indexes
467
491
  ```
468
492
 
469
- _See code: [src/commands/text-index.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/text-index.ts)_
493
+ _See code: [src/commands/text-index.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/text-index.ts)_
470
494
 
471
495
  ## `jbrowse upgrade [LOCALPATH]`
472
496
 
@@ -493,14 +517,26 @@ OPTIONS
493
517
  --nightly Download the latest development build from the main branch
494
518
 
495
519
  EXAMPLES
496
- $ jbrowse upgrade # Upgrades current directory to latest jbrowse release
520
+ # Upgrades current directory to latest jbrowse release
521
+ $ jbrowse upgrade
522
+
523
+ # Upgrade jbrowse instance at a specific filesystem path
497
524
  $ jbrowse upgrade /path/to/jbrowse2/installation
525
+
526
+ # Upgrade to a specific tag
498
527
  $ jbrowse upgrade /path/to/jbrowse2/installation --tag v1.0.0
499
- $ jbrowse upgrade --listVersions # Lists out all available versions of JBrowse 2
528
+
529
+ # List versions available on github
530
+ $ jbrowse upgrade --listVersions
531
+
532
+ # Upgrade from a specific URL
500
533
  $ jbrowse upgrade --url https://sample.com/jbrowse2.zip
534
+
535
+ # Get nightly release from main branch
536
+ $ jbrowse upgrade --nightly
501
537
  ```
502
538
 
503
- _See code: [src/commands/upgrade.ts](https://github.com/GMOD/jbrowse-components/blob/v1.4.3/products/jbrowse-cli/src/commands/upgrade.ts)_
539
+ _See code: [src/commands/upgrade.ts](https://github.com/GMOD/jbrowse-components/blob/v1.5.2/products/jbrowse-cli/src/commands/upgrade.ts)_
504
540
 
505
541
  <!-- commandsstop -->
506
542
 
package/lib/base.d.ts CHANGED
@@ -4,14 +4,15 @@
4
4
  import Command from '@oclif/command';
5
5
  export interface UriLocation {
6
6
  uri: string;
7
+ locationType: 'UriLocation';
7
8
  }
8
9
  export interface Gff3TabixAdapter {
9
10
  type: 'Gff3TabixAdapter';
10
11
  gffGzLocation: UriLocation;
11
12
  }
12
- export interface GtfTabixAdapter {
13
- type: 'GtfTabixAdapter';
14
- gtfGzLocation: UriLocation;
13
+ export interface GtfAdapter {
14
+ type: 'GtfAdapter';
15
+ gtfLocation: UriLocation;
15
16
  }
16
17
  export interface VcfTabixAdapter {
17
18
  type: 'VcfTabixAdapter';
@@ -78,7 +79,7 @@ export interface Track {
78
79
  trackId: string;
79
80
  name: string;
80
81
  assemblyNames: string[];
81
- adapter: Gff3TabixAdapter | GtfTabixAdapter | VcfTabixAdapter;
82
+ adapter: Gff3TabixAdapter | GtfAdapter | VcfTabixAdapter;
82
83
  textSearching?: TextSearching;
83
84
  }
84
85
  export interface Config {
@@ -93,9 +94,12 @@ export interface Config {
93
94
  interface GithubRelease {
94
95
  tag_name: string;
95
96
  prerelease: boolean;
96
- assets?: [{
97
- browser_download_url: string;
98
- }];
97
+ assets?: [
98
+ {
99
+ browser_download_url: string;
100
+ name: string;
101
+ }
102
+ ];
99
103
  }
100
104
  export default abstract class JBrowseCommand extends Command {
101
105
  init(): Promise<void>;
@@ -107,7 +111,7 @@ export default abstract class JBrowseCommand extends Command {
107
111
  fetchGithubVersions(): Promise<GithubRelease[]>;
108
112
  getLatest(): Promise<string>;
109
113
  fetchVersions(): AsyncGenerator<GithubRelease[], void, unknown>;
110
- getTag(tag: string): Promise<any>;
114
+ getTag(tag: string): Promise<string>;
111
115
  getBranch(branch: string): Promise<string>;
112
116
  }
113
117
  export {};
package/lib/base.js CHANGED
@@ -4,11 +4,11 @@
4
4
  */
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const tslib_1 = require("tslib");
7
- const command_1 = tslib_1.__importDefault(require("@oclif/command"));
7
+ const command_1 = (0, tslib_1.__importDefault)(require("@oclif/command"));
8
8
  const fs_1 = require("fs");
9
- const path_1 = tslib_1.__importDefault(require("path"));
10
- const json_parse_better_errors_1 = tslib_1.__importDefault(require("json-parse-better-errors"));
11
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
9
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
10
+ const json_parse_better_errors_1 = (0, tslib_1.__importDefault)(require("json-parse-better-errors"));
11
+ const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
12
12
  class JBrowseCommand extends command_1.default {
13
13
  async init() { }
14
14
  async readFile(location) {
@@ -20,7 +20,7 @@ class JBrowseCommand extends command_1.default {
20
20
  contents = await fs_1.promises.readFile(location, { encoding: 'utf8' });
21
21
  }
22
22
  catch (error) {
23
- this.error(error instanceof Error ? error : error.message, {
23
+ this.error(error instanceof Error ? error : `${error}`, {
24
24
  suggestions: [
25
25
  `Make sure the file "${location}" exists or use --out to point to a directory with a config.json`,
26
26
  'Run `jbrowse add-assembly` to create a config file',
@@ -30,10 +30,10 @@ class JBrowseCommand extends command_1.default {
30
30
  }
31
31
  let result;
32
32
  try {
33
- result = json_parse_better_errors_1.default(contents);
33
+ result = (0, json_parse_better_errors_1.default)(contents);
34
34
  }
35
35
  catch (error) {
36
- this.error(error instanceof Error ? error : error.message, {
36
+ this.error(error instanceof Error ? error : `${error}`, {
37
37
  suggestions: [`Make sure "${location}" is a valid JSON file`],
38
38
  exit: 50,
39
39
  });
@@ -55,7 +55,7 @@ class JBrowseCommand extends command_1.default {
55
55
  }
56
56
  if (locationUrl) {
57
57
  if (check) {
58
- const response = await node_fetch_1.default(locationUrl, { method: 'HEAD' });
58
+ const response = await (0, node_fetch_1.default)(locationUrl, { method: 'HEAD' });
59
59
  if (!response.ok) {
60
60
  throw new Error(`${locationUrl} result ${response.statusText}`);
61
61
  }
@@ -89,7 +89,7 @@ class JBrowseCommand extends command_1.default {
89
89
  let result;
90
90
  // see if it's inline JSON
91
91
  try {
92
- result = json_parse_better_errors_1.default(inlineOrFileName);
92
+ result = (0, json_parse_better_errors_1.default)(inlineOrFileName);
93
93
  }
94
94
  catch (error) {
95
95
  this.debug(`Not valid inline JSON, attempting to parse as filename: '${inlineOrFileName}'`);
@@ -102,7 +102,7 @@ class JBrowseCommand extends command_1.default {
102
102
  var e_1, _a;
103
103
  let versions = [];
104
104
  try {
105
- for (var _b = tslib_1.__asyncValues(this.fetchVersions()), _c; _c = await _b.next(), !_c.done;) {
105
+ for (var _b = (0, tslib_1.__asyncValues)(this.fetchVersions()), _c; _c = await _b.next(), !_c.done;) {
106
106
  const iter = _c.value;
107
107
  versions = versions.concat(iter);
108
108
  }
@@ -118,9 +118,10 @@ class JBrowseCommand extends command_1.default {
118
118
  }
119
119
  async getLatest() {
120
120
  var e_2, _a;
121
+ var _b;
121
122
  try {
122
- for (var _b = tslib_1.__asyncValues(this.fetchVersions()), _c; _c = await _b.next(), !_c.done;) {
123
- const versions = _c.value;
123
+ for (var _c = (0, tslib_1.__asyncValues)(this.fetchVersions()), _d; _d = await _c.next(), !_d.done;) {
124
+ const versions = _d.value;
124
125
  // if a release was just uploaded, or an erroneous build was made
125
126
  // then it might have no build asset
126
127
  const nonprereleases = versions
@@ -128,28 +129,32 @@ class JBrowseCommand extends command_1.default {
128
129
  .filter(release => release.assets && release.assets.length > 0);
129
130
  if (nonprereleases.length !== 0) {
130
131
  // @ts-ignore
131
- return nonprereleases[0].assets[0].browser_download_url;
132
+ const file = (_b = nonprereleases[0].assets.find(f => f.name.includes('jbrowse-web'))) === null || _b === void 0 ? void 0 : _b.browser_download_url;
133
+ if (!file) {
134
+ throw new Error('no jbrowse-web download found');
135
+ }
136
+ return file;
132
137
  }
133
138
  }
134
139
  }
135
140
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
136
141
  finally {
137
142
  try {
138
- if (_c && !_c.done && (_a = _b.return)) await _a.call(_b);
143
+ if (_d && !_d.done && (_a = _c.return)) await _a.call(_c);
139
144
  }
140
145
  finally { if (e_2) throw e_2.error; }
141
146
  }
142
147
  throw new Error('no version tags found');
143
148
  }
144
149
  fetchVersions() {
145
- return tslib_1.__asyncGenerator(this, arguments, function* fetchVersions_1() {
150
+ return (0, tslib_1.__asyncGenerator)(this, arguments, function* fetchVersions_1() {
146
151
  let page = 1;
147
152
  let result;
148
153
  do {
149
- const response = yield tslib_1.__await(node_fetch_1.default(`https://api.github.com/repos/GMOD/jbrowse-components/releases?page=${page}`));
154
+ const response = yield (0, tslib_1.__await)((0, node_fetch_1.default)(`https://api.github.com/repos/GMOD/jbrowse-components/releases?page=${page}`));
150
155
  if (response.ok) {
151
- result = (yield tslib_1.__await(response.json()));
152
- yield yield tslib_1.__await(result.filter(release => release.tag_name.startsWith('v')));
156
+ result = (yield (0, tslib_1.__await)(response.json()));
157
+ yield yield (0, tslib_1.__await)(result.filter(release => release.tag_name.startsWith('v')));
153
158
  page++;
154
159
  }
155
160
  else {
@@ -159,12 +164,15 @@ class JBrowseCommand extends command_1.default {
159
164
  });
160
165
  }
161
166
  async getTag(tag) {
162
- const response = await node_fetch_1.default(`https://api.github.com/repos/GMOD/jbrowse-components/releases/tags/${tag}`);
167
+ var _a, _b;
168
+ const response = await (0, node_fetch_1.default)(`https://api.github.com/repos/GMOD/jbrowse-components/releases/tags/${tag}`);
163
169
  if (response.ok) {
164
- const result = await response.json();
165
- return result && result.assets
166
- ? result.assets[0].browser_download_url
167
- : this.error('Could not find version specified. Use --listVersions to see all available versions', { exit: 90 });
170
+ const result = (await response.json());
171
+ const file = (_b = (_a = result === null || result === void 0 ? void 0 : result.assets) === null || _a === void 0 ? void 0 : _a.find(f => f.name.includes('jbrowse-web'))) === null || _b === void 0 ? void 0 : _b.browser_download_url;
172
+ if (!file) {
173
+ this.error('Could not find version specified. Use --listVersions to see all available versions', { exit: 90 });
174
+ }
175
+ return file;
168
176
  }
169
177
  return this.error(`Error: Could not find version: ${response.statusText}`, {
170
178
  exit: 90,
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
- const fs_1 = tslib_1.__importDefault(require("fs"));
6
- const path_1 = tslib_1.__importDefault(require("path"));
7
- const base_1 = tslib_1.__importDefault(require("../base"));
8
- const fsPromises = fs_1.default.promises;
5
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
6
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
7
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
8
+ const { rename, copyFile, mkdir, symlink } = fs_1.default.promises;
9
9
  function isValidJSON(string) {
10
10
  try {
11
11
  JSON.parse(string);
@@ -68,8 +68,11 @@ class AddAssembly extends base_1.default {
68
68
  trackId: `${name}-ReferenceSequenceTrack`,
69
69
  adapter: {
70
70
  type: 'IndexedFastaAdapter',
71
- fastaLocation: { uri: sequenceLocation },
72
- faiLocation: { uri: indexLocation },
71
+ fastaLocation: {
72
+ uri: sequenceLocation,
73
+ locationType: 'UriLocation',
74
+ },
75
+ faiLocation: { uri: indexLocation, locationType: 'UriLocation' },
73
76
  },
74
77
  };
75
78
  break;
@@ -107,9 +110,15 @@ class AddAssembly extends base_1.default {
107
110
  trackId: `${name}-ReferenceSequenceTrack`,
108
111
  adapter: {
109
112
  type: 'BgzipFastaAdapter',
110
- fastaLocation: { uri: sequenceLocation },
111
- faiLocation: { uri: indexLocation },
112
- gziLocation: { uri: bgzipIndexLocation },
113
+ fastaLocation: {
114
+ uri: sequenceLocation,
115
+ locationType: 'UriLocation',
116
+ },
117
+ faiLocation: { uri: indexLocation, locationType: 'UriLocation' },
118
+ gziLocation: {
119
+ uri: bgzipIndexLocation,
120
+ locationType: 'UriLocation',
121
+ },
113
122
  },
114
123
  };
115
124
  break;
@@ -132,7 +141,10 @@ class AddAssembly extends base_1.default {
132
141
  trackId: `${name}-ReferenceSequenceTrack`,
133
142
  adapter: {
134
143
  type: 'TwoBitAdapter',
135
- twoBitLocation: { uri: sequenceLocation },
144
+ twoBitLocation: {
145
+ uri: sequenceLocation,
146
+ locationType: 'UriLocation',
147
+ },
136
148
  },
137
149
  };
138
150
  break;
@@ -155,7 +167,10 @@ class AddAssembly extends base_1.default {
155
167
  trackId: `${name}-ReferenceSequenceTrack`,
156
168
  adapter: {
157
169
  type: 'ChromSizesAdapter',
158
- chromSizesLocation: { uri: sequenceLocation },
170
+ chromSizesLocation: {
171
+ uri: sequenceLocation,
172
+ locationType: 'UriLocation',
173
+ },
159
174
  },
160
175
  };
161
176
  break;
@@ -191,7 +206,7 @@ class AddAssembly extends base_1.default {
191
206
  const { args: runArgs, flags: runFlags } = this.parse(AddAssembly);
192
207
  const output = runFlags.target || runFlags.out || '.';
193
208
  if (!(await exists(output))) {
194
- await fsPromises.mkdir(output, { recursive: true });
209
+ await mkdir(output, { recursive: true });
195
210
  }
196
211
  const isDir = fs_1.default.statSync(output).isDirectory();
197
212
  this.target = isDir ? `${output}/config.json` : output;
@@ -228,7 +243,10 @@ class AddAssembly extends base_1.default {
228
243
  assembly.refNameAliases = {
229
244
  adapter: {
230
245
  type: 'RefNameAliasAdapter',
231
- location: { uri: refNameAliasesLocation },
246
+ location: {
247
+ uri: refNameAliasesLocation,
248
+ locationType: 'UriLocation',
249
+ },
232
250
  },
233
251
  };
234
252
  }
@@ -329,7 +347,7 @@ class AddAssembly extends base_1.default {
329
347
  if (!filePath) {
330
348
  return undefined;
331
349
  }
332
- return fsPromises.copyFile(filePath, path_1.default.join(path_1.default.dirname(destination), path_1.default.basename(filePath)));
350
+ return copyFile(filePath, path_1.default.join(path_1.default.dirname(destination), path_1.default.basename(filePath)));
333
351
  }));
334
352
  return true;
335
353
  }
@@ -338,7 +356,7 @@ class AddAssembly extends base_1.default {
338
356
  if (!filePath) {
339
357
  return undefined;
340
358
  }
341
- return fsPromises.symlink(filePath, path_1.default.join(path_1.default.dirname(destination), path_1.default.basename(filePath)));
359
+ return symlink(filePath, path_1.default.join(path_1.default.dirname(destination), path_1.default.basename(filePath)));
342
360
  }));
343
361
  return true;
344
362
  }
@@ -347,7 +365,7 @@ class AddAssembly extends base_1.default {
347
365
  if (!filePath) {
348
366
  return undefined;
349
367
  }
350
- return fsPromises.rename(filePath, path_1.default.join(path_1.default.dirname(destination), path_1.default.basename(filePath)));
368
+ return rename(filePath, path_1.default.join(path_1.default.dirname(destination), path_1.default.basename(filePath)));
351
369
  }));
352
370
  return true;
353
371
  }
@@ -361,13 +379,29 @@ class AddAssembly extends base_1.default {
361
379
  exports.default = AddAssembly;
362
380
  AddAssembly.description = 'Add an assembly to a JBrowse 2 configuration';
363
381
  AddAssembly.examples = [
382
+ '# add assembly to installation in current directory. assumes .fai file also exists, and copies GRCh38.fa and GRCh38.fa.fai to current directory',
364
383
  '$ jbrowse add-assembly GRCh38.fa --load copy',
365
- '$ jbrowse add-assembly GRCh38.fasta.with.custom.extension.xyz --type indexedFasta --load move',
366
- '$ jbrowse add-assembly myFile.fa.gz --name hg38 --alias GRCh38 --displayName "Homo sapiens (hg38)" --load inPlace',
384
+ '',
385
+ '# add assembly to a specific jb2 installation path using --out, and copies the .fa and .fa.fai file to /path/to/jb2',
386
+ '$ jbrowse add-assembly GRCh38.fa --out /path/to/jb2/ --load copy',
387
+ '',
388
+ '# force indexedFasta for add-assembly without relying on file extension',
389
+ '$ jbrowse add-assembly GRCh38.xyz --type indexedFasta --load copy',
390
+ '',
391
+ '# add displayName for an assembly',
392
+ '$ jbrowse add-assembly myFile.fa.gz --name hg38 --displayName "Homo sapiens (hg38)"',
393
+ '',
394
+ '# use chrom.sizes file for assembly instead of a fasta file',
367
395
  '$ jbrowse add-assembly GRCh38.chrom.sizes --load inPlace',
396
+ '',
397
+ '# add assembly from preconfigured json file, expert option',
368
398
  '$ jbrowse add-assembly GRCh38.config.json --load copy',
399
+ '',
400
+ '# add assembly from a 2bit file, also note pointing direct to a URL so no --load flag needed',
369
401
  '$ jbrowse add-assembly https://example.com/data/sample.2bit',
370
- '$ jbrowse add-assembly GRCh38.fa --target /path/to/jb2/installation/customconfig.json --load copy',
402
+ '',
403
+ '# add a bgzip indexed fasta inferred by fa.gz extension. assumes .fa.gz.gzi and .fa.gz.fai files also exists',
404
+ '$ jbrowse add-assembly myfile.fa.gz --load copy',
371
405
  ];
372
406
  AddAssembly.args = [
373
407
  {
@@ -2,17 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
- const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
- const fs_1 = tslib_1.__importDefault(require("fs"));
7
- const path_1 = tslib_1.__importDefault(require("path"));
8
- const json_parse_better_errors_1 = tslib_1.__importDefault(require("json-parse-better-errors"));
9
- const base_1 = tslib_1.__importDefault(require("../base"));
10
- const fsPromises = fs_1.default.promises;
5
+ const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
6
+ const fs_1 = (0, tslib_1.__importDefault)(require("fs"));
7
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
8
+ const json_parse_better_errors_1 = (0, tslib_1.__importDefault)(require("json-parse-better-errors"));
9
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
11
10
  class AddConnection extends base_1.default {
12
11
  async run() {
13
12
  const { args: runArgs, flags: runFlags } = this.parse(AddConnection);
14
13
  const output = runFlags.target || runFlags.out || '.';
15
- const isDir = (await fsPromises.lstat(output)).isDirectory();
14
+ const isDir = fs_1.default.lstatSync(output).isDirectory();
16
15
  this.target = isDir ? `${output}/config.json` : output;
17
16
  const { connectionUrlOrPath: argsPath } = runArgs;
18
17
  const { config } = runFlags;
@@ -56,7 +55,7 @@ class AddConnection extends base_1.default {
56
55
  let configObj = {};
57
56
  if (config) {
58
57
  try {
59
- configObj = json_parse_better_errors_1.default(config);
58
+ configObj = (0, json_parse_better_errors_1.default)(config);
60
59
  }
61
60
  catch (error) {
62
61
  this.error('Could not parse provided JSON object');
@@ -66,11 +65,17 @@ class AddConnection extends base_1.default {
66
65
  connectionId, name: name || connectionId, assemblyName }, configObj);
67
66
  switch (type) {
68
67
  case 'UCSCTrackHubConnection': {
69
- connectionConfig.hubTxtLocation = { uri: url };
68
+ connectionConfig.hubTxtLocation = {
69
+ uri: url,
70
+ locationType: 'UriLocation',
71
+ };
70
72
  break;
71
73
  }
72
74
  case 'JBrowse1Connection': {
73
- connectionConfig.dataDirLocation = { uri: url };
75
+ connectionConfig.dataDirLocation = {
76
+ uri: url,
77
+ locationType: 'UriLocation',
78
+ };
74
79
  break;
75
80
  }
76
81
  default: {
@@ -113,7 +118,7 @@ class AddConnection extends base_1.default {
113
118
  let response;
114
119
  try {
115
120
  if (check) {
116
- response = await node_fetch_1.default(locationUrl, { method: 'HEAD' });
121
+ response = await (0, node_fetch_1.default)(locationUrl, { method: 'HEAD' });
117
122
  }
118
123
  if (!response || response.ok) {
119
124
  return locationUrl.href;
@@ -158,7 +163,7 @@ AddConnection.examples = [
158
163
  '$ jbrowse add-connection http://mysite.com/jbrowse/custom_data_folder/ --type JBrowse1Connection',
159
164
  '$ jbrowse add-connection http://mysite.com/path/to/hub.txt --assemblyName hg19',
160
165
  '$ jbrowse add-connection http://mysite.com/path/to/custom_hub_name.txt --type UCSCTrackHubConnection --assemblyName hg19',
161
- `$ jbrowse add-connection http://mysite.com/path/to/custom --type custom --config '{"uri":{"url":"https://mysite.com/path/to/custom"}}' --assemblyName hg19`,
166
+ `$ jbrowse add-connection http://mysite.com/path/to/custom --type custom --config '{"uri":{"url":"https://mysite.com/path/to/custom"}, "locationType": "UriLocation"}' --assemblyName hg19`,
162
167
  '$ jbrowse add-connection https://mysite.com/path/to/hub.txt --connectionId newId --name newName --target /path/to/jb2/installation/config.json',
163
168
  ];
164
169
  AddConnection.args = [
@@ -179,7 +184,7 @@ AddConnection.flags = {
179
184
  }),
180
185
  config: command_1.flags.string({
181
186
  char: 'c',
182
- description: `Any extra config settings to add to connection in JSON object format, such as '{"uri":"url":"https://sample.com"}}'`,
187
+ description: `Any extra config settings to add to connection in JSON object format, such as '{"uri":"url":"https://sample.com"}, "locationType": "UriLocation"}'`,
183
188
  }),
184
189
  connectionId: command_1.flags.string({
185
190
  description: `Id for the connection that must be unique to JBrowse. Defaults to 'connectionType-assemblyName-currentTime'`,
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  const command_1 = require("@oclif/command");
5
5
  const fs_1 = require("fs");
6
- const base_1 = tslib_1.__importDefault(require("../base"));
6
+ const base_1 = (0, tslib_1.__importDefault)(require("../base"));
7
7
  class AddTrackJson extends base_1.default {
8
8
  async run() {
9
9
  const { args, flags: runFlags } = this.parse(AddTrackJson);