|
@@ -32,6 +32,15 @@ const async_exec = (prog, args, onData, onErr) => {
|
|
|
const rmList = (list) => {
|
|
const rmList = (list) => {
|
|
|
return Promise.all(list.map(e => fs_1.default.promises.rm(e, { recursive: true })));
|
|
return Promise.all(list.map(e => fs_1.default.promises.rm(e, { recursive: true })));
|
|
|
};
|
|
};
|
|
|
|
|
+const isDone = (rsltDir) => {
|
|
|
|
|
+ let done = false;
|
|
|
|
|
+ if (fs_1.default.existsSync(path_1.default.join(rsltDir, 'contigs.fasta'))) {
|
|
|
|
|
+ if (fs_1.default.statSync(path_1.default.join(rsltDir, 'contigs.fasta')).size > 1) {
|
|
|
|
|
+ done = true;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return done;
|
|
|
|
|
+};
|
|
|
const denovoAssemblage = (reads, rnames, spadesPath) => {
|
|
const denovoAssemblage = (reads, rnames, spadesPath) => {
|
|
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
let readsIn = [];
|
|
let readsIn = [];
|
|
@@ -62,11 +71,11 @@ const denovoAssemblage = (reads, rnames, spadesPath) => {
|
|
|
const args = isPairedEnd ? ['-1', tmpSubReads[0], '-2', tmpSubReads[1]] : ['-s', tmpSubReads[0]];
|
|
const args = isPairedEnd ? ['-1', tmpSubReads[0], '-2', tmpSubReads[1]] : ['-s', tmpSubReads[0]];
|
|
|
const rsltDir = path_1.default.join(os_1.default.tmpdir(), (+new Date) + '_spades');
|
|
const rsltDir = path_1.default.join(os_1.default.tmpdir(), (+new Date) + '_spades');
|
|
|
yield async_exec(spadesPath, ['-t', threads, '--isolate', ...args, '-o', rsltDir], console.log, console.log);
|
|
yield async_exec(spadesPath, ['-t', threads, '--isolate', ...args, '-o', rsltDir], console.log, console.log);
|
|
|
- if (!fs_1.default.existsSync(path_1.default.join(rsltDir, 'contigs.fasta'))) {
|
|
|
|
|
|
|
+ if (!isDone(rsltDir)) {
|
|
|
yield rmList([rsltDir]);
|
|
yield rmList([rsltDir]);
|
|
|
console.log('Trying meta');
|
|
console.log('Trying meta');
|
|
|
yield async_exec(spadesPath, ['-t', threads, '--meta', ...args, '-o', rsltDir], console.log, console.log);
|
|
yield async_exec(spadesPath, ['-t', threads, '--meta', ...args, '-o', rsltDir], console.log, console.log);
|
|
|
- if (!fs_1.default.existsSync(path_1.default.join(rsltDir, 'contigs.fasta'))) {
|
|
|
|
|
|
|
+ if (!isDone(rsltDir)) {
|
|
|
yield rmList([rsltDir, ...tmpSubReads]);
|
|
yield rmList([rsltDir, ...tmpSubReads]);
|
|
|
reject('No convergence');
|
|
reject('No convergence');
|
|
|
}
|
|
}
|