From e2721f0180a9363ce8640323140be5571364ce2c Mon Sep 17 00:00:00 2001 From: maxulysse Date: Tue, 5 Nov 2024 11:52:02 +0100 Subject: [PATCH] first modules from Sarek --- modules/nf-core/bcftools/mpileup/main.nf | 12 +++--- modules/nf-core/bwa/index/main.nf | 2 +- modules/nf-core/bwamem2/mem/main.nf | 51 ++++++++++++------------ 3 files changed, 33 insertions(+), 32 deletions(-) diff --git a/modules/nf-core/bcftools/mpileup/main.nf b/modules/nf-core/bcftools/mpileup/main.nf index 82e14df7a74..6760329ef9e 100644 --- a/modules/nf-core/bcftools/mpileup/main.nf +++ b/modules/nf-core/bcftools/mpileup/main.nf @@ -27,9 +27,9 @@ process BCFTOOLS_MPILEUP { def args2 = task.ext.args2 ?: '' def args3 = task.ext.args3 ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def mpileup = save_mpileup ? "| tee ${prefix}.mpileup" : "" - def bgzip_mpileup = save_mpileup ? "bgzip ${prefix}.mpileup" : "" - def intervals = intervals ? "-T ${intervals}" : "" + def mpileup_command = save_mpileup ? "| tee ${prefix}.mpileup" : "" + def bgzip_command = save_mpileup ? "bgzip ${prefix}.mpileup" : "" + def intervals_command = intervals ? "-T ${intervals}" : "" """ echo "${meta.id}" > sample_name.list @@ -38,13 +38,13 @@ process BCFTOOLS_MPILEUP { --fasta-ref $fasta \\ $args \\ $bam \\ - $intervals \\ - $mpileup \\ + $intervals_command \\ + $mpileup_command \\ | bcftools call --output-type v $args2 \\ | bcftools reheader --samples sample_name.list \\ | bcftools view --output-file ${prefix}.vcf.gz --output-type z $args3 - $bgzip_mpileup + $bgzip_command tabix -p vcf -f ${prefix}.vcf.gz diff --git a/modules/nf-core/bwa/index/main.nf b/modules/nf-core/bwa/index/main.nf index 2e48b6caae3..e4233a22d57 100644 --- a/modules/nf-core/bwa/index/main.nf +++ b/modules/nf-core/bwa/index/main.nf @@ -11,7 +11,7 @@ process BWA_INDEX { tuple val(meta), path(fasta) output: - tuple val(meta), path(bwa) , emit: index + tuple val(meta), path("bwa") , emit: index path "versions.yml" , emit: versions when: diff --git a/modules/nf-core/bwamem2/mem/main.nf b/modules/nf-core/bwamem2/mem/main.nf index 729428c4e07..3fb939fc445 100644 --- a/modules/nf-core/bwamem2/mem/main.nf +++ b/modules/nf-core/bwamem2/mem/main.nf @@ -1,25 +1,24 @@ process BWAMEM2_MEM { - tag "$meta.id" + tag "${meta.id}" label 'process_high' - conda "${moduleDir}/environment.yml" - container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://depot.galaxyproject.org/singularity/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:2d15960ccea84e249a150b7f5d4db3a42fc2d6c3-0' : - 'biocontainers/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:2d15960ccea84e249a150b7f5d4db3a42fc2d6c3-0' }" + container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container + ? 'https://depot.galaxyproject.org/singularity/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:2d15960ccea84e249a150b7f5d4db3a42fc2d6c3-0' + : 'biocontainers/mulled-v2-e5d375990341c5aef3c9aff74f96f66f65375ef6:2d15960ccea84e249a150b7f5d4db3a42fc2d6c3-0'}" input: tuple val(meta), path(reads) tuple val(meta2), path(index) tuple val(meta3), path(fasta) - val sort_bam + val sort_bam output: - tuple val(meta), path("*.sam") , emit: sam , optional:true - tuple val(meta), path("*.bam") , emit: bam , optional:true - tuple val(meta), path("*.cram") , emit: cram, optional:true - tuple val(meta), path("*.crai") , emit: crai, optional:true - tuple val(meta), path("*.csi") , emit: csi , optional:true - path "versions.yml" , emit: versions + tuple val(meta), path("*.sam"), emit: sam, optional: true + tuple val(meta), path("*.bam"), emit: bam, optional: true + tuple val(meta), path("*.cram"), emit: cram, optional: true + tuple val(meta), path("*.crai"), emit: crai, optional: true + tuple val(meta), path("*.csi"), emit: csi, optional: true + path "versions.yml", emit: versions when: task.ext.when == null || task.ext.when @@ -31,21 +30,23 @@ process BWAMEM2_MEM { def samtools_command = sort_bam ? 'sort' : 'view' def extension_pattern = /(--output-fmt|-O)+\s+(\S+)/ - def extension_matcher = (args2 =~ extension_pattern) + def extension_matcher = (args2 =~ extension_pattern) def extension = extension_matcher.getCount() > 0 ? extension_matcher[0][2].toLowerCase() : "bam" - def reference = fasta && extension=="cram" ? "--reference ${fasta}" : "" - if (!fasta && extension=="cram") error "Fasta reference is required for CRAM output" + def reference = fasta && extension == "cram" ? "--reference ${fasta}" : "" + if (!fasta && extension == "cram") { + error("Fasta reference is required for CRAM output") + } """ INDEX=`find -L ./ -name "*.amb" | sed 's/\\.amb\$//'` bwa-mem2 \\ mem \\ - $args \\ - -t $task.cpus \\ + ${args} \\ + -t ${task.cpus} \\ \$INDEX \\ - $reads \\ - | samtools $samtools_command $args2 -@ $task.cpus ${reference} -o ${prefix}.${extension} - + ${reads} \\ + | samtools ${samtools_command} ${args2} -@ ${task.cpus} ${reference} -o ${prefix}.${extension} - cat <<-END_VERSIONS > versions.yml "${task.process}": @@ -56,20 +57,20 @@ process BWAMEM2_MEM { stub: - def args = task.ext.args ?: '' def args2 = task.ext.args2 ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - def samtools_command = sort_bam ? 'sort' : 'view' def extension_pattern = /(--output-fmt|-O)+\s+(\S+)/ - def extension_matcher = (args2 =~ extension_pattern) + def extension_matcher = (args2 =~ extension_pattern) def extension = extension_matcher.getCount() > 0 ? extension_matcher[0][2].toLowerCase() : "bam" - def reference = fasta && extension=="cram" ? "--reference ${fasta}" : "" - if (!fasta && extension=="cram") error "Fasta reference is required for CRAM output" + if (!fasta && extension == "cram") { + error("Fasta reference is required for CRAM output") + } def create_index = "" if (extension == "cram") { create_index = "touch ${prefix}.crai" - } else if (extension == "bam") { + } + else if (extension == "bam") { create_index = "touch ${prefix}.csi" }