From d5cf091f1a6b542413f6b9f5926c394142db84f4 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Mon, 28 Feb 2022 14:59:20 +0100
Subject: [PATCH] src/nf_modules/hisat2/main.nf

---
 .../hisat2/2.2.1/docker_init.sh               |  4 +--
 src/nf_modules/hisat2/main.nf                 | 27 +++++++++++--------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/src/.docker_modules/hisat2/2.2.1/docker_init.sh b/src/.docker_modules/hisat2/2.2.1/docker_init.sh
index 11a1df82..adeffb7e 100755
--- a/src/.docker_modules/hisat2/2.2.1/docker_init.sh
+++ b/src/.docker_modules/hisat2/2.2.1/docker_init.sh
@@ -1,5 +1,5 @@
 #!/bin/sh
 docker pull lbmc/hisat2:2.2.1
-# docker build src/.docker_modules/hisat2/2.1.1 -t 'lbmc/hisat2:2.2.1'
-# docker push lbmc/hisat2:2.2.1
+docker build src/.docker_modules/hisat2/2.2.1 -t 'lbmc/hisat2:2.2.1'
+docker push lbmc/hisat2:2.2.1
 docker buildx build --platform linux/amd64,linux/arm64 -t "lbmc/hisat2:2.2.1" --push src/.docker_modules/hisat2/2.2.1
diff --git a/src/nf_modules/hisat2/main.nf b/src/nf_modules/hisat2/main.nf
index 96c53239..34492a11 100644
--- a/src/nf_modules/hisat2/main.nf
+++ b/src/nf_modules/hisat2/main.nf
@@ -1,5 +1,5 @@
 version = "2.2.1"
-container_url = "lbmc/histat2:${version}"
+container_url = "lbmc/hisat2:${version}"
 
 params.index_fasta = ""
 params.index_fasta_out = ""
@@ -20,12 +20,13 @@ process index_fasta {
 
   script:
 """
+gunzip ${fasta}
 hisat2-build -p ${task.cpus} \
-  ${fasta} \
+  ${fasta.baseName} \
   ${fasta.simpleName} &> \
   ${fasta.simpleName}_hisat2_index_report.txt
 
-if grep -q "Error" ${fasta.simpleName}_bowtie2_index_report.txt; then
+if grep -q "Error" ${fasta.simpleName}_hisat2_index_report.txt; then
   exit 1
 fi
 """
@@ -70,30 +71,34 @@ process mapping_fastq {
 
   if (reads.size() == 2)
   """
-  histat2 ${params.mapping_fastq} \
+  hisat2 ${params.mapping_fastq} \
     -p ${task.cpus} \
     -x ${index_id} \
     -1 ${reads[0]} \
     -2 ${reads[1]} 2> \
     ${file_prefix}_ht2_mapping_report_tmp.txt \
-    | samtools view -@ ${task.cpus} -bS - \
-    | samtools sort -@ ${task.cpus} -o ${file_prefix}.bam -
+    | samtools view -@ ${task.cpus} -bS - 2>> \
+    ${file_prefix}_ht2_mapping_report_tmp.txt \
+    | samtools sort -@ ${task.cpus} -o ${file_prefix}.bam - 2>> \
+    ${file_prefix}_ht2_mapping_report.txt
 
-  if grep -q "Error" ${file_prefix}_ht2_mapping_report_tmp.txt; then
+  if grep -q "Error" ${file_prefix}_ht2_mapping_report.txt; then
     exit 1
   fi
   """
   else
   """
-  histat2 ${params.mapping_fastq} \
+  hisat2 ${params.mapping_fastq} \
     -p ${task.cpus} \
     -x ${index_id} \
     -U ${reads} 2> \
     ${file_prefix}_ht2_mapping_report_tmp.txt \
-    | samtools view -@ ${task.cpus} -bS - \
-    | samtools sort -@ ${task.cpus} -o ${file_prefix}.bam -
+    | samtools view -@ ${task.cpus} -bS - 2>> \
+    ${file_prefix}_ht2_mapping_report.txt \
+    | samtools sort -@ ${task.cpus} -o ${file_prefix}.bam - 2>> \
+    ${file_prefix}_ht2_mapping_report.txt
 
-  if grep -q "Error" ${file_prefix}_ht2_mapping_report_tmp.txt; then
+  if grep -q "Error" ${file_prefix}_ht2_mapping_report.txt; then
     exit 1
   fi
   """
-- 
GitLab