|
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
};
|
|
};
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
-exports.makeRefSeqFromReg = exports.getSymbol = exports.getFromAcc = void 0;
|
|
|
|
|
|
|
+exports.getData = exports.getOffsets = exports.makeRefSeqFromReg = exports.getSymbol = exports.getFromAcc = void 0;
|
|
|
const fs_1 = __importDefault(require("fs"));
|
|
const fs_1 = __importDefault(require("fs"));
|
|
|
const os_1 = __importDefault(require("os"));
|
|
const os_1 = __importDefault(require("os"));
|
|
|
const path_1 = __importDefault(require("path"));
|
|
const path_1 = __importDefault(require("path"));
|
|
@@ -35,6 +35,7 @@ const readline_1 = __importDefault(require("readline"));
|
|
|
const buffer_1 = require("buffer");
|
|
const buffer_1 = require("buffer");
|
|
|
const genbank_parser_1 = __importDefault(require("genbank-parser"));
|
|
const genbank_parser_1 = __importDefault(require("genbank-parser"));
|
|
|
const aligner_1 = require("aligner");
|
|
const aligner_1 = require("aligner");
|
|
|
|
|
+const jsonata_1 = __importDefault(require("jsonata"));
|
|
|
const async_exec = (prog, args, onData) => {
|
|
const async_exec = (prog, args, onData) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
return new Promise((resolve, reject) => {
|
|
|
const child = (0, child_process_1.spawn)(prog, args, { shell: true });
|
|
const child = (0, child_process_1.spawn)(prog, args, { shell: true });
|
|
@@ -135,6 +136,43 @@ const getOffset = (indexPath, acc) => __awaiter(void 0, void 0, void 0, function
|
|
|
}
|
|
}
|
|
|
return res;
|
|
return res;
|
|
|
});
|
|
});
|
|
|
|
|
+const getOffsets = (indexPath, accessions) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
|
|
+ var e_3, _g;
|
|
|
|
|
+ let res = [];
|
|
|
|
|
+ const indexPaths = Array.isArray(indexPath) ? indexPath : [indexPath];
|
|
|
|
|
+ for (const iP of indexPaths) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ for (var _h = (e_3 = void 0, __asyncValues(line$(iP))), _j; _j = yield _h.next(), !_j.done;) {
|
|
|
|
|
+ const line = _j.value;
|
|
|
|
|
+ const tmp = line.split('\t');
|
|
|
|
|
+ if (accessions.test(tmp[0])) {
|
|
|
|
|
+ res.push([iP.split('.jsi')[0], tmp[1], tmp[2], tmp[0]]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
|
|
|
+ finally {
|
|
|
|
|
+ try {
|
|
|
|
|
+ if (_j && !_j.done && (_g = _h.return)) yield _g.call(_h);
|
|
|
|
|
+ }
|
|
|
|
|
+ finally { if (e_3) throw e_3.error; }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+});
|
|
|
|
|
+exports.getOffsets = getOffsets;
|
|
|
|
|
+const getData = (dbPath, accessionRegex, query) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
|
|
+ dbPath = Array.isArray(dbPath) ? dbPath : [dbPath];
|
|
|
|
|
+ const results = [];
|
|
|
|
|
+ const allOffsets = yield getOffsets(dbPath.map(e => e + '.jsi'), accessionRegex);
|
|
|
|
|
+ for (const offset of allOffsets) {
|
|
|
|
|
+ const txt = yield readOffset(offset[0], Number(offset[1]), Number(offset[2]));
|
|
|
|
|
+ const json = (0, genbank_parser_1.default)(txt)[0];
|
|
|
|
|
+ query ? results.push((0, jsonata_1.default)(query).evaluate(json)) : results.push(json);
|
|
|
|
|
+ }
|
|
|
|
|
+ return results;
|
|
|
|
|
+});
|
|
|
|
|
+exports.getData = getData;
|
|
|
const getFromAcc = (accession, dbPath, indexPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const getFromAcc = (accession, dbPath, indexPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
dbPath = Array.isArray(dbPath) ? dbPath : [dbPath];
|
|
dbPath = Array.isArray(dbPath) ? dbPath : [dbPath];
|
|
|
if (!indexPath) {
|
|
if (!indexPath) {
|
|
@@ -227,7 +265,7 @@ const getJSI = (dbPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
});
|
|
});
|
|
|
// Todo: add progress
|
|
// Todo: add progress
|
|
|
const makeRefSeqFromReg = (dbPath, reg, distFile, limit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
const makeRefSeqFromReg = (dbPath, reg, distFile, limit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
- var e_3, _g;
|
|
|
|
|
|
|
+ var e_4, _k;
|
|
|
dbPath = Array.isArray(dbPath) ? dbPath : [dbPath];
|
|
dbPath = Array.isArray(dbPath) ? dbPath : [dbPath];
|
|
|
const jsiFiles = yield getJSI(dbPath);
|
|
const jsiFiles = yield getJSI(dbPath);
|
|
|
const tmpDir = path_1.default.join(os_1.default.tmpdir(), 'parser-' + Math.random());
|
|
const tmpDir = path_1.default.join(os_1.default.tmpdir(), 'parser-' + Math.random());
|
|
@@ -237,8 +275,8 @@ const makeRefSeqFromReg = (dbPath, reg, distFile, limit) => __awaiter(void 0, vo
|
|
|
for (const jsiFile of jsiFiles) {
|
|
for (const jsiFile of jsiFiles) {
|
|
|
console.log('reading ' + jsiFile);
|
|
console.log('reading ' + jsiFile);
|
|
|
try {
|
|
try {
|
|
|
- for (var _h = (e_3 = void 0, __asyncValues(line$(jsiFile))), _j; _j = yield _h.next(), !_j.done;) {
|
|
|
|
|
- const line = _j.value;
|
|
|
|
|
|
|
+ for (var _l = (e_4 = void 0, __asyncValues(line$(jsiFile))), _m; _m = yield _l.next(), !_m.done;) {
|
|
|
|
|
+ const line = _m.value;
|
|
|
if (line.match(reg)) {
|
|
if (line.match(reg)) {
|
|
|
const [accession, from, to] = line.split('\t');
|
|
const [accession, from, to] = line.split('\t');
|
|
|
const res = yield getFromAcc(accession, jsiFile.split('.jsi')[0]);
|
|
const res = yield getFromAcc(accession, jsiFile.split('.jsi')[0]);
|
|
@@ -269,12 +307,12 @@ const makeRefSeqFromReg = (dbPath, reg, distFile, limit) => __awaiter(void 0, vo
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
|
|
|
|
|
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
|
finally {
|
|
finally {
|
|
|
try {
|
|
try {
|
|
|
- if (_j && !_j.done && (_g = _h.return)) yield _g.call(_h);
|
|
|
|
|
|
|
+ if (_m && !_m.done && (_k = _l.return)) yield _k.call(_l);
|
|
|
}
|
|
}
|
|
|
- finally { if (e_3) throw e_3.error; }
|
|
|
|
|
|
|
+ finally { if (e_4) throw e_4.error; }
|
|
|
}
|
|
}
|
|
|
if (limit)
|
|
if (limit)
|
|
|
if (counter === limit)
|
|
if (counter === limit)
|