@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.
Files changed (57) hide show
  1. package/README.md +413 -57
  2. package/bin/run +1 -1
  3. package/bundle/index.js +550 -2659
  4. package/dist/base.js +0 -3
  5. package/dist/bin.js +2 -1
  6. package/dist/cliFetch.js +3 -0
  7. package/dist/commands/add-assembly/index.js +46 -19
  8. package/dist/commands/add-assembly/utils.js +204 -290
  9. package/dist/commands/add-connection.js +73 -79
  10. package/dist/commands/add-track-json.js +24 -12
  11. package/dist/commands/add-track-utils/adapter-utils.js +222 -288
  12. package/dist/commands/add-track-utils/file-operations.js +27 -11
  13. package/dist/commands/add-track-utils/multiwig.js +47 -0
  14. package/dist/commands/add-track-utils/track-config.js +68 -25
  15. package/dist/commands/add-track-utils/validators.js +36 -20
  16. package/dist/commands/add-track.js +201 -62
  17. package/dist/commands/admin-server/index.js +30 -49
  18. package/dist/commands/admin-server/utils.js +235 -125
  19. package/dist/commands/create.js +18 -34
  20. package/dist/commands/make-density/density-generator.js +180 -0
  21. package/dist/commands/make-density/index.js +139 -0
  22. package/dist/commands/make-pif/index.js +128 -11
  23. package/dist/commands/make-pif/pif-generator.js +249 -43
  24. package/dist/commands/process-utils.js +13 -2
  25. package/dist/commands/remove-track.js +20 -13
  26. package/dist/commands/set-default-session.js +35 -31
  27. package/dist/commands/shared/config-operations.js +3 -10
  28. package/dist/commands/shared/density.js +12 -0
  29. package/dist/commands/shared/sort-utils.js +67 -10
  30. package/dist/commands/shared/validators.js +38 -3
  31. package/dist/commands/sort-bed.js +2 -33
  32. package/dist/commands/sort-gff.js +2 -33
  33. package/dist/commands/text-index/adapter-utils.js +6 -23
  34. package/dist/commands/text-index/aggregate.js +40 -34
  35. package/dist/commands/text-index/command.js +35 -7
  36. package/dist/commands/text-index/config-utils.js +60 -83
  37. package/dist/commands/text-index/file-list.js +32 -18
  38. package/dist/commands/text-index/index.js +4 -4
  39. package/dist/commands/text-index/indexing-utils.js +49 -73
  40. package/dist/commands/text-index/per-track.js +44 -31
  41. package/dist/commands/text-index/validators.js +1 -1
  42. package/dist/commands/upgrade.js +20 -32
  43. package/dist/commands/validate/configManifest.generated.js +5765 -0
  44. package/dist/commands/validate/displayDefaultKeys.js +28 -0
  45. package/dist/commands/validate/index.js +97 -0
  46. package/dist/commands/validate/suggest.js +35 -0
  47. package/dist/commands/validate/types.js +6 -0
  48. package/dist/commands/validate/validateConfig.js +522 -0
  49. package/dist/index.js +104 -50
  50. package/dist/types/common.js +3 -27
  51. package/dist/utils.js +309 -128
  52. package/dist/version.js +1 -1
  53. package/package.json +8 -10
  54. package/dist/commands/make-pif/cigar-utils.js +0 -24
  55. package/dist/commands/make-pif/file-utils.js +0 -30
  56. package/dist/commands/track-utils.js +0 -74
  57. package/dist/util.js +0 -35
package/dist/base.js CHANGED
@@ -1,4 +1 @@
1
- /**
2
- * By convention, exit codes in this base class are below 100
3
- */
4
1
  export {};
package/dist/bin.js CHANGED
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env node
2
- import { main } from "./index.js";
2
+ import { main } from './index.js';
3
3
  main(process.argv.slice(2)).catch((e) => {
4
4
  console.error(e);
5
+ process.exitCode = 1;
5
6
  });
package/dist/cliFetch.js CHANGED
@@ -1,3 +1,6 @@
1
+ // Wrapper around fetch that allows tests to mock API calls. All modules in
2
+ // jbrowse-cli must use this instead of the global fetch function. See
3
+ // CLAUDE.md for details.
1
4
  export default function cliFetch(url, options = {}) {
2
5
  return fetch(url, options);
3
6
  }
@@ -1,6 +1,10 @@
1
- import { parseArgs } from 'util';
2
- import { addAssemblyToConfig, enhanceAssembly, getAssembly, loadOrCreateConfig, resolveTargetPath, saveConfigAndReport, } from "./utils.js";
3
- import { debug, printHelp } from "../../utils.js";
1
+ import path from 'node:path';
2
+ import { parseArgs } from 'node:util';
3
+ import { debug, printHelp, requirePositional } from '../../utils.js';
4
+ import { loadFiles } from '../add-track-utils/file-operations.js';
5
+ import { validateLoadOption } from '../add-track-utils/validators.js';
6
+ import { saveConfigAndReport } from '../shared/config-operations.js';
7
+ import { addAssemblyToConfig, enhanceAssembly, getAssembly, loadOrCreateConfig, parseSequenceType, resolveTargetPath, } from './utils.js';
4
8
  export async function run(args) {
5
9
  const options = {
6
10
  type: {
@@ -40,7 +44,6 @@ export async function run(args) {
40
44
  type: 'string',
41
45
  description: 'Type of aliases defined by --refNameAliases; if "custom", --refNameAliases is either a JSON file location or inline JSON that defines a custom sequence adapter',
42
46
  choices: ['aliases', 'custom'],
43
- dependsOn: ['refNameAliases'],
44
47
  },
45
48
  refNameColors: {
46
49
  type: 'string',
@@ -65,18 +68,14 @@ export async function run(args) {
65
68
  description: 'Required flag when using a local file. Choose how to manage the data directory. Copy, symlink, or move the data directory to the JBrowse directory. Or use inPlace to modify the config without doing any file operations',
66
69
  choices: ['copy', 'symlink', 'move', 'inPlace'],
67
70
  },
68
- skipCheck: {
69
- type: 'boolean',
70
- description: "Don't check whether or not the sequence file or URL exists or if you are in a JBrowse directory",
71
- },
72
- overwrite: {
73
- type: 'boolean',
74
- description: 'Overwrite existing assembly if one with the same name exists',
75
- },
76
71
  force: {
77
72
  type: 'boolean',
78
73
  short: 'f',
79
- description: 'Equivalent to `--skipCheck --overwrite`',
74
+ description: 'Overwrite existing assembly and skip file existence checks',
75
+ },
76
+ config: {
77
+ type: 'string',
78
+ description: 'Any extra config settings to add to the assembly',
80
79
  },
81
80
  };
82
81
  const { positionals, values: runFlags } = parseArgs({
@@ -85,6 +84,13 @@ export async function run(args) {
85
84
  allowPositionals: true,
86
85
  });
87
86
  const description = 'Add an assembly to a JBrowse 2 configuration';
87
+ const usage = 'jbrowse add-assembly <sequence> [options]';
88
+ const notes = '--config takes inline JSON (not a file path) that is merged into the ' +
89
+ 'generated assembly config, so you can set fields the dedicated flags do ' +
90
+ 'not cover. A "sequence" object in it is merged into the generated ' +
91
+ 'ReferenceSequenceTrack rather than replacing it, e.g. --config ' +
92
+ '\'{"sequence":{"formatAbout":{"hideUris":true}}}\' hides file URIs in the ' +
93
+ "assembly's About dialog.";
88
94
  const examples = [
89
95
  '# add assembly to installation in current directory. assumes .fai file also exists, and copies GRCh38.fa and GRCh38.fa.fai to current directory',
90
96
  '$ jbrowse add-assembly GRCh38.fa --load copy',
@@ -109,32 +115,53 @@ export async function run(args) {
109
115
  '',
110
116
  '# add a bgzip indexed fasta inferred by fa.gz extension. assumes .fa.gz.gzi and .fa.gz.fai files also exists',
111
117
  '$ jbrowse add-assembly myfile.fa.gz --load copy',
118
+ '',
119
+ '# hide file URIs in the assembly About dialog',
120
+ '$ jbrowse add-assembly GRCh38.fa --load copy --config \'{"sequence":{"formatAbout":{"hideUris":true}}}\'',
112
121
  ];
113
122
  if (runFlags.help) {
114
123
  printHelp({
115
124
  description,
116
125
  examples,
117
- usage: 'jbrowse add-assembly <sequence> [options]',
126
+ notes,
127
+ usage,
118
128
  options,
119
129
  });
120
130
  return;
121
131
  }
122
- const argsSequence = positionals[0] || '';
132
+ validateLoadOption(runFlags.load);
133
+ const type = parseSequenceType(runFlags.type);
134
+ const argsSequence = positionals[0];
135
+ requirePositional(argsSequence, 'sequence', usage);
123
136
  const output = runFlags.target || runFlags.out || '.';
137
+ const flags = { ...runFlags, type };
124
138
  debug(`Sequence location is: ${argsSequence}`);
125
139
  const target = await resolveTargetPath(output);
126
- const baseAssembly = await getAssembly({ runFlags, argsSequence, target });
127
- const assembly = await enhanceAssembly(baseAssembly, runFlags);
140
+ const { assembly: baseAssembly, filesToLoad: sequenceFiles } = await getAssembly({
141
+ runFlags: flags,
142
+ argsSequence,
143
+ });
144
+ const { assembly, filesToLoad: aliasFiles } = await enhanceAssembly(baseAssembly, flags);
128
145
  const configContents = await loadOrCreateConfig(target);
129
146
  const { config: updatedConfig, wasOverwritten } = await addAssemblyToConfig({
130
147
  config: configContents,
131
148
  assembly,
132
- runFlags,
149
+ runFlags: flags,
150
+ });
151
+ await loadFiles({
152
+ files: [...sequenceFiles, ...aliasFiles],
153
+ destDir: path.dirname(target),
154
+ mode: flags.load,
155
+ force: flags.force,
133
156
  });
134
157
  await saveConfigAndReport({
135
158
  config: updatedConfig,
136
159
  target,
137
- assembly,
160
+ itemType: 'assembly',
161
+ itemName: assembly.name,
162
+ itemId: assembly.name,
138
163
  wasOverwritten,
139
164
  });
165
+ console.log(`\nNext, add tracks to this assembly (replace with your data file):\n` +
166
+ ` jbrowse add-track myfile.bam -a ${assembly.name} --load copy`);
140
167
  }