From 654fe7ec5b18c0042c668e8f85aba86f396d248d Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent.modolo@ens-lyon.fr> Date: Thu, 26 Jul 2018 16:08:03 +0200 Subject: [PATCH] Bowtie2: fix bug on nf files --- src/nf_modules/Bowtie2/bowtie2.nf | 28 ++++++++++++------- .../Bowtie2/tests/mapping_paired.nf | 1 + .../Bowtie2/tests/mapping_single.nf | 1 + 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/nf_modules/Bowtie2/bowtie2.nf b/src/nf_modules/Bowtie2/bowtie2.nf index e5cd169..9b4203b 100644 --- a/src/nf_modules/Bowtie2/bowtie2.nf +++ b/src/nf_modules/Bowtie2/bowtie2.nf @@ -57,16 +57,17 @@ Channel .set { index_files } process mapping_fastq { - tag "$reads.baseName" + tag "$pair_id" cpus 4 publishDir "results/mapping/bams/", mode: 'copy' input: - file reads from fastq_files + set pair_id, file(reads) from fastq_files file index from index_files.toList() output: - file "*.bam" into bam_files + set pair_id, "*.bam" into bam_files + file "*_report.txt" into mapping_report script: index_id = index[0] @@ -76,12 +77,12 @@ process mapping_fastq { } } """ -bowtie2 --very_sensitive -p ${task.cpus} -x ${index_id} \ --U ${reads} 2> \ -${reads.baseName}_bowtie2_report.txt | \ -samtools view -Sb - > ${reads.baseName}.bam +bowtie2 --very-sensitive -p ${task.cpus} -x ${index_id} \ +-1 ${reads[0]} -2 ${reads[1]} 2> \ +${pair_id}_bowtie2_report.txt | \ +samtools view -Sb - > ${pair_id}.bam -if grep -q "Error" ${reads.baseName}_bowtie2_report.txt; then +if grep -q "Error" ${pair_id}_bowtie2_report.txt; then exit 1 fi """ @@ -116,15 +117,22 @@ 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\.bt2/) { + index_id = ( index_file =~ /(.*)\.1\.bt2/)[0][1] + } + } """ -bowtie2 --very_sensitive -p ${task.cpus} -x ${index[0].baseName} \ +bowtie2 --very_sensitive -p ${task.cpus} -x ${index_id} \ -U ${reads} 2> \ ${reads.baseName}_bowtie2_report.txt | \ samtools view -Sb - > ${reads.baseName}.bam -if grep -q "Error" ${fasta.baseName}_bowtie2_report.txt; then +if grep -q "Error" ${reads.baseName}_bowtie2_report.txt; then exit 1 fi """ diff --git a/src/nf_modules/Bowtie2/tests/mapping_paired.nf b/src/nf_modules/Bowtie2/tests/mapping_paired.nf index 0a16565..d102ebb 100644 --- a/src/nf_modules/Bowtie2/tests/mapping_paired.nf +++ b/src/nf_modules/Bowtie2/tests/mapping_paired.nf @@ -24,6 +24,7 @@ process mapping_fastq { output: set pair_id, "*.bam" into bam_files + file "*_report.txt" into mapping_report script: index_id = index[0] diff --git a/src/nf_modules/Bowtie2/tests/mapping_single.nf b/src/nf_modules/Bowtie2/tests/mapping_single.nf index 201c32c..b96b108 100644 --- a/src/nf_modules/Bowtie2/tests/mapping_single.nf +++ b/src/nf_modules/Bowtie2/tests/mapping_single.nf @@ -23,6 +23,7 @@ process mapping_fastq { output: file "*.bam" into bam_files + file "*_report.txt" into mapping_report script: index_id = index[0] -- GitLab