From e4d6d7ab5bd4d993b24807db8bfe8ae7a69891d0 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Thu, 7 Oct 2021 11:20:05 +0200
Subject: [PATCH] samtools: add rm_from_bam process

---
 src/nf_modules/samtools/main.nf | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/nf_modules/samtools/main.nf b/src/nf_modules/samtools/main.nf
index 3c940314..0d384315 100644
--- a/src/nf_modules/samtools/main.nf
+++ b/src/nf_modules/samtools/main.nf
@@ -74,6 +74,28 @@ samtools view -@ ${task.cpus} -hb ${bam} -L ${bed} ${params.filter_bam} > \
 """
 }
 
+params.rm_from_bam = ""
+params.rm_from_bam_out = ""
+process filter_bam {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$file_id"
+  if (params.rm_from_bam_out != "") {
+    publishDir "results/${params.rm_from_bam_out}", mode: 'copy'
+  }
+
+  input:
+    tuple val(file_id), path(bam)
+    tuple val(bed_id), path(bed)
+
+  output:
+    tuple val(file_id), path("*_filtered.bam"), emit: bam
+  script:
+"""
+samtools view -@ ${task.cpus} ${params.filter_bam} -hb -L ${bed} -U ${bam.simpleName}_filtered.bam ${bam} >  /dev/null
+"""
+}
+
 params.filter_bam_mapped = "-F 4"
 params.filter_bam_mapped_out = ""
 process filter_bam_mapped {
-- 
GitLab