From cc81bec20845cf79e4fbe53d70e1e4a8e7bcd109 Mon Sep 17 00:00:00 2001
From: Laurent Modolo <laurent.modolo@ens-lyon.fr>
Date: Tue, 31 Jul 2018 10:53:23 +0200
Subject: [PATCH] Bowtie: fix single mapping and index parsing

---
 src/nf_modules/Bowtie/bowtie.nf               | 3 +++
 src/nf_modules/Bowtie/tests/index.nf          | 1 +
 src/nf_modules/Bowtie/tests/mapping_paired.nf | 3 ++-
 src/nf_modules/Bowtie/tests/mapping_single.nf | 5 +++--
 src/nf_modules/Bowtie2/bowtie2.nf             | 1 +
 src/nf_modules/Bowtie2/tests/index.nf         | 1 +
 6 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/nf_modules/Bowtie/bowtie.nf b/src/nf_modules/Bowtie/bowtie.nf
index 21e3295..54d10da 100644
--- a/src/nf_modules/Bowtie/bowtie.nf
+++ b/src/nf_modules/Bowtie/bowtie.nf
@@ -25,6 +25,7 @@ process index_fasta {
 
   output:
     file "*.index*" into index_files
+    file "*_report.txt" into indexing_report
 
   script:
 """
@@ -68,6 +69,7 @@ process mapping_fastq {
 
   output:
   file "*.bam" into bam_files
+  file "*_report.txt" into mapping_report
 
   script:
   index_id = index[0]
@@ -119,6 +121,7 @@ process mapping_fastq {
 
   output:
   file "*.bam" into bam_files
+  file "*_report.txt" into mapping_report
 
   script:
 index_id = index[0]
diff --git a/src/nf_modules/Bowtie/tests/index.nf b/src/nf_modules/Bowtie/tests/index.nf
index 0b3ca58..f9ee2eb 100644
--- a/src/nf_modules/Bowtie/tests/index.nf
+++ b/src/nf_modules/Bowtie/tests/index.nf
@@ -17,6 +17,7 @@ process index_fasta {
 
   output:
     file "*.index*" into index_files
+    file "*_report.txt" into indexing_report
 
   script:
 """
diff --git a/src/nf_modules/Bowtie/tests/mapping_paired.nf b/src/nf_modules/Bowtie/tests/mapping_paired.nf
index fdf9aee..6ea2d70 100644
--- a/src/nf_modules/Bowtie/tests/mapping_paired.nf
+++ b/src/nf_modules/Bowtie/tests/mapping_paired.nf
@@ -24,11 +24,12 @@ process mapping_fastq {
 
   output:
   file "*.bam" into bam_files
+  file "*_report.txt" into mapping_report
 
   script:
   index_id = index[0]
   for (index_file in index) {
-    if (index_file =~ /.*\.1\.ebwt/) {
+  if (index_file =~ /.*\.1\.ebwt/ && !(index_file =~ /.*\.rev\.1\.ebwt/)) {
         index_id = ( index_file =~ /(.*)\.1\.ebwt/)[0][1]
     }
   }
diff --git a/src/nf_modules/Bowtie/tests/mapping_single.nf b/src/nf_modules/Bowtie/tests/mapping_single.nf
index e878126..551b90c 100644
--- a/src/nf_modules/Bowtie/tests/mapping_single.nf
+++ b/src/nf_modules/Bowtie/tests/mapping_single.nf
@@ -23,17 +23,18 @@ process mapping_fastq {
 
   output:
   file "*.bam" into bam_files
+  file "*_report.txt" into mapping_report
 
   script:
 index_id = index[0]
 for (index_file in index) {
-  if (index_file =~ /.*\.1\.ebwt/) {
+  if (index_file =~ /.*\.1\.ebwt/ && !(index_file =~ /.*\.rev\.1\.ebwt/)) {
       index_id = ( index_file =~ /(.*)\.1\.ebwt/)[0][1]
   }
 }
 """
 bowtie --best -v 3 -k 1 --sam -p ${task.cpus} ${index_id} \
--U ${reads} 2> \
+-q ${reads} 2> \
 ${reads.baseName}_bowtie_report.txt | \
 samtools view -Sb - > ${reads.baseName}.bam
 
diff --git a/src/nf_modules/Bowtie2/bowtie2.nf b/src/nf_modules/Bowtie2/bowtie2.nf
index 8ec01cc..3a51b5c 100644
--- a/src/nf_modules/Bowtie2/bowtie2.nf
+++ b/src/nf_modules/Bowtie2/bowtie2.nf
@@ -25,6 +25,7 @@ process index_fasta {
 
   output:
     file "*.index*" into index_files
+    file "*_report.txt" into indexing_report
 
   script:
 """
diff --git a/src/nf_modules/Bowtie2/tests/index.nf b/src/nf_modules/Bowtie2/tests/index.nf
index 2636f4b..4f3cde5 100644
--- a/src/nf_modules/Bowtie2/tests/index.nf
+++ b/src/nf_modules/Bowtie2/tests/index.nf
@@ -17,6 +17,7 @@ process index_fasta {
 
   output:
     file "*.index*" into index_files
+    file "*_report.txt" into indexing_report
 
   script:
 """
-- 
GitLab