@jbrowse/cli 3.5.1 → 3.6.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.
@@ -1,380 +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 stream_1 = require("stream");
9
- const core_1 = require("@oclif/core");
10
- const ixixx_1 = require("ixixx");
11
- const base_1 = __importDefault(require("../base"));
12
- const common_1 = require("../types/common");
13
- const gff3Adapter_1 = require("../types/gff3Adapter");
14
- const vcfAdapter_1 = require("../types/vcfAdapter");
15
- function readConf(path) {
16
- return JSON.parse(fs_1.default.readFileSync(path, 'utf8'));
17
- }
18
- function writeConf(obj, path) {
19
- fs_1.default.writeFileSync(path, JSON.stringify(obj, null, 2));
20
- }
21
- function getLoc(elt) {
22
- return elt.locationType === 'LocalPathLocation' ? elt.localPath : elt.uri;
23
- }
24
- class TextIndex extends base_1.default {
25
- async run() {
26
- const { flags } = await this.parse(TextIndex);
27
- const { perTrack, file } = flags;
28
- if (file) {
29
- await this.indexFileList();
30
- }
31
- else if (perTrack) {
32
- await this.perTrackIndex();
33
- }
34
- else {
35
- await this.aggregateIndex();
36
- }
37
- this.log('Finished!');
38
- }
39
- async aggregateIndex() {
40
- const { flags } = await this.parse(TextIndex);
41
- const { out, target, tracks, assemblies, attributes, quiet, force, exclude, dryrun, prefixSize, } = flags;
42
- const outFlag = target || out || '.';
43
- const isDir = fs_1.default.lstatSync(outFlag).isDirectory();
44
- const confPath = isDir ? path_1.default.join(outFlag, 'config.json') : outFlag;
45
- const outLocation = path_1.default.dirname(confPath);
46
- const config = readConf(confPath);
47
- const trixDir = path_1.default.join(outLocation, 'trix');
48
- if (!fs_1.default.existsSync(trixDir)) {
49
- fs_1.default.mkdirSync(trixDir);
50
- }
51
- const aggregateTextSearchAdapters = config.aggregateTextSearchAdapters || [];
52
- const asms = assemblies?.split(',') ||
53
- config.assemblies?.map(a => a.name) ||
54
- (config.assembly ? [config.assembly.name] : []);
55
- if (!asms.length) {
56
- throw new Error('No assemblies found');
57
- }
58
- for (const asm of asms) {
59
- const trackConfigs = await this.getTrackConfigs(confPath, tracks?.split(','), asm);
60
- if (!trackConfigs.length) {
61
- this.log(`Indexing assembly ${asm}...(no tracks found)...`);
62
- continue;
63
- }
64
- this.log(`Indexing assembly ${asm}...`);
65
- if (dryrun) {
66
- this.log(trackConfigs.map(e => `${e.trackId}\t${e.adapter?.type}`).join('\n'));
67
- }
68
- else {
69
- const id = `${asm}-index`;
70
- const idx = aggregateTextSearchAdapters.findIndex(x => x.textSearchAdapterId === id);
71
- if (idx !== -1 && !force) {
72
- this.log(`Note: ${asm} has already been indexed with this configuration, use --force to overwrite this assembly. Skipping for now`);
73
- continue;
74
- }
75
- await this.indexDriver({
76
- trackConfigs,
77
- outLocation,
78
- quiet,
79
- name: asm,
80
- attributes: attributes.split(','),
81
- typesToExclude: exclude.split(','),
82
- assemblyNames: [asm],
83
- prefixSize,
84
- });
85
- const trixConf = {
86
- type: 'TrixTextSearchAdapter',
87
- textSearchAdapterId: id,
88
- ixFilePath: {
89
- uri: `trix/${asm}.ix`,
90
- locationType: 'UriLocation',
91
- },
92
- ixxFilePath: {
93
- uri: `trix/${asm}.ixx`,
94
- locationType: 'UriLocation',
95
- },
96
- metaFilePath: {
97
- uri: `trix/${asm}_meta.json`,
98
- locationType: 'UriLocation',
99
- },
100
- assemblyNames: [asm],
101
- };
102
- if (idx === -1) {
103
- aggregateTextSearchAdapters.push(trixConf);
104
- }
105
- else {
106
- aggregateTextSearchAdapters[idx] = trixConf;
107
- }
108
- }
109
- }
110
- if (!dryrun) {
111
- writeConf({
112
- ...config,
113
- aggregateTextSearchAdapters,
114
- }, confPath);
115
- }
116
- }
117
- async perTrackIndex() {
118
- const { flags } = await this.parse(TextIndex);
119
- const { out, target, tracks, assemblies, attributes, quiet, force, exclude, prefixSize, } = flags;
120
- const outFlag = target || out || '.';
121
- const isDir = fs_1.default.lstatSync(outFlag).isDirectory();
122
- const confFilePath = isDir ? path_1.default.join(outFlag, 'config.json') : outFlag;
123
- const outLocation = path_1.default.dirname(confFilePath);
124
- const config = readConf(confFilePath);
125
- const configTracks = config.tracks || [];
126
- const trixDir = path_1.default.join(outLocation, 'trix');
127
- if (!fs_1.default.existsSync(trixDir)) {
128
- fs_1.default.mkdirSync(trixDir);
129
- }
130
- if (assemblies) {
131
- throw new Error(`Can't specify assemblies when indexing per track, remove assemblies flag to continue.`);
132
- }
133
- const confs = await this.getTrackConfigs(confFilePath, tracks?.split(','));
134
- if (!confs.length) {
135
- throw new Error('Tracks not found in config.json, please add track configurations before indexing.');
136
- }
137
- for (const trackConfig of confs) {
138
- const { textSearching, trackId, assemblyNames } = trackConfig;
139
- if (textSearching?.textSearchAdapter && !force) {
140
- this.log(`Note: ${trackId} has already been indexed with this configuration, use --force to overwrite this track. Skipping for now`);
141
- continue;
142
- }
143
- this.log(`Indexing track ${trackId}...`);
144
- await this.indexDriver({
145
- trackConfigs: [trackConfig],
146
- attributes: attributes.split(','),
147
- outLocation,
148
- quiet,
149
- name: trackId,
150
- typesToExclude: exclude.split(','),
151
- assemblyNames,
152
- prefixSize,
153
- });
154
- if (!textSearching?.textSearchAdapter) {
155
- // modifies track with new text search adapter
156
- const index = configTracks.findIndex(track => trackId === track.trackId);
157
- if (index !== -1) {
158
- configTracks[index] = {
159
- ...trackConfig,
160
- textSearching: {
161
- ...textSearching,
162
- textSearchAdapter: {
163
- type: 'TrixTextSearchAdapter',
164
- textSearchAdapterId: `${trackId}-index`,
165
- ixFilePath: {
166
- uri: `trix/${trackId}.ix`,
167
- locationType: 'UriLocation',
168
- },
169
- ixxFilePath: {
170
- uri: `trix/${trackId}.ixx`,
171
- locationType: 'UriLocation',
172
- },
173
- metaFilePath: {
174
- uri: `trix/${trackId}_meta.json`,
175
- locationType: 'UriLocation',
176
- },
177
- assemblyNames: assemblyNames,
178
- },
179
- },
180
- };
181
- }
182
- else {
183
- this.log("Error: can't find trackId");
184
- }
185
- }
186
- writeConf({ ...config, tracks: configTracks }, confFilePath);
187
- }
188
- }
189
- async indexFileList() {
190
- const { flags } = await this.parse(TextIndex);
191
- const { out, target, fileId, file, attributes, quiet, exclude, prefixSize, } = flags;
192
- if (!file) {
193
- throw new Error('Cannot index file list without files');
194
- }
195
- const outFlag = target || out || '.';
196
- const trixDir = path_1.default.join(outFlag, 'trix');
197
- if (!fs_1.default.existsSync(trixDir)) {
198
- fs_1.default.mkdirSync(trixDir);
199
- }
200
- const trackConfigs = file
201
- .map(file => (0, common_1.guessAdapterFromFileName)(file))
202
- .filter(fileConfig => (0, common_1.supported)(fileConfig.adapter?.type));
203
- if (fileId?.length) {
204
- for (const [i, element] of fileId.entries()) {
205
- trackConfigs[i].trackId = element;
206
- }
207
- }
208
- await this.indexDriver({
209
- trackConfigs,
210
- outLocation: outFlag,
211
- name: trackConfigs.length > 1 ? 'aggregate' : path_1.default.basename(file[0]),
212
- quiet,
213
- attributes: attributes.split(','),
214
- typesToExclude: exclude.split(','),
215
- assemblyNames: [],
216
- prefixSize,
217
- });
218
- this.log('Successfully created index for these files. See https://jbrowse.org/storybook/lgv/main/?path=/story/text-searching--page for info about usage');
219
- }
220
- async indexDriver({ trackConfigs, attributes, outLocation, name, quiet, typesToExclude, assemblyNames, prefixSize, }) {
221
- const readStream = stream_1.Readable.from(this.indexFiles({
222
- trackConfigs,
223
- attributes,
224
- outLocation,
225
- quiet,
226
- typesToExclude,
227
- }));
228
- await this.runIxIxx({
229
- readStream,
230
- outLocation,
231
- name,
232
- prefixSize,
233
- });
234
- await (0, common_1.generateMeta)({
235
- trackConfigs,
236
- attributes,
237
- outLocation,
238
- name,
239
- typesToExclude,
240
- assemblyNames,
241
- });
242
- }
243
- async *indexFiles({ trackConfigs, attributes, outLocation, quiet, typesToExclude, }) {
244
- for (const config of trackConfigs) {
245
- const { adapter, textSearching } = config;
246
- const { type } = adapter || {};
247
- const { indexingFeatureTypesToExclude = typesToExclude, indexingAttributes = attributes, } = textSearching || {};
248
- let loc;
249
- if (type === 'Gff3TabixAdapter') {
250
- // @ts-expect-error
251
- loc = adapter.gffGzLocation || adapter;
252
- }
253
- else if (type === 'Gff3Adapter') {
254
- // @ts-expect-error
255
- loc = adapter.gffLocation || adapter;
256
- }
257
- else if (type === 'VcfAdapter') {
258
- // @ts-expect-error
259
- loc = adapter.vcfLocation || adapter;
260
- }
261
- else if (type === 'VcfTabixAdapter') {
262
- // @ts-expect-error
263
- loc = adapter.vcfGzLocation || adapter;
264
- }
265
- else {
266
- return;
267
- }
268
- if (type === 'Gff3TabixAdapter' || type === 'Gff3Adapter') {
269
- yield* (0, gff3Adapter_1.indexGff3)({
270
- config,
271
- attributesToIndex: indexingAttributes,
272
- inLocation: getLoc(loc),
273
- outLocation,
274
- typesToExclude: indexingFeatureTypesToExclude,
275
- quiet,
276
- });
277
- }
278
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
279
- else if (type === 'VcfTabixAdapter' || type === 'VcfAdapter') {
280
- yield* (0, vcfAdapter_1.indexVcf)({
281
- config,
282
- attributesToIndex: indexingAttributes,
283
- inLocation: getLoc(loc),
284
- outLocation,
285
- typesToExclude: indexingFeatureTypesToExclude,
286
- quiet,
287
- });
288
- }
289
- }
290
- }
291
- async runIxIxx({ readStream, outLocation, name, prefixSize, }) {
292
- await (0, ixixx_1.ixIxxStream)(readStream, path_1.default.join(outLocation, 'trix', `${name}.ix`), path_1.default.join(outLocation, 'trix', `${name}.ixx`), prefixSize);
293
- }
294
- async getTrackConfigs(configPath, trackIds, assemblyName) {
295
- const { tracks } = readConf(configPath);
296
- if (!tracks) {
297
- return [];
298
- }
299
- const trackIdsToIndex = trackIds || tracks.map(track => track.trackId);
300
- return trackIdsToIndex
301
- .map(trackId => {
302
- const currentTrack = tracks.find(t => trackId === t.trackId);
303
- if (!currentTrack) {
304
- throw new Error(`Track not found in config.json for trackId ${trackId}, please add track configuration before indexing.`);
305
- }
306
- return currentTrack;
307
- })
308
- .filter(track => (0, common_1.supported)(track.adapter?.type))
309
- .filter(track => assemblyName ? track.assemblyNames.includes(assemblyName) : true);
310
- }
311
- }
312
- TextIndex.description = 'Make a text-indexing file for any given track(s).';
313
- TextIndex.examples = [
314
- "# indexes all tracks that it can find in the current directory's config.json",
315
- '$ jbrowse text-index',
316
- '',
317
- "# indexes specific trackIds that it can find in the current directory's config.json",
318
- '$ jbrowse text-index --tracks=track1,track2,track3',
319
- '',
320
- "# indexes all tracks in a directory's config.json or in a specific config file",
321
- '$ jbrowse text-index --out /path/to/jb2/',
322
- '',
323
- '# indexes only a specific assembly, and overwrite what was previously there using force (which is needed if a previous index already existed)',
324
- '$ jbrowse text-index -a hg19 --force',
325
- '',
326
- '# create index for some files for use in @jbrowse/react-linear-genome-view2 or similar',
327
- '$ jbrowse text-index --file myfile.gff3.gz --file myfile.vcfgz --out indexes',
328
- ];
329
- TextIndex.flags = {
330
- help: core_1.Flags.help({ char: 'h' }),
331
- tracks: core_1.Flags.string({
332
- description: 'Specific tracks to index, formatted as comma separated trackIds. If unspecified, indexes all available tracks',
333
- }),
334
- target: core_1.Flags.string({
335
- description: 'Path to config file in JB2 installation directory to read from.',
336
- }),
337
- out: core_1.Flags.string({
338
- description: 'Synonym for target',
339
- }),
340
- attributes: core_1.Flags.string({
341
- description: 'Comma separated list of attributes to index',
342
- default: 'Name,ID',
343
- }),
344
- assemblies: core_1.Flags.string({
345
- char: 'a',
346
- description: 'Specify the assembl(ies) to create an index for. If unspecified, creates an index for each assembly in the config',
347
- }),
348
- force: core_1.Flags.boolean({
349
- default: false,
350
- description: 'Overwrite previously existing indexes',
351
- }),
352
- quiet: core_1.Flags.boolean({
353
- char: 'q',
354
- default: false,
355
- description: 'Hide the progress bars',
356
- }),
357
- perTrack: core_1.Flags.boolean({
358
- default: false,
359
- description: 'If set, creates an index per track',
360
- }),
361
- exclude: core_1.Flags.string({
362
- description: 'Adds gene type to list of excluded types',
363
- default: 'CDS,exon',
364
- }),
365
- prefixSize: core_1.Flags.integer({
366
- description: 'Specify the prefix size for the ixx index. We attempt to automatically calculate this, but you can manually specify this too. If many genes have similar gene IDs e.g. Z000000001, Z000000002 the prefix size should be larger so that they get split into different bins',
367
- }),
368
- file: core_1.Flags.string({
369
- description: 'File or files to index (can be used to create trix indexes for embedded component use cases not using a config.json for example)',
370
- multiple: true,
371
- }),
372
- fileId: core_1.Flags.string({
373
- description: 'Set the trackId used for the indexes generated with the --file argument',
374
- multiple: true,
375
- }),
376
- dryrun: core_1.Flags.boolean({
377
- description: 'Just print out tracks that will be indexed by the process, without doing any indexing',
378
- }),
379
- };
380
- exports.default = TextIndex;
@@ -1,109 +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 decompress_1 = __importDefault(require("decompress"));
10
- const base_1 = __importDefault(require("../base"));
11
- const fetchWithProxy_1 = __importDefault(require("../fetchWithProxy"));
12
- class Upgrade extends base_1.default {
13
- async run() {
14
- const { args: runArgs, flags: runFlags } = await this.parse(Upgrade);
15
- const { localPath: argsPath } = runArgs;
16
- const { clean, listVersions, tag, url, branch, nightly } = runFlags;
17
- if (listVersions) {
18
- const versions = (await this.fetchGithubVersions()).map(v => v.tag_name);
19
- this.log(`All JBrowse versions:\n${versions.join('\n')}`);
20
- this.exit();
21
- }
22
- this.debug(`Want to upgrade at: ${argsPath}`);
23
- if (!argsPath) {
24
- this.error('No directory supplied', { exit: 100 });
25
- }
26
- if (!fs_1.default.existsSync(path_1.default.join(argsPath, 'manifest.json'))) {
27
- this.error(`No manifest.json found in this directory, are you sure it is an
28
- existing jbrowse 2 installation?`, { exit: 10 });
29
- }
30
- const locationUrl = url ||
31
- (nightly ? await this.getBranch('main') : '') ||
32
- (branch ? await this.getBranch(branch) : '') ||
33
- (tag ? await this.getTag(tag) : await this.getLatest());
34
- this.log(`Fetching ${locationUrl}...`);
35
- const response = await (0, fetchWithProxy_1.default)(locationUrl);
36
- if (!response.ok) {
37
- this.error(`Failed to fetch: ${response.statusText}`, { exit: 100 });
38
- }
39
- const type = response.headers.get('content-type');
40
- if (url &&
41
- type !== 'application/zip' &&
42
- type !== 'application/octet-stream') {
43
- this.error('The URL provided does not seem to be a JBrowse installation URL');
44
- }
45
- if (clean) {
46
- fs_1.default.rmSync(path_1.default.join(argsPath, 'static'), { recursive: true, force: true });
47
- for (const f of fs_1.default
48
- .readdirSync(argsPath)
49
- .filter(f => f.includes('worker.js'))) {
50
- fs_1.default.unlinkSync(path_1.default.join(argsPath, f));
51
- }
52
- }
53
- await (0, decompress_1.default)(Buffer.from(await response.arrayBuffer()), argsPath);
54
- this.log(`Unpacked ${locationUrl} at ${argsPath}`);
55
- }
56
- }
57
- Upgrade.description = 'Upgrades JBrowse 2 to latest version';
58
- Upgrade.examples = [
59
- '# Upgrades current directory to latest jbrowse release',
60
- '$ jbrowse upgrade',
61
- '',
62
- '# Upgrade jbrowse instance at a specific filesystem path',
63
- '$ jbrowse upgrade /path/to/jbrowse2/installation',
64
- '',
65
- '# Upgrade to a specific tag',
66
- '$ jbrowse upgrade /path/to/jbrowse2/installation --tag v1.0.0',
67
- '',
68
- '# List versions available on github',
69
- '$ jbrowse upgrade --listVersions',
70
- '',
71
- '# Upgrade from a specific URL',
72
- '$ jbrowse upgrade --url https://sample.com/jbrowse2.zip',
73
- '',
74
- '# Get nightly release from main branch',
75
- '$ jbrowse upgrade --nightly',
76
- ];
77
- Upgrade.args = {
78
- localPath: core_1.Args.string({
79
- required: false,
80
- description: 'Location where JBrowse 2 is installed',
81
- default: '.',
82
- }),
83
- };
84
- Upgrade.flags = {
85
- help: core_1.Flags.help({ char: 'h' }),
86
- // will need to account for pagination once there is a lot of releases
87
- listVersions: core_1.Flags.boolean({
88
- char: 'l',
89
- description: 'Lists out all versions of JBrowse 2',
90
- }),
91
- tag: core_1.Flags.string({
92
- char: 't',
93
- description: 'Version of JBrowse 2 to install. Format is v1.0.0.\nDefaults to latest',
94
- }),
95
- branch: core_1.Flags.string({
96
- description: 'Download a development build from a named git branch',
97
- }),
98
- nightly: core_1.Flags.boolean({
99
- description: 'Download the latest development build from the main branch',
100
- }),
101
- clean: core_1.Flags.boolean({
102
- description: 'Removes old js,map,and LICENSE files in the installation',
103
- }),
104
- url: core_1.Flags.string({
105
- char: 'u',
106
- description: 'A direct URL to a JBrowse 2 release',
107
- }),
108
- };
109
- exports.default = Upgrade;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = fetchWithProxy;
4
- const node_1 = require("node-fetch-native/node");
5
- const proxy_1 = require("node-fetch-native/proxy");
6
- const proxy = (0, proxy_1.createProxy)();
7
- // The correct proxy `Agent` implementation to use will be determined
8
- // via the `http_proxy` / `https_proxy` / `no_proxy` / etc. env vars
9
- // https://github.com/unjs/node-fetch-native?tab=readme-ov-file#proxy-support
10
- function fetchWithProxy(url, options = {}) {
11
- return (0, node_1.fetch)(url, { ...options, ...proxy });
12
- }
package/lib/index.js DELETED
@@ -1,6 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.run = void 0;
4
- var core_1 = require("@oclif/core");
5
- Object.defineProperty(exports, "run", { enumerable: true, get: function () { return core_1.run; } });
6
- // trigger build
@@ -1,128 +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
- exports.createRemoteStream = createRemoteStream;
7
- exports.isURL = isURL;
8
- exports.guessAdapterFromFileName = guessAdapterFromFileName;
9
- exports.supported = supported;
10
- exports.generateMeta = generateMeta;
11
- const fs_1 = __importDefault(require("fs"));
12
- const path_1 = __importDefault(require("path"));
13
- const fetchWithProxy_1 = __importDefault(require("../fetchWithProxy"));
14
- async function createRemoteStream(urlIn) {
15
- const res = await (0, fetchWithProxy_1.default)(urlIn);
16
- if (!res.ok) {
17
- throw new Error(`Failed to fetch ${urlIn} status ${res.status} ${await res.text()}`);
18
- }
19
- return res;
20
- }
21
- function isURL(FileName) {
22
- let url;
23
- try {
24
- url = new URL(FileName);
25
- }
26
- catch (_) {
27
- return false;
28
- }
29
- return url.protocol === 'http:' || url.protocol === 'https:';
30
- }
31
- function makeLocation(location, protocol) {
32
- if (protocol === 'uri') {
33
- return {
34
- uri: location,
35
- locationType: 'UriLocation',
36
- };
37
- }
38
- if (protocol === 'localPath') {
39
- return {
40
- localPath: path_1.default.resolve(location),
41
- locationType: 'LocalPathLocation',
42
- };
43
- }
44
- throw new Error(`invalid protocol ${protocol}`);
45
- }
46
- function guessAdapterFromFileName(filePath) {
47
- const protocol = isURL(filePath) ? 'uri' : 'localPath';
48
- const name = path_1.default.basename(filePath);
49
- if (/\.vcf\.b?gz$/i.test(filePath)) {
50
- return {
51
- trackId: name,
52
- name: name,
53
- assemblyNames: [],
54
- adapter: {
55
- type: 'VcfTabixAdapter',
56
- vcfGzLocation: makeLocation(filePath, protocol),
57
- },
58
- };
59
- }
60
- else if (/\.gff3?\.b?gz$/i.test(filePath)) {
61
- return {
62
- trackId: name,
63
- name,
64
- assemblyNames: [],
65
- adapter: {
66
- type: 'Gff3TabixAdapter',
67
- gffGzLocation: makeLocation(filePath, protocol),
68
- },
69
- };
70
- }
71
- else if (/\.gtf?$/i.test(filePath)) {
72
- return {
73
- trackId: name,
74
- name,
75
- assemblyNames: [],
76
- adapter: {
77
- type: 'GtfAdapter',
78
- gtfLocation: { uri: filePath, locationType: 'UriLocation' },
79
- },
80
- };
81
- }
82
- else if (/\.vcf$/i.test(filePath)) {
83
- return {
84
- trackId: name,
85
- name,
86
- assemblyNames: [],
87
- adapter: {
88
- type: 'VcfAdapter',
89
- vcfLocation: makeLocation(filePath, protocol),
90
- },
91
- };
92
- }
93
- else if (/\.gff3?$/i.test(filePath)) {
94
- return {
95
- trackId: name,
96
- name,
97
- assemblyNames: [],
98
- adapter: {
99
- type: 'Gff3Adapter',
100
- gffLocation: makeLocation(filePath, protocol),
101
- },
102
- };
103
- }
104
- else {
105
- throw new Error(`Unsupported file type ${filePath}`);
106
- }
107
- }
108
- function supported(type = '') {
109
- return [
110
- 'Gff3TabixAdapter',
111
- 'VcfTabixAdapter',
112
- 'Gff3Adapter',
113
- 'VcfAdapter',
114
- ].includes(type);
115
- }
116
- async function generateMeta({ trackConfigs, attributes, outLocation, name, typesToExclude, assemblyNames, }) {
117
- const tracks = trackConfigs.map(({ adapter, textSearching, trackId }) => ({
118
- trackId,
119
- attributesIndexed: textSearching?.indexingAttributes || attributes,
120
- excludedTypes: textSearching?.indexingFeatureTypesToExclude || typesToExclude,
121
- adapterConf: adapter,
122
- }));
123
- fs_1.default.writeFileSync(path_1.default.join(outLocation, 'trix', `${name}_meta.json`), JSON.stringify({
124
- dateCreated: new Date().toISOString(),
125
- tracks,
126
- assemblyNames,
127
- }, null, 2));
128
- }