From 0d885dcd6b9a46cbbfdc7d628502e7b16bbc0fe8 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Thu, 18 Feb 2021 09:48:57 +0100
Subject: [PATCH] macs3: add main.nf

---
 src/nf_modules/macs3/main.nf | 69 ++++++++++++++++++++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 src/nf_modules/macs3/main.nf

diff --git a/src/nf_modules/macs3/main.nf b/src/nf_modules/macs3/main.nf
new file mode 100644
index 00000000..b5b14056
--- /dev/null
+++ b/src/nf_modules/macs3/main.nf
@@ -0,0 +1,69 @@
+version = "3.0.0a6"
+container_url = "lbmc/macs3:${version}"
+
+process peak_calling {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "${file_id}"
+
+  input:
+    tuple val(file_id), path(bam_ip), path(bam_control)
+
+  output:
+    path "*", emit: peak
+    path "*_report.txt", emit: report
+
+  script:
+/* remove --nomodel option for real dataset */
+"""
+macs2 callpeak \
+  --treatment ${file_ip} \
+  --call-summits "True"\
+  --control ${file_control} \
+  --keep-dup "auto" \
+  --name ${bam_ip.simpleName} \
+  --gsize ${macs3_genome_size} 2> \
+  ${bam_ip.simpleName}_macs3_report.txt
+
+if grep -q "ERROR" ${bam_ip.simpleName}_macs3_report.txt; then
+  echo "MACS3 error"
+  exit 1
+fi
+"""
+}
+
+process peak_calling_bg {
+  container = "${container_url}"
+  label "big_mem_multi_cpus"
+  tag "${file_id}"
+
+  input:
+    tuple val(file_id), path(bg_ip), path(bg_control)
+
+  output:
+    path "*", emit: peak
+    path "*_report.txt", emit: report
+
+  script:
+/* remove --nomodel option for real dataset */
+"""
+awk '{print $1"\t"$2"\t"$3"\t.\t+\t"$4}' ${file_ip} > \
+  ${file_ip.simpleName}.bed
+awk '{print $1"\t"$2"\t"$3"\t.\t+\t"$4}' ${file_control} > \
+  ${file_control.simpleName}.bed
+macs2 callpeak \
+  --treatment ${file_ip.simpleName}.bed \
+  --call-summits "True"\
+  --control ${file_control.simpleName}.bed \
+  --keep-dup "auto" \
+  --name ${bam_ip.simpleName} \
+  --gsize ${macs3_genome_size} 2> \
+  ${bam_ip.simpleName}_macs3_report.txt
+
+if grep -q "ERROR" ${bam_ip.simpleName}_macs3_report.txt; then
+  echo "MACS3 error"
+  exit 1
+fi
+"""
+}
+
-- 
GitLab