From 76661338cf8257793c6b87e638ca8107cf0de3b7 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Fri, 20 Aug 2021 15:36:56 +0200
Subject: [PATCH] emase-zero: redirect stdrr to report file

---
 src/nf_modules/emase-zero/main.nf | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/nf_modules/emase-zero/main.nf b/src/nf_modules/emase-zero/main.nf
index 6c8282ab..58cb0788 100644
--- a/src/nf_modules/emase-zero/main.nf
+++ b/src/nf_modules/emase-zero/main.nf
@@ -29,7 +29,7 @@ process emase {
   label "big_mem_mono_cpus"
   tag "$file_id"
   if (params.count_out != "") {
-    publishDir "results/${params.count_out}", mode: 'copy'
+    publishDir "results/counts/${params.count_out}", mode: 'copy'
   }
 
   input:
@@ -39,7 +39,8 @@ process emase {
     tuple val(gene_to_transcript_id), path(gene_to_transcript)
 
   output:
-    tuple val(file_id), path("${bin.simpleName}.quantified"), emit: count
+    tuple val(file_id), path("${bin.simpleName}.quantified*"), emit: count
+    path "*_report.txt", emit: report
 
   script:
 """
@@ -49,6 +50,11 @@ emase-zero ${params.count} \
   -o ${bin.simpleName}.quantified \
   -l ${transcript_length} \
   -g gene_to_transcript.txt \
-  ${bin}
+  ${bin} 2> ${file_prefix}_emase-zero_repport.txt
+
+if grep -q "ERROR" ${file_prefix}_emase-zero_repport.txt; then
+  exit 1
+fi
+
 """
 }
\ No newline at end of file
-- 
GitLab