|
|
@@ -73,19 +73,25 @@ var async_exec = function (prog, args, onData) {
|
|
|
child.on('exit', function (code) { return resolve(code); });
|
|
|
});
|
|
|
};
|
|
|
+var invReplace = function (regex, string, by) {
|
|
|
+ if (by === void 0) { by = '_'; }
|
|
|
+ return string.split('').map(function (letter) { return letter.match(regex) ? letter : by; }).join('');
|
|
|
+};
|
|
|
var makeReference = function (sequenceName, sequence, filePath, lineN) {
|
|
|
if (lineN === void 0) { lineN = 80; }
|
|
|
return __awaiter(void 0, void 0, void 0, function () {
|
|
|
return __generator(this, function (_a) {
|
|
|
return [2 /*return*/, new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
|
- var r, error_1;
|
|
|
+ var r, regex_sam_restriction, nSeqName, error_1;
|
|
|
var _a;
|
|
|
return __generator(this, function (_b) {
|
|
|
switch (_b.label) {
|
|
|
case 0:
|
|
|
_b.trys.push([0, 3, , 4]);
|
|
|
r = new RegExp(".{1," + lineN + "}", "g");
|
|
|
- return [4 /*yield*/, fs_1.default.promises.writeFile(filePath, '>' + sequenceName + '\n' + ((_a = sequence.match(r)) === null || _a === void 0 ? void 0 : _a.join('\n')))];
|
|
|
+ regex_sam_restriction = /[>0-9A-Za-z!#$%&+\./:;?@^_|~-]|[\n\t]/g;
|
|
|
+ nSeqName = invReplace(regex_sam_restriction, sequenceName);
|
|
|
+ return [4 /*yield*/, fs_1.default.promises.writeFile(filePath, '>' + nSeqName + '\n' + ((_a = sequence.match(r)) === null || _a === void 0 ? void 0 : _a.join('\n')))];
|
|
|
case 1:
|
|
|
_b.sent();
|
|
|
return [4 /*yield*/, async_exec('bwa', ['index', filePath], function () { return console.log; })];
|