diff --git a/src/nf_modules/Bowtie2/bowtie2.nf b/src/nf_modules/Bowtie2/bowtie2.nf index d35c3442596cdc3e92faf55a121fb359e0cb8560..efee164247fb6fcfd9a983d8b70e84db6f271353 100644 --- a/src/nf_modules/Bowtie2/bowtie2.nf +++ b/src/nf_modules/Bowtie2/bowtie2.nf @@ -101,6 +101,7 @@ log.info "index files : ${params.index}" Channel .fromPath( params.fastq ) .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } + .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} .set { fastq_files } Channel .fromPath( params.index ) @@ -108,16 +109,16 @@ Channel .set { index_files } process mapping_fastq { - tag "$reads.baseName" + tag "$file_id" cpus 4 publishDir "results/mapping/bams/", mode: 'copy' input: - file reads from fastq_files + set file_id, file(reads) from fastq_files file index from index_files.collect() output: - file "*.bam" into bam_files + set file_id, "*.bam" into bam_files file "*_report.txt" into mapping_report script: @@ -130,10 +131,10 @@ 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 +${file_id}_bowtie2_report.txt | \ +samtools view -Sb - > ${file_id}.bam -if grep -q "Error" ${reads.baseName}_bowtie2_report.txt; then +if grep -q "Error" ${file_id}_bowtie2_report.txt; then exit 1 fi """ diff --git a/src/nf_modules/Bowtie2/tests/mapping_single.nf b/src/nf_modules/Bowtie2/tests/mapping_single.nf index 5f6a9de9d88eba6151af957fc07433129b9ae196..66676991aae710a5263d763dee2ad7dbde6b7a51 100644 --- a/src/nf_modules/Bowtie2/tests/mapping_single.nf +++ b/src/nf_modules/Bowtie2/tests/mapping_single.nf @@ -6,6 +6,7 @@ log.info "index files : ${params.index}" Channel .fromPath( params.fastq ) .ifEmpty { error "Cannot find any fastq files matching: ${params.fastq}" } + .map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]} .set { fastq_files } Channel .fromPath( params.index ) @@ -13,16 +14,16 @@ Channel .set { index_files } process mapping_fastq { - tag "$reads.baseName" + tag "$file_id" cpus 4 publishDir "results/mapping/bams/", mode: 'copy' input: - file reads from fastq_files + set file_id, file(reads) from fastq_files file index from index_files.collect() output: - file "*.bam" into bam_files + set file_id, "*.bam" into bam_files file "*_report.txt" into mapping_report script: @@ -35,10 +36,10 @@ 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 +${file_id}_bowtie2_report.txt | \ +samtools view -Sb - > ${file_id}.bam -if grep -q "Error" ${reads.baseName}_bowtie2_report.txt; then +if grep -q "Error" ${file_id}_bowtie2_report.txt; then exit 1 fi """