From ff5c7a24d9815c4a304407ee541f72ee27cb01ec Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Wed, 17 Feb 2021 10:00:03 +0100
Subject: [PATCH] samtools: add process to merge multiple bam

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

diff --git a/src/nf_modules/samtools/main.nf b/src/nf_modules/samtools/main.nf
index 20db864f..7af44dda 100644
--- a/src/nf_modules/samtools/main.nf
+++ b/src/nf_modules/samtools/main.nf
@@ -165,6 +165,24 @@ samtools merge ${first_bam} ${second_bam} \
 """
 }
 
+process merge_multi_bam {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "$file_id"
+  cpus = 2
+
+  input:
+    tuple val(file_id), path(bams)
+
+  output:
+    tuple val(file_id), path("*.bam*"), emit: bam
+  script:
+"""
+samtools merge ${bams} \
+  ${file_id}.bam
+"""
+}
+
 process stats_bam {
   container = "${container_url}"
   label "big_mem_multi_cpus"
-- 
GitLab