Thomas %!s(int64=4) %!d(string=hai) anos
pai
achega
de1864ef13
Modificáronse 2 ficheiros con 19 adicións e 9 borrados
  1. 8 4
      index.js
  2. 11 5
      index.ts

+ 8 - 4
index.js

@@ -62,19 +62,23 @@ const denovoAssemblage = (reads, rnames, spadesPath) => {
         // Prepare the fastq files for spades inputs
         const rnamesSel = '\'' + rnames.join('\\|') + '\'';
         const tmpSubReads = [];
+        let isfq = [];
         for (const R of readsIn) {
-            const tmp = path_1.default.join(os_1.default.tmpdir(), (+new Date) + '_' + path_1.default.parse(R).base);
+            const parsedPath = path_1.default.parse(R);
+            const greper = parsedPath.ext === '.gz' ? 'zgrep' : 'grep';
+            isfq.push(R.match(/\.fq/) ? true : false);
+            const tmp = path_1.default.join(os_1.default.tmpdir(), (+new Date) + '_' + parsedPath.name + (isfq ? '.fq' : '.fa'));
             tmpSubReads.push(tmp);
-            const greper = R.match(/gz$/) ? 'zgrep' : 'grep';
             yield async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], console.log, console.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', ...args, '-o', rsltDir], console.log, console.log);
+        yield async_exec(spadesPath, ['-t', threads, '--isolate', correction, ...args, '-o', rsltDir], console.log, console.log);
         if (!isDone(rsltDir)) {
             yield rmList([rsltDir]);
             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', correction, ...args, '-o', rsltDir], console.log, console.log);
             if (!isDone(rsltDir)) {
                 yield rmList([rsltDir, ...tmpSubReads]);
                 reject('No convergence');

+ 11 - 5
index.ts

@@ -58,23 +58,29 @@ const denovoAssemblage = (
         // Prepare the fastq files for spades inputs
         const rnamesSel = '\'' + rnames.join('\\|') + '\''
         const tmpSubReads: string[] = []
+        let isfq = []
+    
         for (const R of readsIn) {
-            const tmp = path.join(os.tmpdir(), (+new Date)  + '_' + path.parse(R).base)
+            const parsedPath = path.parse(R)
+            const greper = parsedPath.ext === '.gz' ? 'zgrep' : 'grep'
+            isfq.push(R.match(/\.fq/) ? true : false)
+            const tmp = path.join(os.tmpdir(), (+new Date)  + '_' + parsedPath.name + (isfq ? '.fq' : '.fa'))
             tmpSubReads.push(tmp)
-            const greper = R.match(/gz$/) ? 'zgrep' : 'grep'
             await async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], console.log, console.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.join(os.tmpdir(), (+new Date)  + '_spades')
         
-        await async_exec(spadesPath, ['-t', threads, '--isolate', ...args, '-o', rsltDir], console.log, console.log)
+        await async_exec(spadesPath, ['-t', threads, '--isolate', correction, ...args, '-o', rsltDir], console.log, console.log)
 
         if(!isDone(rsltDir)) {
             await rmList([rsltDir])
             console.log('Trying meta')
-            await async_exec(spadesPath, ['-t', threads, '--meta', ...args, '-o', rsltDir], console.log, console.log)
-            
+            await async_exec(spadesPath, ['-t', threads, '--meta', correction, ...args, '-o', rsltDir], console.log, console.log)
             if(!isDone(rsltDir)) {
                 await rmList([rsltDir, ...tmpSubReads])
                 reject('No convergence')