From 1814df72ddef067b4b7441246b012307b56d848f Mon Sep 17 00:00:00 2001
From: vvanoost <vincent.vanoosthuyse@ens-lyon.fr>
Date: Thu, 2 Aug 2018 11:04:15 +0200
Subject: [PATCH] add filtering step of reads based on mapping quality >=2

---
 src/RNAseq_sen1D_bowtie2_SE.nf | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/RNAseq_sen1D_bowtie2_SE.nf b/src/RNAseq_sen1D_bowtie2_SE.nf
index 70accab..76645ff 100644
--- a/src/RNAseq_sen1D_bowtie2_SE.nf
+++ b/src/RNAseq_sen1D_bowtie2_SE.nf
@@ -230,6 +230,25 @@ fi
 """
 }
 
+/*
+* filtering mapping quality >= 2
+*/
+
+process quality_filtered_bam {
+  tag "$bam.baseName"
+  cpus 2
+
+  input:
+    file bam from bam_files
+
+  output:
+    file "*_filtered.bam*" into filtered_bam_files
+  script:
+"""
+samtools view -hb -q 2 ${bam} > ${bam}_filtered.bam
+"""
+}
+
 /*                      MultiQC                                     */
 
 process multiqc {
@@ -258,7 +277,7 @@ process sort_bam {
   cpus 4
   publishDir "results/mapping_SE/bams/", mode: 'copy'
   input:
-    file bam from bam_files
+    file bam from filtered_bam_files
 
   output:
     file "*_sorted.bam" into sorted_bam_files
-- 
GitLab