Thomas 4 vuotta sitten
vanhempi
commit
60eecaa42d
2 muutettua tiedostoa jossa 48 lisäystä ja 20 poistoa
  1. 23 9
      index.js
  2. 25 11
      index.ts

+ 23 - 9
index.js

@@ -67,7 +67,7 @@ const denovoAssemblage = (reads, rnames, spadesPath, log) => {
             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[isfq.length] ? '.fq' : '.fa'));
+            const tmp = path_1.default.join(os_1.default.tmpdir(), (+new Date) + '_' + parsedPath.name + (isfq[isfq.length - 1] ? '.fq' : '.fa'));
             tmpSubReads.push(tmp);
             yield async_exec(greper, [rnamesSel, R, '-A3', '--no-group-separator', '>', tmp], log, log);
         }
@@ -98,13 +98,27 @@ exports.denovoAssemblage = denovoAssemblage;
 /*
 (async()=>{
     const spadesPath = '/home/thomas/NGS/tools/SPAdes-3.15.0-Linux/bin/spades.py'
-    const reads2 = '/home/thomas/Documents/Programmes/ttest/71-mer.fa'
-    const rnames = ['33530080_3',   '30971394_3',   '77190111_3',   '89825138_3',
-      '22481866_3',   '111937620_4',  '24308941_6',   '27758147_3',
-      '87242990_14',  '41688638_4',   '114699822_3',  '48573844_4',
-      '91080996_3',   '99644261_3',   '77207124_3',   '28986564_10',
-      '84400117_4',   '10884880_6',   '116082011_12', '1739367_3',
-      '13550404_3',   '68446023_10',  '50560660_3',   '9046992_3']
-    console.log(await denovoAssemblage(reads2, rnames, spadesPath));
+    const reads2 = ['/home/thomas/Documents/Programmes/ttest/R1r.fq', '/home/thomas/Documents/Programmes/ttest/R2r.fq']
+    const rnames = [
+        'A00680:166:HYCYGDMXX:1:1356:7663:10723',
+        'A00680:166:HYCYGDMXX:1:2475:28284:20384',
+        'A00680:166:HYCYGDMXX:1:1274:10646:6339',
+        'A00680:166:HYCYGDMXX:1:1314:10303:30921',
+        'A00680:166:HYCYGDMXX:1:1365:11966:21277',
+        'A00680:166:HYCYGDMXX:1:1425:21151:6778',
+        'A00680:166:HYCYGDMXX:1:2288:25301:5822',
+        'A00680:166:HYCYGDMXX:1:2312:24758:12587',
+        'A00680:166:HYCYGDMXX:1:2410:17110:13808',
+        'A00680:166:HYCYGDMXX:1:2410:17761:15468',
+        'A00680:166:HYCYGDMXX:1:2425:19777:2237',
+        'A00680:166:HYCYGDMXX:1:2429:13575:20149',
+        'A00680:166:HYCYGDMXX:2:1374:20971:34773',
+        'A00680:166:HYCYGDMXX:2:2350:16920:14293',
+        'A00680:166:HYCYGDMXX:1:2274:12707:16736',
+        'A00680:166:HYCYGDMXX:1:2274:12717:16720',
+        'A00680:166:HYCYGDMXX:2:1329:3839:27367',
+        'A00680:166:HYCYGDMXX:2:1330:1416:7827'
+    ]
+    console.log(await denovoAssemblage(reads2, rnames, spadesPath, console.log));
 })()
 */ 

+ 25 - 11
index.ts

@@ -59,16 +59,16 @@ const denovoAssemblage = (
         // Prepare the fastq files for spades inputs
         const rnamesSel = '\'' + rnames.join('\\|') + '\''
         const tmpSubReads: string[] = []
-        let isfq = []
+        let isfq: boolean[] = []
     
         for (const R of readsIn) {
             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[isfq.length] ? '.fq' : '.fa'))
+            
+            const tmp = path.join(os.tmpdir(), (+new Date)  + '_' + parsedPath.name + (isfq[isfq.length-1] ? '.fq' : '.fa'))
             tmpSubReads.push(tmp)
             await 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' : ''
@@ -101,13 +101,27 @@ export { denovoAssemblage }
 /*
 (async()=>{
     const spadesPath = '/home/thomas/NGS/tools/SPAdes-3.15.0-Linux/bin/spades.py'
-    const reads2 = '/home/thomas/Documents/Programmes/ttest/71-mer.fa' 
-    const rnames = ['33530080_3',   '30971394_3',   '77190111_3',   '89825138_3',
-      '22481866_3',   '111937620_4',  '24308941_6',   '27758147_3',
-      '87242990_14',  '41688638_4',   '114699822_3',  '48573844_4',
-      '91080996_3',   '99644261_3',   '77207124_3',   '28986564_10',
-      '84400117_4',   '10884880_6',   '116082011_12', '1739367_3',
-      '13550404_3',   '68446023_10',  '50560660_3',   '9046992_3']
-    console.log(await denovoAssemblage(reads2, rnames, spadesPath));
+    const reads2 = ['/home/thomas/Documents/Programmes/ttest/R1r.fq', '/home/thomas/Documents/Programmes/ttest/R2r.fq']
+    const rnames = [
+        'A00680:166:HYCYGDMXX:1:1356:7663:10723',
+        'A00680:166:HYCYGDMXX:1:2475:28284:20384',
+        'A00680:166:HYCYGDMXX:1:1274:10646:6339',
+        'A00680:166:HYCYGDMXX:1:1314:10303:30921',
+        'A00680:166:HYCYGDMXX:1:1365:11966:21277',
+        'A00680:166:HYCYGDMXX:1:1425:21151:6778',
+        'A00680:166:HYCYGDMXX:1:2288:25301:5822',
+        'A00680:166:HYCYGDMXX:1:2312:24758:12587',
+        'A00680:166:HYCYGDMXX:1:2410:17110:13808',
+        'A00680:166:HYCYGDMXX:1:2410:17761:15468',
+        'A00680:166:HYCYGDMXX:1:2425:19777:2237',
+        'A00680:166:HYCYGDMXX:1:2429:13575:20149',
+        'A00680:166:HYCYGDMXX:2:1374:20971:34773',
+        'A00680:166:HYCYGDMXX:2:2350:16920:14293',
+        'A00680:166:HYCYGDMXX:1:2274:12707:16736',
+        'A00680:166:HYCYGDMXX:1:2274:12717:16720',
+        'A00680:166:HYCYGDMXX:2:1329:3839:27367',
+        'A00680:166:HYCYGDMXX:2:1330:1416:7827'
+    ]
+    console.log(await denovoAssemblage(reads2, rnames, spadesPath, console.log));
 })()
 */