@jbrowse/cli 2.9.0 → 2.10.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 CHANGED
@@ -54,6 +54,7 @@ It is likely preferable in most cases to install the tools globally with
54
54
  - [`jbrowse admin-server`](#jbrowse-admin-server)
55
55
  - [`jbrowse create LOCALPATH`](#jbrowse-create-localpath)
56
56
  - [`jbrowse help [COMMANDS]`](#jbrowse-help-commands)
57
+ - [`jbrowse make-pif FILE`](#jbrowse-make-pif-file)
57
58
  - [`jbrowse remove-track TRACK`](#jbrowse-remove-track-track)
58
59
  - [`jbrowse set-default-session`](#jbrowse-set-default-session)
59
60
  - [`jbrowse sort-gff FILE`](#jbrowse-sort-gff-file)
@@ -204,7 +205,7 @@ EXAMPLES
204
205
  ```
205
206
 
206
207
  _See code:
207
- [src/commands/add-assembly.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/add-assembly.ts)_
208
+ [src/commands/add-assembly.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/add-assembly.ts)_
208
209
 
209
210
  ## `jbrowse add-connection CONNECTIONURLORPATH`
210
211
 
@@ -255,7 +256,7 @@ EXAMPLES
255
256
  ```
256
257
 
257
258
  _See code:
258
- [src/commands/add-connection.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/add-connection.ts)_
259
+ [src/commands/add-connection.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/add-connection.ts)_
259
260
 
260
261
  ## `jbrowse add-track TRACK`
261
262
 
@@ -336,7 +337,7 @@ EXAMPLES
336
337
  ```
337
338
 
338
339
  _See code:
339
- [src/commands/add-track.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/add-track.ts)_
340
+ [src/commands/add-track.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/add-track.ts)_
340
341
 
341
342
  ## `jbrowse add-track-json TRACK`
342
343
 
@@ -366,7 +367,7 @@ EXAMPLES
366
367
  ```
367
368
 
368
369
  _See code:
369
- [src/commands/add-track-json.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/add-track-json.ts)_
370
+ [src/commands/add-track-json.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/add-track-json.ts)_
370
371
 
371
372
  ## `jbrowse admin-server`
372
373
 
@@ -398,7 +399,7 @@ EXAMPLES
398
399
  ```
399
400
 
400
401
  _See code:
401
- [src/commands/admin-server.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/admin-server.ts)_
402
+ [src/commands/admin-server.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/admin-server.ts)_
402
403
 
403
404
  ## `jbrowse create LOCALPATH`
404
405
 
@@ -455,7 +456,7 @@ EXAMPLES
455
456
  ```
456
457
 
457
458
  _See code:
458
- [src/commands/create.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/create.ts)_
459
+ [src/commands/create.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/create.ts)_
459
460
 
460
461
  ## `jbrowse help [COMMANDS]`
461
462
 
@@ -478,6 +479,36 @@ DESCRIPTION
478
479
  _See code:
479
480
  [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v5.2.20/src/commands/help.ts)_
480
481
 
482
+ ## `jbrowse make-pif FILE`
483
+
484
+ creates pairwise indexed PAF (PIF), with bgzip and tabix
485
+
486
+ ```
487
+ USAGE
488
+ $ jbrowse make-pif FILE [--out <value>] [--csi] [-h]
489
+
490
+ ARGUMENTS
491
+ FILE PAF file as input
492
+
493
+ FLAGS
494
+ -h, --help Show CLI help.
495
+ --csi Create a CSI index for the PIF file instead of TBI
496
+ --out=<value> Where to write the output file. will write ${file}.pif.gz and ${file}.pif.gz.tbi
497
+
498
+ DESCRIPTION
499
+ creates pairwise indexed PAF (PIF), with bgzip and tabix
500
+
501
+ EXAMPLES
502
+ $ jbrowse pif input.paf # creates input.pif.gz in same directory
503
+
504
+
505
+
506
+ $ jbrowse pif input.paf --out output.pif.gz # specify output file, creates output.pif.gz.tbi also
507
+ ```
508
+
509
+ _See code:
510
+ [src/commands/make-pif.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/make-pif.ts)_
511
+
481
512
  ## `jbrowse remove-track TRACK`
482
513
 
483
514
  Remove a track configuration from a JBrowse 2 configuration. Be aware that this
@@ -504,7 +535,7 @@ EXAMPLES
504
535
  ```
505
536
 
506
537
  _See code:
507
- [src/commands/remove-track.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/remove-track.ts)_
538
+ [src/commands/remove-track.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/remove-track.ts)_
508
539
 
509
540
  ## `jbrowse set-default-session`
510
541
 
@@ -543,7 +574,7 @@ EXAMPLES
543
574
  ```
544
575
 
545
576
  _See code:
546
- [src/commands/set-default-session.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/set-default-session.ts)_
577
+ [src/commands/set-default-session.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/set-default-session.ts)_
547
578
 
548
579
  ## `jbrowse sort-gff FILE`
549
580
 
@@ -553,11 +584,14 @@ sort and grep
553
584
 
554
585
  ```
555
586
  USAGE
556
- $ jbrowse sort-gff FILE
587
+ $ jbrowse sort-gff FILE [-h]
557
588
 
558
589
  ARGUMENTS
559
590
  FILE GFF file
560
591
 
592
+ FLAGS
593
+ -h, --help Show CLI help.
594
+
561
595
  DESCRIPTION
562
596
  Helper utility to sort GFF files for tabix. Moves all lines starting with # to the top of the file, and sort by
563
597
  refname and start position using unix utilities sort and grep
@@ -571,7 +605,7 @@ EXAMPLES
571
605
  ```
572
606
 
573
607
  _See code:
574
- [src/commands/sort-gff.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/sort-gff.ts)_
608
+ [src/commands/sort-gff.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/sort-gff.ts)_
575
609
 
576
610
  ## `jbrowse text-index`
577
611
 
@@ -638,7 +672,7 @@ EXAMPLES
638
672
  ```
639
673
 
640
674
  _See code:
641
- [src/commands/text-index.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/text-index.ts)_
675
+ [src/commands/text-index.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/text-index.ts)_
642
676
 
643
677
  ## `jbrowse upgrade [LOCALPATH]`
644
678
 
@@ -701,7 +735,7 @@ EXAMPLES
701
735
  ```
702
736
 
703
737
  _See code:
704
- [src/commands/upgrade.ts](https://github.com/GMOD/jbrowse-components/blob/v2.9.0/products/jbrowse-cli/src/commands/upgrade.ts)_
738
+ [src/commands/upgrade.ts](https://github.com/GMOD/jbrowse-components/blob/v2.10.0/products/jbrowse-cli/src/commands/upgrade.ts)_
705
739
 
706
740
  <!-- commandsstop -->
707
741
 
@@ -90,6 +90,7 @@ class AddTrack extends base_1.default {
90
90
  });
91
91
  if ([
92
92
  'PAFAdapter',
93
+ 'PairwiseIndexedPAFAdapter',
93
94
  'DeltaAdapter',
94
95
  'ChainAdapter',
95
96
  'MashMapAdapter',
@@ -97,6 +98,7 @@ class AddTrack extends base_1.default {
97
98
  'MCScanSimpleAnchorsAdapter',
98
99
  ].includes(adapter.type)) {
99
100
  // @ts-expect-error
101
+ // this is for the adapter's assembly names
100
102
  adapter.assemblyNames = assemblyNames.split(',').map(a => a.trim());
101
103
  }
102
104
  if (isUrl(location) && load) {
@@ -206,7 +208,8 @@ class AddTrack extends base_1.default {
206
208
  }
207
209
  else if (/\.gff3?\.b?gz$/i.test(location) ||
208
210
  /\.vcf\.b?gz$/i.test(location) ||
209
- /\.bed\.b?gz$/i.test(location)) {
211
+ /\.bed\.b?gz$/i.test(location) ||
212
+ /\.pif\.b?gz$/i.test(location)) {
210
213
  return {
211
214
  file: location,
212
215
  index: index || `${location}.tbi`,
@@ -320,6 +323,16 @@ class AddTrack extends base_1.default {
320
323
  bedLocation: makeLocation(location),
321
324
  };
322
325
  }
326
+ else if (/\.pif\.b?gz$/i.test(location)) {
327
+ return {
328
+ type: 'PairwiseIndexedPAFAdapter',
329
+ pifGzLocation: makeLocation(location),
330
+ index: {
331
+ location: makeLocation(index || `${location}.tbi`),
332
+ indexType: index?.toUpperCase().endsWith('CSI') ? 'CSI' : 'TBI',
333
+ },
334
+ };
335
+ }
323
336
  else if (/\.bed\.b?gz$/i.test(location)) {
324
337
  return {
325
338
  type: 'BedTabixAdapter',
@@ -447,6 +460,7 @@ class AddTrack extends base_1.default {
447
460
  DeltaAdapter: 'SyntenyTrack',
448
461
  ChainAdapter: 'SyntenyTrack',
449
462
  MashMapAdapter: 'SyntenyTrack',
463
+ PairwiseIndexedPAFAdapter: 'SyntenyTrack',
450
464
  MCScanAnchorsAdapter: 'SyntenyTrack',
451
465
  MCScanSimpleAnchorsAdapter: 'SyntenyTrack',
452
466
  };
@@ -0,0 +1,117 @@
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.createPIF = exports.swapIndelCigar = exports.flipCigar = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const readline_1 = __importDefault(require("readline"));
9
+ const zlib_1 = require("zlib");
10
+ const core_1 = require("@oclif/core");
11
+ const command_exists_1 = require("command-exists");
12
+ const child_process_1 = require("child_process");
13
+ const path_1 = __importDefault(require("path"));
14
+ const base_1 = __importDefault(require("../base"));
15
+ const cigarRegex = new RegExp(/([MIDNSHPX=])/);
16
+ function getReadline(filename) {
17
+ const stream = fs_1.default.createReadStream(filename);
18
+ return readline_1.default.createInterface({
19
+ input: filename.match(/.b?gz$/) ? stream.pipe((0, zlib_1.createGunzip)()) : stream,
20
+ });
21
+ }
22
+ function getStdReadline() {
23
+ return readline_1.default.createInterface({
24
+ input: process.stdin,
25
+ });
26
+ }
27
+ function parseCigar(cigar = '') {
28
+ return cigar.split(cigarRegex).slice(0, -1);
29
+ }
30
+ function flipCigar(cigar) {
31
+ const arr = [];
32
+ for (let i = cigar.length - 2; i >= 0; i -= 2) {
33
+ arr.push(cigar[i]);
34
+ const op = cigar[i + 1];
35
+ if (op === 'D') {
36
+ arr.push('I');
37
+ }
38
+ else if (op === 'I') {
39
+ arr.push('D');
40
+ }
41
+ else {
42
+ arr.push(op);
43
+ }
44
+ }
45
+ return arr;
46
+ }
47
+ exports.flipCigar = flipCigar;
48
+ function swapIndelCigar(cigar) {
49
+ return cigar.replaceAll('D', 'K').replaceAll('I', 'D').replaceAll('K', 'I');
50
+ }
51
+ exports.swapIndelCigar = swapIndelCigar;
52
+ async function createPIF(filename, stream) {
53
+ const rl1 = filename ? getReadline(filename) : getStdReadline();
54
+ for await (const line of rl1) {
55
+ const [c1, l1, s1, e1, strand, c2, l2, s2, e2, ...rest] = line.split('\t');
56
+ stream.write([`t${c2}`, l2, s2, e2, strand, c1, l1, s1, e1, ...rest].join('\t') + '\n');
57
+ const cigarIdx = rest.findIndex(f => f.startsWith('cg:Z'));
58
+ const CIGAR = rest[cigarIdx];
59
+ if (CIGAR) {
60
+ rest[cigarIdx] = `cg:Z:${strand === '-'
61
+ ? flipCigar(parseCigar(CIGAR.slice(5))).join('')
62
+ : swapIndelCigar(CIGAR.slice(5))}`;
63
+ }
64
+ stream.write([`q${c1}`, l1, s1, e1, strand, c2, l2, s2, e2, ...rest].join('\t') + '\n');
65
+ }
66
+ rl1.close();
67
+ }
68
+ exports.createPIF = createPIF;
69
+ class MakePIF extends base_1.default {
70
+ async run() {
71
+ const { args: { file }, flags: { out, csi }, } = await this.parse(MakePIF);
72
+ if ((0, command_exists_1.sync)('sh') &&
73
+ (0, command_exists_1.sync)('sort') &&
74
+ (0, command_exists_1.sync)('grep') &&
75
+ (0, command_exists_1.sync)('tabix') &&
76
+ (0, command_exists_1.sync)('bgzip')) {
77
+ const fn = out || `${path_1.default.basename(file || 'output', '.paf')}.pif.gz`;
78
+ const child = (0, child_process_1.spawn)('sh', [
79
+ '-c',
80
+ `sort -t"\`printf '\t'\`" -k1,1 -k3,3n | bgzip > ${fn}; tabix ${csi ? '-C ' : ''}-s1 -b3 -e4 -0 ${fn}`,
81
+ ], {
82
+ env: { ...process.env, LC_ALL: 'C' },
83
+ stdio: ['pipe', process.stdout, process.stderr],
84
+ });
85
+ await createPIF(file, child.stdin);
86
+ child.stdin.end();
87
+ await new Promise(resolve => {
88
+ child.on('close', resolve);
89
+ });
90
+ }
91
+ else {
92
+ throw new Error('Unable to sort, requires unix type environment with sort, grep, bgzip, tabix');
93
+ }
94
+ }
95
+ }
96
+ MakePIF.description = 'creates pairwise indexed PAF (PIF), with bgzip and tabix';
97
+ MakePIF.examples = [
98
+ '$ jbrowse pif input.paf # creates input.pif.gz in same directory',
99
+ '',
100
+ '$ jbrowse pif input.paf --out output.pif.gz # specify output file, creates output.pif.gz.tbi also',
101
+ ];
102
+ MakePIF.flags = {
103
+ out: core_1.Flags.string({
104
+ description: 'Where to write the output file. will write ${file}.pif.gz and ${file}.pif.gz.tbi',
105
+ }),
106
+ csi: core_1.Flags.boolean({
107
+ description: 'Create a CSI index for the PIF file instead of TBI',
108
+ }),
109
+ help: core_1.Flags.help({ char: 'h' }),
110
+ };
111
+ MakePIF.args = {
112
+ file: core_1.Args.string({
113
+ required: true,
114
+ description: `PAF file as input`,
115
+ }),
116
+ };
117
+ exports.default = MakePIF;
@@ -39,4 +39,7 @@ SortGff.args = {
39
39
  description: `GFF file`,
40
40
  }),
41
41
  };
42
+ SortGff.flags = {
43
+ help: core_1.Flags.help({ char: 'h' }),
44
+ };
42
45
  exports.default = SortGff;
@@ -684,6 +684,57 @@
684
684
  "create.js"
685
685
  ]
686
686
  },
687
+ "make-pif": {
688
+ "aliases": [],
689
+ "args": {
690
+ "file": {
691
+ "description": "PAF file as input",
692
+ "name": "file",
693
+ "required": true
694
+ }
695
+ },
696
+ "description": "creates pairwise indexed PAF (PIF), with bgzip and tabix",
697
+ "examples": [
698
+ "$ jbrowse pif input.paf # creates input.pif.gz in same directory",
699
+ "",
700
+ "$ jbrowse pif input.paf --out output.pif.gz # specify output file, creates output.pif.gz.tbi also"
701
+ ],
702
+ "flags": {
703
+ "out": {
704
+ "description": "Where to write the output file. will write ${file}.pif.gz and ${file}.pif.gz.tbi",
705
+ "name": "out",
706
+ "hasDynamicHelp": false,
707
+ "multiple": false,
708
+ "type": "option"
709
+ },
710
+ "csi": {
711
+ "description": "Create a CSI index for the PIF file instead of TBI",
712
+ "name": "csi",
713
+ "allowNo": false,
714
+ "type": "boolean"
715
+ },
716
+ "help": {
717
+ "char": "h",
718
+ "description": "Show CLI help.",
719
+ "name": "help",
720
+ "allowNo": false,
721
+ "type": "boolean"
722
+ }
723
+ },
724
+ "hasDynamicHelp": false,
725
+ "hiddenAliases": [],
726
+ "id": "make-pif",
727
+ "pluginAlias": "@jbrowse/cli",
728
+ "pluginName": "@jbrowse/cli",
729
+ "pluginType": "core",
730
+ "strict": true,
731
+ "isESM": false,
732
+ "relativePath": [
733
+ "lib",
734
+ "commands",
735
+ "make-pif.js"
736
+ ]
737
+ },
687
738
  "remove-track": {
688
739
  "aliases": [],
689
740
  "args": {
@@ -842,7 +893,15 @@
842
893
  "$ jbrowse sort-gff input.gff | bgzip > sorted.gff.gz",
843
894
  "$ tabix sorted.gff.gz"
844
895
  ],
845
- "flags": {},
896
+ "flags": {
897
+ "help": {
898
+ "char": "h",
899
+ "description": "Show CLI help.",
900
+ "name": "help",
901
+ "allowNo": false,
902
+ "type": "boolean"
903
+ }
904
+ },
846
905
  "hasDynamicHelp": false,
847
906
  "hiddenAliases": [],
848
907
  "id": "sort-gff",
@@ -1087,5 +1146,5 @@
1087
1146
  ]
1088
1147
  }
1089
1148
  },
1090
- "version": "2.9.0"
1149
+ "version": "2.10.0"
1091
1150
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jbrowse/cli",
3
- "version": "2.9.0",
3
+ "version": "2.10.0",
4
4
  "description": "A command line tool for working with JBrowse 2",
5
5
  "keywords": [
6
6
  "jbrowse",
@@ -75,5 +75,5 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "a50b6f67cf8c8f3c65a7b8cd858de2fcca1f2909"
78
+ "gitHead": "223d8bfb68fd1bacaf22852639ad5920f1b7f43b"
79
79
  }