|
|
@@ -226,14 +226,16 @@ const getJSI = (dbPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
return indexPath;
|
|
|
});
|
|
|
// Todo: add progress
|
|
|
-const makeRefSeqFromReg = (dbPath, reg, distFile) => __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;
|
|
|
dbPath = Array.isArray(dbPath) ? dbPath : [dbPath];
|
|
|
const jsiFiles = yield getJSI(dbPath);
|
|
|
const tmpDir = path_1.default.join(os_1.default.tmpdir(), 'parser-' + Math.random());
|
|
|
yield fs_1.default.promises.mkdir(tmpDir);
|
|
|
const createdFiles = [];
|
|
|
+ let counter = 0;
|
|
|
for (const jsiFile of jsiFiles) {
|
|
|
+ console.log('reading ' + jsiFile);
|
|
|
try {
|
|
|
for (var _h = (e_3 = void 0, __asyncValues(line$(jsiFile))), _j; _j = yield _h.next(), !_j.done;) {
|
|
|
const line = _j.value;
|
|
|
@@ -243,14 +245,22 @@ const makeRefSeqFromReg = (dbPath, reg, distFile) => __awaiter(void 0, void 0, v
|
|
|
if (res === null || res === void 0 ? void 0 : res.sequence) {
|
|
|
try {
|
|
|
const file = path_1.default.join(tmpDir, (res === null || res === void 0 ? void 0 : res.version) || res.accession + '.fa');
|
|
|
- yield (0, aligner_1.writeSequence)((res === null || res === void 0 ? void 0 : res.version) || res.accession, res === null || res === void 0 ? void 0 : res.sequence, file);
|
|
|
- createdFiles.push(file);
|
|
|
+ if (!createdFiles.includes(file)) {
|
|
|
+ yield (0, aligner_1.writeSequence)((res === null || res === void 0 ? void 0 : res.version) || res.accession, res === null || res === void 0 ? void 0 : res.sequence, file);
|
|
|
+ createdFiles.push(file);
|
|
|
+ counter++;
|
|
|
+ if (counter % 100 === 0)
|
|
|
+ console.log('Already ' + counter + ' sequence parsed');
|
|
|
+ }
|
|
|
}
|
|
|
catch (error) {
|
|
|
console.log(error);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if (limit)
|
|
|
+ if (counter === limit)
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
|
@@ -260,6 +270,9 @@ const makeRefSeqFromReg = (dbPath, reg, distFile) => __awaiter(void 0, void 0, v
|
|
|
}
|
|
|
finally { if (e_3) throw e_3.error; }
|
|
|
}
|
|
|
+ if (limit)
|
|
|
+ if (counter === limit)
|
|
|
+ break;
|
|
|
}
|
|
|
console.log(createdFiles.length + ' sequences');
|
|
|
if (fs_1.default.existsSync(distFile))
|