Thomas преди 4 години
родител
ревизия
8dd1e1627c
променени са 2 файла, в които са добавени 27 реда и са изтрити 12 реда
  1. 13 6
      index.js
  2. 14 6
      index.ts

+ 13 - 6
index.js

@@ -25,7 +25,7 @@ const async_exec = (prog, args, onData, onErr) => {
         child.on('exit', code => resolve(code));
     });
 };
-const clusterSam = (input_sam, threshold, minReads) => {
+const clusterSam = (input_sam, threshold, minReads, blackList) => {
     return new Promise((resolve, _reject) => __awaiter(void 0, void 0, void 0, function* () {
         let inputSam = Array.isArray(input_sam) ? input_sam.join(' ') : input_sam;
         let lineAcc = '';
@@ -59,11 +59,17 @@ const clusterSam = (input_sam, threshold, minReads) => {
                             break;
                     }
                 });
-                if (Array.isArray(byContigs[tmpName])) {
-                    byContigs[tmpName].push(tmpPos);
+                let add = true;
+                if (blackList) {
+                    add = blackList.includes(tmpName) ? false : true;
                 }
-                else {
-                    byContigs[tmpName] = [tmpPos];
+                if (add) {
+                    if (Array.isArray(byContigs[tmpName])) {
+                        byContigs[tmpName].push(tmpPos);
+                    }
+                    else {
+                        byContigs[tmpName] = [tmpPos];
+                    }
                 }
             });
         }, console.log);
@@ -111,6 +117,7 @@ const clusterSam = (input_sam, threshold, minReads) => {
 exports.clusterSam = clusterSam;
 /*
 (async () => {
-    console.log(await clusterSam('/home/thomas/Documents/Programmes/ttest/bwa_mem_splitters_on_HG38_Viral.sam', 333, 55));
+    console.log(await clusterSam('/home/thomas/Documents/Programmes/ttest/bwa_mem_splitters_on_HG38_Viral.sam', 333, 55,
+    ['NR_145819.1', 'NR_145822.1']));
 })()
 */ 

+ 14 - 6
index.ts

@@ -20,7 +20,8 @@ const async_exec = (prog: string, args: string[], onData: Function, onErr: Funct
 const clusterSam = (
     input_sam: string | Array<string>,
     threshold: number,
-    minReads : number
+    minReads : number,
+    blackList ?: string[]
 ) => {
     return new Promise<any>( async (resolve, _reject) => {
         let inputSam: string = Array.isArray(input_sam) ? input_sam.join(' ') : input_sam
@@ -65,10 +66,16 @@ const clusterSam = (
                                 break;
                         }
                     })
-                    if (Array.isArray(byContigs[tmpName])) {
-                        byContigs[tmpName].push(tmpPos)
-                    } else {
-                        byContigs[tmpName] = [tmpPos]
+                    let add = true
+                    if (blackList) {
+                        add = blackList.includes(tmpName) ? false : true
+                    }
+                    if(add) {
+                        if (Array.isArray(byContigs[tmpName])) {
+                            byContigs[tmpName].push(tmpPos)
+                        } else {
+                            byContigs[tmpName] = [tmpPos]
+                        }
                     }
                 })
             }, console.log)
@@ -132,6 +139,7 @@ export { clusterSam }
 
 /*
 (async () => {
-    console.log(await clusterSam('/home/thomas/Documents/Programmes/ttest/bwa_mem_splitters_on_HG38_Viral.sam', 333, 55));
+    console.log(await clusterSam('/home/thomas/Documents/Programmes/ttest/bwa_mem_splitters_on_HG38_Viral.sam', 333, 55, 
+    ['NR_145819.1', 'NR_145822.1']));
 })()
 */