Thomas преди 4 години
родител
ревизия
75f35f7efe
променени са 2 файла, в които са добавени 9 реда и са изтрити 8 реда
  1. 4 4
      index.js
  2. 5 4
      index.ts

+ 4 - 4
index.js

@@ -41,7 +41,7 @@ const isDone = (rsltDir) => {
     }
     return done;
 };
-const denovoAssemblage = (reads, rnames, spadesPath) => {
+const denovoAssemblage = (reads, rnames, spadesPath, log) => {
     return new Promise((resolve, reject) => __awaiter(void 0, void 0, void 0, function* () {
         let readsIn = [];
         let isPairedEnd = false;
@@ -69,16 +69,16 @@ const denovoAssemblage = (reads, rnames, spadesPath) => {
             isfq.push(R.match(/\.fq/) ? true : false);
             const tmp = path_1.default.join(os_1.default.tmpdir(), (+new Date) + '_' + parsedPath.name + (isfq[isfq.length] ? '.fq' : '.fa'));
             tmpSubReads.push(tmp);
-            yield async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], console.log, console.log);
+            yield async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], log, log);
         }
         const correction = (isfq.filter(e => e).length !== isfq.length || isfq.filter(e => e).length === 0) ? '--only-assembler' : '';
         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');
-        yield async_exec(spadesPath, ['-t', threads, '--isolate', correction, ...args, '-o', rsltDir], console.log, console.log);
+        yield async_exec(spadesPath, ['-t', threads, '--isolate', correction, ...args, '-o', rsltDir], log, log);
         if (!isDone(rsltDir) && isPairedEnd) {
             yield rmList([rsltDir]);
             console.log('Trying meta');
-            yield async_exec(spadesPath, ['-t', threads, '--meta', correction, ...args, '-o', rsltDir], console.log, console.log);
+            yield async_exec(spadesPath, ['-t', threads, '--meta', correction, ...args, '-o', rsltDir], log, log);
             if (!isDone(rsltDir)) {
                 yield rmList([rsltDir, ...tmpSubReads]);
                 reject('No convergence');

+ 5 - 4
index.ts

@@ -36,7 +36,8 @@ const isDone = (rsltDir:string) => {
 const denovoAssemblage = (
     reads : string | string[],
     rnames: string[],
-    spadesPath: string
+    spadesPath: string,
+    log: Function
 ) => {
     return new Promise<string>(async (resolve, reject) => {
         let readsIn: string[] = []
@@ -66,7 +67,7 @@ const denovoAssemblage = (
             isfq.push(R.match(/\.fq/) ? true : false)
             const tmp = path.join(os.tmpdir(), (+new Date)  + '_' + parsedPath.name + (isfq[isfq.length] ? '.fq' : '.fa'))
             tmpSubReads.push(tmp)
-            await async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], console.log, console.log)
+            await async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], log, log)
             
         }
 
@@ -75,12 +76,12 @@ const denovoAssemblage = (
         const args = isPairedEnd ? ['-1', tmpSubReads[0], '-2', tmpSubReads[1]] : ['-s', tmpSubReads[0]]
         const rsltDir = path.join(os.tmpdir(), (+new Date)  + '_spades')
         
-        await async_exec(spadesPath, ['-t', threads, '--isolate', correction, ...args, '-o', rsltDir], console.log, console.log)
+        await async_exec(spadesPath, ['-t', threads, '--isolate', correction, ...args, '-o', rsltDir], log, log)
 
         if(!isDone(rsltDir) && isPairedEnd) {
             await rmList([rsltDir])
             console.log('Trying meta')
-            await async_exec(spadesPath, ['-t', threads, '--meta', correction, ...args, '-o', rsltDir], console.log, console.log)
+            await async_exec(spadesPath, ['-t', threads, '--meta', correction, ...args, '-o', rsltDir], log, log)
             if(!isDone(rsltDir)) {
                 await rmList([rsltDir, ...tmpSubReads])
                 reject('No convergence')