@jbrowse/cli 3.6.5 → 4.0.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 +4 -0
- package/bin/run +0 -0
- package/bundle/index.js +2280 -2722
- package/dist/bin.js +2 -2
- package/dist/commands/{add-assembly.js → add-assembly/index.js} +10 -10
- package/dist/commands/{assembly-utils.js → add-assembly/utils.js} +69 -105
- package/dist/commands/add-connection.js +11 -16
- package/dist/commands/add-track-json.js +26 -31
- package/dist/commands/add-track-utils/track-config.js +3 -15
- package/dist/commands/add-track-utils/validators.js +4 -9
- package/dist/commands/add-track.js +23 -25
- package/dist/commands/admin-server/index.js +100 -0
- package/dist/commands/{admin-server-utils.js → admin-server/utils.js} +7 -58
- package/dist/commands/create.js +8 -8
- package/dist/commands/{make-pif.js → make-pif/index.js} +11 -17
- package/dist/commands/{make-pif-utils → make-pif}/pif-generator.js +6 -6
- package/dist/commands/{sort-bed-utils/process-utils.js → process-utils.js} +0 -10
- package/dist/commands/remove-track.js +6 -11
- package/dist/commands/set-default-session.js +8 -12
- package/dist/commands/shared/config-operations.js +37 -0
- package/dist/commands/shared/sort-utils.js +57 -0
- package/dist/commands/shared/validators.js +18 -0
- package/dist/commands/sort-bed.js +13 -24
- package/dist/commands/sort-gff.js +13 -24
- package/dist/commands/text-index/adapter-utils.js +43 -0
- package/dist/commands/text-index/aggregate.js +52 -0
- package/dist/commands/{text-index.js → text-index/command.js} +13 -6
- package/dist/commands/text-index/config-utils.js +134 -0
- package/dist/commands/{text-index-utils → text-index}/file-list.js +12 -15
- package/dist/commands/text-index/index.js +11 -0
- package/dist/commands/{text-index-utils → text-index}/indexing-utils.js +30 -20
- package/dist/commands/text-index/per-track.js +54 -0
- package/dist/commands/track-utils.js +33 -33
- package/dist/commands/upgrade.js +8 -8
- package/dist/index.js +39 -27
- package/dist/types/common.js +9 -8
- package/dist/types/gff3Adapter.js +17 -48
- package/dist/types/streamUtils.js +66 -0
- package/dist/types/vcfAdapter.js +17 -54
- package/dist/util.js +14 -7
- package/dist/utils.js +10 -5
- package/package.json +14 -16
- package/dist/commands/admin-server.js +0 -55
- package/dist/commands/make-pif-utils/validators.js +0 -22
- package/dist/commands/sort-bed-utils/constants.js +0 -12
- package/dist/commands/sort-bed-utils/sort-utils.js +0 -24
- package/dist/commands/sort-bed-utils/validators.js +0 -22
- package/dist/commands/sort-gff-utils/constants.js +0 -13
- package/dist/commands/sort-gff-utils/process-utils.js +0 -23
- package/dist/commands/sort-gff-utils/sort-utils.js +0 -55
- package/dist/commands/sort-gff-utils/validators.js +0 -21
- package/dist/commands/text-index-utils/adapter-utils.js +0 -63
- package/dist/commands/text-index-utils/aggregate.js +0 -87
- package/dist/commands/text-index-utils/config-utils.js +0 -59
- package/dist/commands/text-index-utils/index.js +0 -9
- package/dist/commands/text-index-utils/per-track.js +0 -65
- /package/dist/commands/{make-pif-utils → make-pif}/cigar-utils.js +0 -0
- /package/dist/commands/{make-pif-utils → make-pif}/file-utils.js +0 -0
- /package/dist/commands/{text-index-utils → text-index}/validators.js +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jbrowse/cli",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A command line tool for working with JBrowse 2",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jbrowse",
|
|
@@ -27,26 +27,24 @@
|
|
|
27
27
|
"engines": {
|
|
28
28
|
"node": ">=18.3.0"
|
|
29
29
|
},
|
|
30
|
-
"scripts": {
|
|
31
|
-
"prebuild": "npm run clean",
|
|
32
|
-
"build": "tsc --build && webpack",
|
|
33
|
-
"clean": "rimraf dist bundle",
|
|
34
|
-
"prepack": "npm run clean && npm run docs",
|
|
35
|
-
"predocs": "npm run build",
|
|
36
|
-
"docs": "./generate_readme.sh > README.md"
|
|
37
|
-
},
|
|
38
30
|
"dependencies": {
|
|
39
|
-
"cli-progress": "^3.
|
|
31
|
+
"cli-progress": "^3.12.0",
|
|
40
32
|
"command-exists": "^1.2.9",
|
|
41
33
|
"cors": "^2.8.5",
|
|
42
|
-
"decompress": "^4.
|
|
43
|
-
"express": "^5.1
|
|
44
|
-
"ixixx": "^
|
|
34
|
+
"decompress": "^4.2.1",
|
|
35
|
+
"express": "^5.2.1",
|
|
36
|
+
"ixixx": "^3.0.2",
|
|
45
37
|
"json-parse-better-errors": "^1.0.2",
|
|
46
|
-
"node-fetch-native": "^1.6.
|
|
38
|
+
"node-fetch-native": "^1.6.7",
|
|
39
|
+
"tmp": "^0.2.5"
|
|
47
40
|
},
|
|
48
41
|
"publishConfig": {
|
|
49
42
|
"access": "public"
|
|
50
43
|
},
|
|
51
|
-
"
|
|
52
|
-
|
|
44
|
+
"scripts": {
|
|
45
|
+
"prebuild": "pnpm clean",
|
|
46
|
+
"build": "tsc && webpack",
|
|
47
|
+
"clean": "rimraf bundle",
|
|
48
|
+
"generate-readme": "./generate_readme.sh > README.md"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.run = run;
|
|
4
|
-
const util_1 = require("util");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
const admin_server_utils_1 = require("./admin-server-utils");
|
|
7
|
-
async function run(args) {
|
|
8
|
-
const options = {
|
|
9
|
-
help: {
|
|
10
|
-
type: 'boolean',
|
|
11
|
-
short: 'h',
|
|
12
|
-
},
|
|
13
|
-
port: {
|
|
14
|
-
type: 'string',
|
|
15
|
-
short: 'p',
|
|
16
|
-
description: 'Specified port to start the server on (default: 9090)',
|
|
17
|
-
},
|
|
18
|
-
root: {
|
|
19
|
-
type: 'string',
|
|
20
|
-
description: 'Path to the root of the JB2 installation',
|
|
21
|
-
},
|
|
22
|
-
bodySizeLimit: {
|
|
23
|
-
type: 'string',
|
|
24
|
-
description: 'Size limit of the update message (default: 25mb)',
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
const { values: flags } = (0, util_1.parseArgs)({
|
|
28
|
-
args,
|
|
29
|
-
options,
|
|
30
|
-
allowPositionals: true,
|
|
31
|
-
});
|
|
32
|
-
const description = 'Start up a small admin server for JBrowse configuration';
|
|
33
|
-
const examples = ['$ jbrowse admin-server', '$ jbrowse admin-server -p 8888'];
|
|
34
|
-
if (flags.help) {
|
|
35
|
-
(0, utils_1.printHelp)({
|
|
36
|
-
description,
|
|
37
|
-
examples,
|
|
38
|
-
usage: 'jbrowse admin-server [options]',
|
|
39
|
-
options,
|
|
40
|
-
});
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
const { root, bodySizeLimit = '25mb' } = flags;
|
|
44
|
-
const { outFile, baseDir } = await (0, admin_server_utils_1.setupConfigFile)({ root });
|
|
45
|
-
// Parse and validate port
|
|
46
|
-
const port = (0, admin_server_utils_1.parsePort)({ portStr: flags.port });
|
|
47
|
-
// Set up the Express server
|
|
48
|
-
const { app, key, keyPath, serverRef } = (0, admin_server_utils_1.setupServer)({
|
|
49
|
-
baseDir,
|
|
50
|
-
outFile,
|
|
51
|
-
bodySizeLimit,
|
|
52
|
-
});
|
|
53
|
-
// Start the server and set up shutdown handlers
|
|
54
|
-
(0, admin_server_utils_1.startServer)({ app, port, key, outFile, keyPath, serverRef });
|
|
55
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFileArgument = validateFileArgument;
|
|
4
|
-
exports.validateRequiredCommands = validateRequiredCommands;
|
|
5
|
-
const command_exists_1 = require("command-exists");
|
|
6
|
-
function validateFileArgument(file) {
|
|
7
|
-
// Allow no file argument for stdin input
|
|
8
|
-
if (!file && process.stdin.isTTY) {
|
|
9
|
-
console.error('Error: Missing required argument: file');
|
|
10
|
-
console.error('Usage: jbrowse make-pif <file> [options]');
|
|
11
|
-
console.error(' OR pipe data via stdin: cat file.paf | jbrowse make-pif');
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function validateRequiredCommands() {
|
|
16
|
-
const requiredCommands = ['sh', 'sort', 'grep', 'tabix', 'bgzip'];
|
|
17
|
-
const missingCommands = requiredCommands.filter(cmd => !(0, command_exists_1.sync)(cmd));
|
|
18
|
-
if (missingCommands.length > 0) {
|
|
19
|
-
console.error('Error: Unable to sort, requires unix type environment with sort, grep, bgzip, tabix');
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REQUIRED_COMMANDS = exports.SORT_BED_EXAMPLES = exports.SORT_BED_DESCRIPTION = void 0;
|
|
4
|
-
exports.SORT_BED_DESCRIPTION = 'Helper utility to sort BED files for tabix. Moves all lines starting with # to the top of the file, and sort by refname and start position using unix utilities sort and grep';
|
|
5
|
-
exports.SORT_BED_EXAMPLES = [
|
|
6
|
-
'# sort bed and pipe to bgzip',
|
|
7
|
-
'$ jbrowse sort-bed input.bed | bgzip > sorted.bed.gz',
|
|
8
|
-
'$ tabix sorted.bed.gz',
|
|
9
|
-
'',
|
|
10
|
-
'# OR pipe data via stdin: cat file.bed | jbrowse sort-bed | bgzip > sorted.bed.gz',
|
|
11
|
-
];
|
|
12
|
-
exports.REQUIRED_COMMANDS = ['sh', 'sort', 'grep'];
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMinimalEnvironment = getMinimalEnvironment;
|
|
4
|
-
exports.createSortCommandForFile = createSortCommandForFile;
|
|
5
|
-
exports.spawnSortProcess = spawnSortProcess;
|
|
6
|
-
const child_process_1 = require("child_process");
|
|
7
|
-
function getMinimalEnvironment() {
|
|
8
|
-
return {
|
|
9
|
-
...process.env,
|
|
10
|
-
LC_ALL: 'C',
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function createSortCommandForFile(file) {
|
|
14
|
-
// BED files use columns 1,2 (0-based) for chromosome and start position
|
|
15
|
-
return `(grep "^#" "${file}"; grep -v "^#" "${file}" | sort -t"\`printf '\\t'\`" -k1,1 -k2,2n)`;
|
|
16
|
-
}
|
|
17
|
-
function spawnSortProcess(options) {
|
|
18
|
-
const command = createSortCommandForFile(options.file);
|
|
19
|
-
const env = getMinimalEnvironment();
|
|
20
|
-
return (0, child_process_1.spawn)('sh', ['-c', command], {
|
|
21
|
-
env,
|
|
22
|
-
stdio: 'inherit',
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFileArgument = validateFileArgument;
|
|
4
|
-
exports.validateRequiredCommands = validateRequiredCommands;
|
|
5
|
-
const command_exists_1 = require("command-exists");
|
|
6
|
-
function validateFileArgument(file) {
|
|
7
|
-
// Allow no file argument for stdin input
|
|
8
|
-
if (!file && process.stdin.isTTY) {
|
|
9
|
-
console.error('Error: Missing required argument: file');
|
|
10
|
-
console.error('Usage: jbrowse sort-bed <file>');
|
|
11
|
-
console.error(' OR pipe data via stdin: cat file.bed | jbrowse sort-bed');
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function validateRequiredCommands() {
|
|
16
|
-
const requiredCommands = ['sh', 'sort', 'grep'];
|
|
17
|
-
const missingCommands = requiredCommands.filter(cmd => !(0, command_exists_1.sync)(cmd));
|
|
18
|
-
if (missingCommands.length > 0) {
|
|
19
|
-
console.error('Error: Unable to sort, requires unix type environment with sort, grep');
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REQUIRED_COMMANDS = exports.SORT_GFF_EXAMPLES = exports.SORT_GFF_DESCRIPTION = void 0;
|
|
4
|
-
exports.SORT_GFF_DESCRIPTION = 'Helper utility to sort GFF files for tabix. Moves all lines starting with # to the top of the file, and sort by refname and start position using unix utilities sort and grep';
|
|
5
|
-
exports.SORT_GFF_EXAMPLES = [
|
|
6
|
-
'# sort gff and pipe to bgzip',
|
|
7
|
-
'$ jbrowse sort-gff input.gff | bgzip > sorted.gff.gz',
|
|
8
|
-
'$ tabix sorted.gff.gz',
|
|
9
|
-
'',
|
|
10
|
-
'# sort gff from stdin',
|
|
11
|
-
'$ cat input.gff | jbrowse sort-gff | bgzip > sorted.gff.gz',
|
|
12
|
-
];
|
|
13
|
-
exports.REQUIRED_COMMANDS = ['sh', 'sort', 'grep'];
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.waitForProcessClose = waitForProcessClose;
|
|
4
|
-
exports.handleProcessError = handleProcessError;
|
|
5
|
-
async function waitForProcessClose(child) {
|
|
6
|
-
return new Promise((resolve, reject) => {
|
|
7
|
-
child.on('close', code => {
|
|
8
|
-
resolve(code);
|
|
9
|
-
});
|
|
10
|
-
child.on('error', err => {
|
|
11
|
-
reject(err);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function handleProcessError(error) {
|
|
16
|
-
if (error instanceof Error) {
|
|
17
|
-
console.error(`Process error: ${error.message}`);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
console.error('Unknown process error:', error);
|
|
21
|
-
}
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
@@ -1,55 +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.getMinimalEnvironment = getMinimalEnvironment;
|
|
7
|
-
exports.createSortCommandForStdin = createSortCommandForStdin;
|
|
8
|
-
exports.createSortCommandForFile = createSortCommandForFile;
|
|
9
|
-
exports.spawnSortProcessFromFile = spawnSortProcessFromFile;
|
|
10
|
-
exports.spawnSortProcessFromStdin = spawnSortProcessFromStdin;
|
|
11
|
-
exports.spawnSortProcess = spawnSortProcess;
|
|
12
|
-
const child_process_1 = require("child_process");
|
|
13
|
-
const tmp_1 = __importDefault(require("tmp"));
|
|
14
|
-
function getMinimalEnvironment() {
|
|
15
|
-
return {
|
|
16
|
-
...process.env,
|
|
17
|
-
LC_ALL: 'C',
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
function createSortCommandForStdin() {
|
|
21
|
-
// Create a temporary file to store stdin content, then process it
|
|
22
|
-
// This allows us to read the data twice - once for headers, once for sorting
|
|
23
|
-
const tmpFile = tmp_1.default.fileSync({
|
|
24
|
-
prefix: 'jbrowse-sort-gff',
|
|
25
|
-
}).name;
|
|
26
|
-
const sortCmd = `sort -t"\`printf '\\t'\`" -k1,1 -k4,4n`;
|
|
27
|
-
// Save stdin to temp file, extract headers, sort non-headers, then cleanup
|
|
28
|
-
return `cat > ${tmpFile} && (grep "^#" ${tmpFile}; grep -v "^#" ${tmpFile} | ${sortCmd}) && rm -f ${tmpFile}`;
|
|
29
|
-
}
|
|
30
|
-
function createSortCommandForFile(file) {
|
|
31
|
-
// When reading from a file, we can read it multiple times directly
|
|
32
|
-
// Need to wrap in parentheses to ensure both grep outputs are combined
|
|
33
|
-
return `(grep "^#" "${file}"; grep -v "^#" "${file}" | sort -t"\`printf '\\t'\`" -k1,1 -k4,4n)`;
|
|
34
|
-
}
|
|
35
|
-
function spawnSortProcessFromFile(file) {
|
|
36
|
-
const command = createSortCommandForFile(file);
|
|
37
|
-
const env = getMinimalEnvironment();
|
|
38
|
-
return (0, child_process_1.spawn)('sh', ['-c', command], {
|
|
39
|
-
env,
|
|
40
|
-
stdio: 'inherit',
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function spawnSortProcessFromStdin() {
|
|
44
|
-
const command = createSortCommandForStdin();
|
|
45
|
-
const env = getMinimalEnvironment();
|
|
46
|
-
return (0, child_process_1.spawn)('sh', ['-c', command], {
|
|
47
|
-
env,
|
|
48
|
-
stdio: 'inherit',
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function spawnSortProcess(options) {
|
|
52
|
-
return options.file
|
|
53
|
-
? spawnSortProcessFromFile(options.file)
|
|
54
|
-
: spawnSortProcessFromStdin();
|
|
55
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateFileArgument = validateFileArgument;
|
|
4
|
-
exports.validateRequiredCommands = validateRequiredCommands;
|
|
5
|
-
const command_exists_1 = require("command-exists");
|
|
6
|
-
function validateFileArgument(file) {
|
|
7
|
-
// Allow no file argument for stdin input
|
|
8
|
-
if (!file && process.stdin.isTTY) {
|
|
9
|
-
console.error('Error: Missing required argument: file');
|
|
10
|
-
console.error('Usage: jbrowse sort-gff <file>');
|
|
11
|
-
console.error(' OR pipe data via stdin: cat file.gff | jbrowse sort-gff');
|
|
12
|
-
process.exit(1);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
function validateRequiredCommands() {
|
|
16
|
-
const requiredCommands = ['sh', 'sort', 'grep'];
|
|
17
|
-
const missingCommands = requiredCommands.filter(cmd => !(0, command_exists_1.sync)(cmd));
|
|
18
|
-
if (missingCommands.length > 0) {
|
|
19
|
-
throw new Error('Error: Unable to sort, requires unix type environment with sort, grep');
|
|
20
|
-
}
|
|
21
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLoc = getLoc;
|
|
4
|
-
exports.createTrixAdapter = createTrixAdapter;
|
|
5
|
-
exports.createPerTrackTrixAdapter = createPerTrackTrixAdapter;
|
|
6
|
-
exports.getAdapterLocation = getAdapterLocation;
|
|
7
|
-
function getLoc(elt) {
|
|
8
|
-
return elt.locationType === 'LocalPathLocation' ? elt.localPath : elt.uri;
|
|
9
|
-
}
|
|
10
|
-
function createTrixAdapter(id, asm, assemblyNames) {
|
|
11
|
-
return {
|
|
12
|
-
type: 'TrixTextSearchAdapter',
|
|
13
|
-
textSearchAdapterId: id,
|
|
14
|
-
ixFilePath: {
|
|
15
|
-
uri: `trix/${asm}.ix`,
|
|
16
|
-
locationType: 'UriLocation',
|
|
17
|
-
},
|
|
18
|
-
ixxFilePath: {
|
|
19
|
-
uri: `trix/${asm}.ixx`,
|
|
20
|
-
locationType: 'UriLocation',
|
|
21
|
-
},
|
|
22
|
-
metaFilePath: {
|
|
23
|
-
uri: `trix/${asm}_meta.json`,
|
|
24
|
-
locationType: 'UriLocation',
|
|
25
|
-
},
|
|
26
|
-
assemblyNames: assemblyNames || [asm],
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function createPerTrackTrixAdapter(trackId, assemblyNames) {
|
|
30
|
-
return {
|
|
31
|
-
type: 'TrixTextSearchAdapter',
|
|
32
|
-
textSearchAdapterId: `${trackId}-index`,
|
|
33
|
-
ixFilePath: {
|
|
34
|
-
uri: `trix/${trackId}.ix`,
|
|
35
|
-
locationType: 'UriLocation',
|
|
36
|
-
},
|
|
37
|
-
ixxFilePath: {
|
|
38
|
-
uri: `trix/${trackId}.ixx`,
|
|
39
|
-
locationType: 'UriLocation',
|
|
40
|
-
},
|
|
41
|
-
metaFilePath: {
|
|
42
|
-
uri: `trix/${trackId}_meta.json`,
|
|
43
|
-
locationType: 'UriLocation',
|
|
44
|
-
},
|
|
45
|
-
assemblyNames: assemblyNames,
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function getAdapterLocation(adapter) {
|
|
49
|
-
const { type } = adapter || {};
|
|
50
|
-
if (type === 'Gff3TabixAdapter') {
|
|
51
|
-
return adapter.gffGzLocation || adapter;
|
|
52
|
-
}
|
|
53
|
-
else if (type === 'Gff3Adapter') {
|
|
54
|
-
return adapter.gffLocation || adapter;
|
|
55
|
-
}
|
|
56
|
-
else if (type === 'VcfAdapter') {
|
|
57
|
-
return adapter.vcfLocation || adapter;
|
|
58
|
-
}
|
|
59
|
-
else if (type === 'VcfTabixAdapter') {
|
|
60
|
-
return adapter.vcfGzLocation || adapter;
|
|
61
|
-
}
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
@@ -1,87 +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.aggregateIndex = aggregateIndex;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const config_utils_1 = require("./config-utils");
|
|
10
|
-
const indexing_utils_1 = require("./indexing-utils");
|
|
11
|
-
async function aggregateIndex(flags) {
|
|
12
|
-
const { out, target, tracks, assemblies, attributes, quiet, force, exclude, dryrun, prefixSize, } = flags;
|
|
13
|
-
const outFlag = target || out || '.';
|
|
14
|
-
const isDir = fs_1.default.lstatSync(outFlag).isDirectory();
|
|
15
|
-
const confPath = isDir ? path_1.default.join(outFlag, 'config.json') : outFlag;
|
|
16
|
-
const outLocation = path_1.default.dirname(confPath);
|
|
17
|
-
const config = (0, config_utils_1.readConf)(confPath);
|
|
18
|
-
const trixDir = path_1.default.join(outLocation, 'trix');
|
|
19
|
-
if (!fs_1.default.existsSync(trixDir)) {
|
|
20
|
-
fs_1.default.mkdirSync(trixDir);
|
|
21
|
-
}
|
|
22
|
-
const aggregateTextSearchAdapters = config.aggregateTextSearchAdapters || [];
|
|
23
|
-
const asms = assemblies?.split(',') ||
|
|
24
|
-
config.assemblies?.map(a => a.name) ||
|
|
25
|
-
(config.assembly ? [config.assembly.name] : []);
|
|
26
|
-
if (!asms.length) {
|
|
27
|
-
throw new Error('No assemblies found');
|
|
28
|
-
}
|
|
29
|
-
for (const asm of asms) {
|
|
30
|
-
const trackConfigs = (0, config_utils_1.getTrackConfigs)(confPath, tracks?.split(','), asm);
|
|
31
|
-
if (!trackConfigs.length) {
|
|
32
|
-
console.log(`Indexing assembly ${asm}...(no tracks found)...`);
|
|
33
|
-
continue;
|
|
34
|
-
}
|
|
35
|
-
console.log(`Indexing assembly ${asm}...`);
|
|
36
|
-
if (dryrun) {
|
|
37
|
-
console.log(trackConfigs.map(e => `${e.trackId} ${e.adapter?.type}`).join('\n'));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const id = `${asm}-index`;
|
|
41
|
-
const idx = aggregateTextSearchAdapters.findIndex(x => x.textSearchAdapterId === id);
|
|
42
|
-
if (idx !== -1 && !force) {
|
|
43
|
-
console.log(`Note: ${asm} has already been indexed with this configuration, use --force to overwrite this assembly. Skipping for now`);
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
|
-
await (0, indexing_utils_1.indexDriver)({
|
|
47
|
-
trackConfigs,
|
|
48
|
-
outLocation,
|
|
49
|
-
quiet,
|
|
50
|
-
name: asm,
|
|
51
|
-
attributes: attributes.split(','),
|
|
52
|
-
typesToExclude: exclude.split(','),
|
|
53
|
-
assemblyNames: [asm],
|
|
54
|
-
prefixSize,
|
|
55
|
-
});
|
|
56
|
-
const trixConf = {
|
|
57
|
-
type: 'TrixTextSearchAdapter',
|
|
58
|
-
textSearchAdapterId: id,
|
|
59
|
-
ixFilePath: {
|
|
60
|
-
uri: `trix/${asm}.ix`,
|
|
61
|
-
locationType: 'UriLocation',
|
|
62
|
-
},
|
|
63
|
-
ixxFilePath: {
|
|
64
|
-
uri: `trix/${asm}.ixx`,
|
|
65
|
-
locationType: 'UriLocation',
|
|
66
|
-
},
|
|
67
|
-
metaFilePath: {
|
|
68
|
-
uri: `trix/${asm}_meta.json`,
|
|
69
|
-
locationType: 'UriLocation',
|
|
70
|
-
},
|
|
71
|
-
assemblyNames: [asm],
|
|
72
|
-
};
|
|
73
|
-
if (idx === -1) {
|
|
74
|
-
aggregateTextSearchAdapters.push(trixConf);
|
|
75
|
-
}
|
|
76
|
-
else {
|
|
77
|
-
aggregateTextSearchAdapters[idx] = trixConf;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
if (!dryrun) {
|
|
82
|
-
(0, config_utils_1.writeConf)({
|
|
83
|
-
...config,
|
|
84
|
-
aggregateTextSearchAdapters,
|
|
85
|
-
}, confPath);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
@@ -1,59 +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.readConf = readConf;
|
|
7
|
-
exports.writeConf = writeConf;
|
|
8
|
-
exports.getConfigPath = getConfigPath;
|
|
9
|
-
exports.ensureTrixDir = ensureTrixDir;
|
|
10
|
-
exports.getAssemblyNames = getAssemblyNames;
|
|
11
|
-
exports.getTrackConfigs = getTrackConfigs;
|
|
12
|
-
const fs_1 = __importDefault(require("fs"));
|
|
13
|
-
const path_1 = __importDefault(require("path"));
|
|
14
|
-
const common_1 = require("../../types/common");
|
|
15
|
-
function readConf(configPath) {
|
|
16
|
-
return JSON.parse(fs_1.default.readFileSync(configPath, 'utf8'));
|
|
17
|
-
}
|
|
18
|
-
function writeConf(obj, configPath) {
|
|
19
|
-
fs_1.default.writeFileSync(configPath, JSON.stringify(obj, null, 2));
|
|
20
|
-
}
|
|
21
|
-
function getConfigPath(outFlag) {
|
|
22
|
-
const isDir = fs_1.default.lstatSync(outFlag).isDirectory();
|
|
23
|
-
const configPath = isDir ? path_1.default.join(outFlag, 'config.json') : outFlag;
|
|
24
|
-
const outLocation = path_1.default.dirname(configPath);
|
|
25
|
-
return { configPath, outLocation };
|
|
26
|
-
}
|
|
27
|
-
function ensureTrixDir(outLocation) {
|
|
28
|
-
const trixDir = path_1.default.join(outLocation, 'trix');
|
|
29
|
-
if (!fs_1.default.existsSync(trixDir)) {
|
|
30
|
-
fs_1.default.mkdirSync(trixDir);
|
|
31
|
-
}
|
|
32
|
-
return trixDir;
|
|
33
|
-
}
|
|
34
|
-
function getAssemblyNames(config, assemblies) {
|
|
35
|
-
const asms = assemblies?.split(',') ||
|
|
36
|
-
config.assemblies?.map(a => a.name) ||
|
|
37
|
-
(config.assembly ? [config.assembly.name] : []);
|
|
38
|
-
if (!asms.length) {
|
|
39
|
-
throw new Error('No assemblies found');
|
|
40
|
-
}
|
|
41
|
-
return asms;
|
|
42
|
-
}
|
|
43
|
-
function getTrackConfigs(configPath, trackIds, assemblyName) {
|
|
44
|
-
const { tracks } = readConf(configPath);
|
|
45
|
-
if (!tracks) {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
const trackIdsToIndex = trackIds || tracks.map(track => track.trackId);
|
|
49
|
-
return trackIdsToIndex
|
|
50
|
-
.map(trackId => {
|
|
51
|
-
const currentTrack = tracks.find(t => trackId === t.trackId);
|
|
52
|
-
if (!currentTrack) {
|
|
53
|
-
throw new Error(`Track not found in config.json for trackId ${trackId}, please add track configuration before indexing.`);
|
|
54
|
-
}
|
|
55
|
-
return currentTrack;
|
|
56
|
-
})
|
|
57
|
-
.filter(track => (0, common_1.supported)(track.adapter?.type))
|
|
58
|
-
.filter(track => assemblyName ? track.assemblyNames.includes(assemblyName) : true);
|
|
59
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.indexFileList = exports.perTrackIndex = exports.aggregateIndex = void 0;
|
|
4
|
-
var aggregate_1 = require("./aggregate");
|
|
5
|
-
Object.defineProperty(exports, "aggregateIndex", { enumerable: true, get: function () { return aggregate_1.aggregateIndex; } });
|
|
6
|
-
var per_track_1 = require("./per-track");
|
|
7
|
-
Object.defineProperty(exports, "perTrackIndex", { enumerable: true, get: function () { return per_track_1.perTrackIndex; } });
|
|
8
|
-
var file_list_1 = require("./file-list");
|
|
9
|
-
Object.defineProperty(exports, "indexFileList", { enumerable: true, get: function () { return file_list_1.indexFileList; } });
|
|
@@ -1,65 +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.perTrackIndex = perTrackIndex;
|
|
7
|
-
const fs_1 = __importDefault(require("fs"));
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const adapter_utils_1 = require("./adapter-utils");
|
|
10
|
-
const config_utils_1 = require("./config-utils");
|
|
11
|
-
const indexing_utils_1 = require("./indexing-utils");
|
|
12
|
-
const validators_1 = require("./validators");
|
|
13
|
-
async function perTrackIndex(flags) {
|
|
14
|
-
const { out, target, tracks, assemblies, attributes, quiet, force, exclude, prefixSize, } = flags;
|
|
15
|
-
const outFlag = target || out || '.';
|
|
16
|
-
const isDir = fs_1.default.lstatSync(outFlag).isDirectory();
|
|
17
|
-
const confFilePath = isDir ? path_1.default.join(outFlag, 'config.json') : outFlag;
|
|
18
|
-
const outLocation = path_1.default.dirname(confFilePath);
|
|
19
|
-
const config = (0, config_utils_1.readConf)(confFilePath);
|
|
20
|
-
const configTracks = config.tracks || [];
|
|
21
|
-
const trixDir = path_1.default.join(outLocation, 'trix');
|
|
22
|
-
if (!fs_1.default.existsSync(trixDir)) {
|
|
23
|
-
fs_1.default.mkdirSync(trixDir);
|
|
24
|
-
}
|
|
25
|
-
(0, validators_1.validateAssembliesForPerTrack)(assemblies);
|
|
26
|
-
const confs = (0, config_utils_1.getTrackConfigs)(confFilePath, tracks?.split(','));
|
|
27
|
-
if (!confs.length) {
|
|
28
|
-
throw new Error('Tracks not found in config.json, please add track configurations before indexing.');
|
|
29
|
-
}
|
|
30
|
-
for (const trackConfig of confs) {
|
|
31
|
-
const { textSearching, trackId, assemblyNames } = trackConfig;
|
|
32
|
-
if (textSearching?.textSearchAdapter && !force) {
|
|
33
|
-
console.log(`Note: ${trackId} has already been indexed with this configuration, use --force to overwrite this track. Skipping for now`);
|
|
34
|
-
continue;
|
|
35
|
-
}
|
|
36
|
-
console.log(`Indexing track ${trackId}...`);
|
|
37
|
-
await (0, indexing_utils_1.indexDriver)({
|
|
38
|
-
trackConfigs: [trackConfig],
|
|
39
|
-
attributes: attributes.split(','),
|
|
40
|
-
outLocation,
|
|
41
|
-
quiet,
|
|
42
|
-
name: trackId,
|
|
43
|
-
typesToExclude: exclude.split(','),
|
|
44
|
-
assemblyNames,
|
|
45
|
-
prefixSize,
|
|
46
|
-
});
|
|
47
|
-
if (!textSearching?.textSearchAdapter) {
|
|
48
|
-
// modifies track with new text search adapter
|
|
49
|
-
const index = configTracks.findIndex(track => trackId === track.trackId);
|
|
50
|
-
if (index !== -1) {
|
|
51
|
-
configTracks[index] = {
|
|
52
|
-
...trackConfig,
|
|
53
|
-
textSearching: {
|
|
54
|
-
...textSearching,
|
|
55
|
-
textSearchAdapter: (0, adapter_utils_1.createPerTrackTrixAdapter)(trackId, assemblyNames),
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
console.log("Error: can't find trackId");
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
(0, config_utils_1.writeConf)({ ...config, tracks: configTracks }, confFilePath);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|