diff --git a/main.nf b/main.nf index 41aa6bb..6f753b6 100755 --- a/main.nf +++ b/main.nf @@ -78,25 +78,25 @@ workflow { // alignment if (params.algorithm == "aln" && !params.inception) { - BWA_ALN(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq1)}) - BWA_ALN_2(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq2)}) - BWA_SAMPE(BWA_ALN.out.alignment_output.join(BWA_ALN_2.out.alignment_output)) + BWA_ALN(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq1)},params.reference) + BWA_ALN_2(trimmed_fastqs.map {name, fq1, fq2 -> tuple(name, fq2)},params.reference) + BWA_SAMPE(BWA_ALN.out.alignment_output.join(BWA_ALN_2.out.alignment_output),params.reference) output_bams = BWA_SAMPE.out.bams } else if (params.algorithm == "aln" && params.inception) { - BWA_ALN_INCEPTION(trimmed_fastqs) + BWA_ALN_INCEPTION(trimmed_fastqs,params.reference) output_bams = BWA_ALN_INCEPTION.out.bams } else if (params.algorithm == "mem") { - BWA_MEM(trimmed_fastqs) + BWA_MEM(trimmed_fastqs,params.reference) output_bams = BWA_MEM.out.bams } else if (params.algorithm == "mem2") { - BWA_MEM_2(trimmed_fastqs) + BWA_MEM_2(trimmed_fastqs,params.reference) output_bams = BWA_MEM_2.out.bams } else if (params.algorithm == "star") { - STAR(trimmed_fastqs) + STAR(trimmed_fastqs,params.reference) output_bams = STAR.out.bams } else { @@ -112,20 +112,20 @@ workflow { trimmed_fastqs = FASTP_SINGLE.out.trimmed_fastqs } if (params.algorithm == "aln" && !params.inception) { - BWA_ALN(trimmed_fastqs) - BWA_SAMSE(BWA_ALN.out.alignment_output) + BWA_ALN(trimmed_fastqs,params.reference) + BWA_SAMSE(BWA_ALN.out.alignment_output,params.reference) output_bams = BWA_SAMSE.out.bams } else if (params.algorithm == "mem") { - BWA_MEM_SE(trimmed_fastqs) + BWA_MEM_SE(trimmed_fastqs,params.reference) output_bams = BWA_MEM_SE.out.bams } else if (params.algorithm == "mem2") { - BWA_MEM_2_SE(trimmed_fastqs) + BWA_MEM_2_SE(trimmed_fastqs,params.reference) output_bams = BWA_MEM_2_SE.out.bams } else if (params.algorithm == "star") { - STAR_SE(trimmed_fastqs) + STAR_SE(trimmed_fastqs,params.reference) output_bams = STAR_SE.out.bams } else { diff --git a/modules/01_fastp.nf b/modules/01_fastp.nf index 7638f8c..a972813 100644 --- a/modules/01_fastp.nf +++ b/modules/01_fastp.nf @@ -16,7 +16,7 @@ process FASTP_PAIRED { file("${fastq2.baseName}.trimmed.fq.gz"), emit: trimmed_fastqs file("${name}.fastp_stats.json") file("${name}.fastp_stats.html") - file("software_versions.${task.process}.txt") + file("software_versions.FASTP_PAIRED.txt") """ # --input_files needs to be forced, otherwise it is inherited from profile in tests @@ -29,8 +29,8 @@ process FASTP_PAIRED { --html ${name}.fastp_stats.html \ --thread ${params.cpus} - echo ${params.manifest} >> software_versions.${task.process}.txt - fastp --version 2>> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.FASTP_PAIRED.txt + fastp --version 2>> software_versions.FASTP_PAIRED.txt """ } @@ -50,7 +50,7 @@ process FASTP_SINGLE { tuple val(name), file("${fastq1.baseName}.trimmed.fq.gz"), emit: trimmed_fastqs file("${name}.fastp_stats.json") file("${name}.fastp_stats.html") - file("software_versions.${task.process}.txt") + file("software_versions.FASTP_SINGLE.txt") """ # --input_files needs to be forced, otherwise it is inherited from profile in tests @@ -61,7 +61,7 @@ process FASTP_SINGLE { --html ${name}.fastp_stats.html \ --thread ${params.cpus} - echo ${params.manifest} >> software_versions.${task.process}.txt - fastp --version 2>> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.FASTP_SINGLE.txt + fastp --version 2>> software_versions.FASTP_SINGLE.txt """ } \ No newline at end of file diff --git a/modules/02_bwa_aln.nf b/modules/02_bwa_aln.nf index 7f9b4ad..c7381d8 100644 --- a/modules/02_bwa_aln.nf +++ b/modules/02_bwa_aln.nf @@ -9,16 +9,17 @@ process BWA_ALN { input: tuple val(name), file(fastq) + val(reference) output: tuple val("${name}"), file("${fastq}"), file("${fastq.baseName}.sai"), emit: alignment_output - file("software_versions.${task.process}.txt") + file("software_versions.BWA_ALN.txt") """ - bwa aln -t ${task.cpus} ${params.reference} ${fastq} > ${fastq.baseName}.sai + bwa aln -t ${task.cpus} ${reference} ${fastq} > ${fastq.baseName}.sai - echo ${params.manifest} >> software_versions.${task.process}.txt - echo "bwa=0.7.17" >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_ALN.txt + echo "bwa=0.7.17" >> software_versions.BWA_ALN.txt """ } @@ -34,17 +35,18 @@ process BWA_SAMPE { input: // joins both channels by key using the first element in the tuple, the name tuple val(name), file(fastq1), file(sai1), file(fastq2), file(sai2) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_SAMPE.txt") """ - bwa sampe ${params.reference} ${sai1} ${sai2} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam + bwa sampe ${reference} ${sai1} ${sai2} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - echo "bwa=0.7.17" >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_SAMPE.txt + echo "bwa=0.7.17" >> software_versions.BWA_SAMPE.txt + samtools --version >> software_versions.BWA_SAMPE.txt """ } @@ -60,16 +62,17 @@ process BWA_SAMSE { input: // joins both channels by key using the first element in the tuple, the name tuple val(name), file(fastq), file(sai) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_SAMSE.txt") """ - bwa samse ${params.reference} ${sai} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam + bwa samse ${reference} ${sai} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - echo "bwa=0.7.17" >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_SAMSE.txt + echo "bwa=0.7.17" >> software_versions.BWA_SAMSE.txt """ } @@ -86,18 +89,19 @@ process BWA_ALN_INCEPTION { input: // joins both channels by key using the first element in the tuple, the name tuple val(name), file(fastq1), file(fastq2) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_ALN_INCEPTION.txt") """ - bwa sampe ${params.reference} <( bwa aln -t ${params.cpus} ${params.reference} ${fastq1} ) \ - <( bwa aln -t ${params.cpus} ${params.reference} ${fastq2} ) ${fastq1} ${fastq2} \ + bwa sampe ${reference} <( bwa aln -t ${params.cpus} ${reference} ${fastq1} ) \ + <( bwa aln -t ${params.cpus} ${reference} ${fastq2} ) ${fastq1} ${fastq2} \ | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - echo "bwa=0.7.17" >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_ALN_INCEPTION.txt + echo "bwa=0.7.17" >> software_versions.BWA_ALN_INCEPTION.txt + samtools --version >> software_versions.BWA_ALN_INCEPTION.txt """ } diff --git a/modules/02_bwa_mem.nf b/modules/02_bwa_mem.nf index 626a170..93bf7ce 100644 --- a/modules/02_bwa_mem.nf +++ b/modules/02_bwa_mem.nf @@ -10,17 +10,18 @@ process BWA_MEM { input: tuple val(name), file(fastq1), file(fastq2) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_MEM.txt") """ - bwa mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam + bwa mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - echo "bwa=0.7.17" >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_MEM.txt + echo "bwa=0.7.17" >> software_versions.BWA_MEM.txt + samtools --version >> software_versions.BWA_MEM.txt """ } @@ -36,16 +37,17 @@ process BWA_MEM_SE { input: // joins both channels by key using the first element in the tuple, the name tuple val(name), file(fastq) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_MEM_SE.txt") """ - bwa mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam + bwa mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - echo "bwa=0.7.17" >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_MEM_SE.txt + echo "bwa=0.7.17" >> software_versions.BWA_MEM_SE.txt + samtools --version >> software_versions.BWA_MEM_SE.txt """ } diff --git a/modules/02_bwa_mem_2.nf b/modules/02_bwa_mem_2.nf index 58ad725..03a5034 100755 --- a/modules/02_bwa_mem_2.nf +++ b/modules/02_bwa_mem_2.nf @@ -10,17 +10,18 @@ process BWA_MEM_2 { input: tuple val(name), file(fastq1), file(fastq2) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_MEM_2.txt") """ - bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam + bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq1} ${fastq2} | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - bwa-mem2 version >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_MEM_2.txt + bwa-mem2 version >> software_versions.BWA_MEM_2.txt + samtools --version >> software_versions.BWA_MEM_2.txt """ } @@ -36,16 +37,17 @@ process BWA_MEM_2_SE { input: // joins both channels by key using the first element in the tuple, the name tuple val(name), file(fastq) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.BWA_MEM_2_SE.txt") """ - bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${params.reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam + bwa-mem2 mem ${params.additional_args} -t ${task.cpus} ${reference} ${fastq} | samtools view -uS - | samtools sort - > ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - bwa-mem2 version >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.BWA_MEM_2_SE.txt + bwa-mem2 version >> software_versions.BWA_MEM_2_SE.txt + samtools --version >> software_versions.BWA_MEM_2_SE.txt """ } diff --git a/modules/02_star.nf b/modules/02_star.nf index 66c1b95..f06d9b1 100644 --- a/modules/02_star.nf +++ b/modules/02_star.nf @@ -10,15 +10,16 @@ process STAR { input: tuple val(name), file(fastq1), file(fastq2) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.STAR.txt") script: two_pass_mode_param = params.star_two_pass_mode ? "--twopassMode Basic" : "" """ - STAR --genomeDir ${params.reference} ${two_pass_mode_param} ${params.additional_args} \ + STAR --genomeDir ${reference} ${two_pass_mode_param} ${params.additional_args} \ --readFilesCommand "gzip -d -c -f" \ --readFilesIn ${fastq1} ${fastq2} \ --outSAMmode Full \ @@ -32,8 +33,8 @@ process STAR { mv ${name}.Aligned.sortedByCoord.out.bam ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - STAR --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.STAR.txt + STAR --version >> software_versions.STAR.txt """ } @@ -48,15 +49,16 @@ process STAR_SE { input: tuple val(name), file(fastq) + val(reference) output: tuple val("${name}"), file("${name}.bam"), emit: bams - file("software_versions.${task.process}.txt") + file("software_versions.STAR_SE.txt") script: two_pass_mode_param = params.star_two_pass_mode ? "--twopassMode Basic" : "" """ - STAR --genomeDir ${params.reference} ${two_pass_mode_param} ${params.additional_args} \ + STAR --genomeDir ${reference} ${two_pass_mode_param} ${params.additional_args} \ --readFilesCommand "gzip -d -c -f" \ --readFilesIn ${fastq} \ --outSAMmode Full \ @@ -70,7 +72,7 @@ process STAR_SE { mv ${name}.Aligned.sortedByCoord.out.bam ${name}.bam - echo ${params.manifest} >> software_versions.${task.process}.txt - STAR --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.STAR_SE.txt + STAR --version >> software_versions.STAR_SE.txt """ } diff --git a/modules/03_index.nf b/modules/03_index.nf index a6fbcdf..7162aef 100644 --- a/modules/03_index.nf +++ b/modules/03_index.nf @@ -13,12 +13,12 @@ process INDEX_BAM { output: file("${name}.bam.bai") - file("software_versions.${task.process}.txt") + file("software_versions.INDEX_BAM.txt") """ samtools index -@ ${task.cpus} ${bam} - echo ${params.manifest} >> software_versions.${task.process}.txt - samtools --version >> software_versions.${task.process}.txt + echo ${params.manifest} >> software_versions.INDEX_BAM.txt + samtools --version >> software_versions.INDEX_BAM.txt """ }