From 219fc4221aaac26d1664b3e85ec19fc1ed22b1de Mon Sep 17 00:00:00 2001 From: asp8200 Date: Mon, 14 Aug 2023 09:13:35 +0000 Subject: [PATCH] Replace local version of SENTIEON_READWRITER with nf-core version --- modules.json | 5 ++ modules/local/sentieon/readwriter.nf | 54 ------------ modules/nf-core/sentieon/readwriter/main.nf | 84 +++++++++++++++++++ modules/nf-core/sentieon/readwriter/meta.yml | 71 ++++++++++++++++ .../local/alignment/align_sentieon.nf | 5 +- 5 files changed, 162 insertions(+), 57 deletions(-) delete mode 100644 modules/local/sentieon/readwriter.nf create mode 100644 modules/nf-core/sentieon/readwriter/main.nf create mode 100644 modules/nf-core/sentieon/readwriter/meta.yml diff --git a/modules.json b/modules.json index 106948ad..5f9df891 100644 --- a/modules.json +++ b/modules.json @@ -350,6 +350,11 @@ "git_sha": "b9172e8c26a3db5009f7872654c44587e254f094", "installed_by": ["modules"] }, + "sentieon/readwriter": { + "branch": "master", + "git_sha": "b28e4dde755117e8dab5d6e85e292f145b8b53c3", + "installed_by": ["modules"] + }, "smncopynumbercaller": { "branch": "master", "git_sha": "911696ea0b62df80e900ef244d7867d177971f73", diff --git a/modules/local/sentieon/readwriter.nf b/modules/local/sentieon/readwriter.nf deleted file mode 100644 index cc90fd25..00000000 --- a/modules/local/sentieon/readwriter.nf +++ /dev/null @@ -1,54 +0,0 @@ -process SENTIEON_READWRITER { - tag "$meta.id" - label 'process_medium' - label 'sentieon' - - secret 'SENTIEON_LICENSE_BASE64' - - input: - tuple val(meta), path(bam), path(bai) - - output: - tuple val(meta), path('*.bam') , emit: bam - tuple val(meta), path('*.bam.bai') , emit: bai - tuple val(meta), path('*.bam'), path('*.bam.bai'), emit: bam_bai - path "versions.yml" , emit: versions - - when: - task.ext.when == null || task.ext.when - - script: - def args = task.ext.args ?: '' - def input = bam.sort().collect{"-i $it"}.join(' ') - def prefix = task.ext.prefix ?: "${meta.id}" - """ - if [ \${SENTIEON_LICENSE_BASE64:-"unset"} != "unset" ]; then - echo "Initializing SENTIEON_LICENSE env variable" - source sentieon_init.sh SENTIEON_LICENSE_BASE64 - fi - - sentieon \\ - driver \\ - -t $task.cpus \\ - $input \\ - --algo ReadWriter \\ - ${prefix}.bam - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - sentieon: \$(echo \$(sentieon driver --version 2>&1) | sed -e "s/sentieon-genomics-//g") - END_VERSIONS - """ - - stub: - def prefix = task.ext.prefix ?: "${meta.id}" - """ - touch ${prefix}.bam - touch ${prefix}.bam.bai - - cat <<-END_VERSIONS > versions.yml - "${task.process}": - sentieon: \$(echo \$(sentieon driver --version 2>&1) | sed -e "s/sentieon-genomics-//g") - END_VERSIONS - """ -} diff --git a/modules/nf-core/sentieon/readwriter/main.nf b/modules/nf-core/sentieon/readwriter/main.nf new file mode 100644 index 00000000..080b3ad7 --- /dev/null +++ b/modules/nf-core/sentieon/readwriter/main.nf @@ -0,0 +1,84 @@ +process SENTIEON_READWRITER { + tag "$meta.id" + label 'process_medium' + label 'sentieon' + + secret 'SENTIEON_LICENSE_BASE64' + + container 'nf-core/sentieon:202112.06' + + input: + tuple val(meta), path(input), path(index) + tuple val(meta2), path(fasta) + tuple val(meta3), path(fai) + + output: + tuple val(meta), path("*.${format}"), emit: output + tuple val(meta), path("*.${index}") , emit: index + tuple val(meta), path("*.${format}"), path("*.${index}"), emit: output_index + path "versions.yml" , emit: versions + + when: + task.ext.when == null || task.ext.when + + script: + // Exit if running this module with -profile conda / -profile mamba + if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { + error "Sentieon modules do not support Conda. Please use Docker / Singularity / Podman instead." + } + def args = task.ext.args ?: '' + def args2 = task.ext.args2 ?: '' + def input_str = input.sort().collect{"-i $it"}.join(' ') + def reference = fasta ? "-r $fasta" : '' + def prefix = task.ext.prefix ?: "${meta.id}" + format = input.extension == "bam" ? "bam" : "cram" + index = format == "bam" ? "bam.bai" : "cram.crai" + def sentieon_auth_mech_base64 = task.ext.sentieon_auth_mech_base64 ?: '' + def sentieon_auth_data_base64 = task.ext.sentieon_auth_data_base64 ?: '' + """ + if [ "\${#SENTIEON_LICENSE_BASE64}" -lt "1500" ]; then # If the string SENTIEON_LICENSE_BASE64 is short, then it is an encrypted url. + export SENTIEON_LICENSE=\$(echo -e "\$SENTIEON_LICENSE_BASE64" | base64 -d) + else # Localhost license file + # The license file is stored as a nextflow variable like, for instance, this: + # nextflow secrets set SENTIEON_LICENSE_BASE64 \$(cat | base64 -w 0) + export SENTIEON_LICENSE=\$(mktemp) + echo -e "\$SENTIEON_LICENSE_BASE64" | base64 -d > \$SENTIEON_LICENSE + fi + + if [ ${sentieon_auth_mech_base64} ] && [ ${sentieon_auth_data_base64} ]; then + # If sentieon_auth_mech_base64 and sentieon_auth_data_base64 are non-empty strings, then Sentieon is mostly likely being run with some test-license. + export SENTIEON_AUTH_MECH=\$(echo -n "${sentieon_auth_mech_base64}" | base64 -d) + export SENTIEON_AUTH_DATA=\$(echo -n "${sentieon_auth_data_base64}" | base64 -d) + echo "Decoded and exported Sentieon test-license system environment variables" + fi + + sentieon \\ + driver \\ + -t $task.cpus \\ + $reference \\ + $args \\ + $input_str \\ + --algo ReadWriter \\ + $args2 \\ + ${prefix}.${format} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sentieon: \$(echo \$(sentieon driver --version 2>&1) | sed -e "s/sentieon-genomics-//g") + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + format = input.extension == "bam" ? "bam" : "cram" + index = format == "bam" ? "bam.bai" : "cram.crai" + """ + touch ${prefix}.${format} + touch ${prefix}.${index} + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + sentieon: \$(echo \$(sentieon driver --version 2>&1) | sed -e "s/sentieon-genomics-//g") + END_VERSIONS + """ +} diff --git a/modules/nf-core/sentieon/readwriter/meta.yml b/modules/nf-core/sentieon/readwriter/meta.yml new file mode 100644 index 00000000..23dcfcab --- /dev/null +++ b/modules/nf-core/sentieon/readwriter/meta.yml @@ -0,0 +1,71 @@ +name: sentieon_readwriter +description: Merges BAM files, and/or convert them into cram files. Also, outputs the result of applying the Base Quality Score Recalibration to a file. +keywords: + - merge + - convert + - readwriter + - sentieon +tools: + - sentieon: + description: | + Sentieon® provides complete solutions for secondary DNA/RNA analysis for a variety of sequencing platforms, including short and long reads. + Our software improves upon BWA, STAR, Minimap2, GATK, HaplotypeCaller, Mutect, and Mutect2 based pipelines and is deployable on any generic-CPU-based computing system. + homepage: https://www.sentieon.com/ + documentation: https://www.sentieon.com/ +input: + - meta: + type: map + description: | + Groovy Map containing sample information. + e.g. [ id:'test', single_end:false ] + - meta2: + type: map + description: | + Groovy Map containing reference information. + e.g. [ id:'test' ] + - meta3: + type: map + description: | + Groovy Map containing reference information. + e.g. [ id:'test' ] + - input: + type: file + description: BAM/CRAM file. + pattern: "*.{bam,cram}" + - index: + type: file + description: BAI/CRAI file. + pattern: "*.{bai,crai}" + - fasta: + type: file + description: Genome fasta file + pattern: "*.{fa,fasta}" + - fai: + type: file + description: The index of the FASTA reference. + pattern: "*.fai" + +output: + - meta: + type: map + description: | + Groovy Map containing reference information. + e.g. [ id:'test', single_end:false ] + - output: + type: file + description: BAM/CRAM file + pattern: "*.{bam,cram}" + - index: + type: file + description: BAM/CRAM index file + pattern: "*.{bai,crai}" + - output_index: + type: file + description: BAM/CRAM alignment and the corresponding index file + - versions: + type: file + description: File containing software versions + pattern: "versions.yml" + +authors: + - "@ramprasadn" diff --git a/subworkflows/local/alignment/align_sentieon.nf b/subworkflows/local/alignment/align_sentieon.nf index 796aeaa4..2f172714 100644 --- a/subworkflows/local/alignment/align_sentieon.nf +++ b/subworkflows/local/alignment/align_sentieon.nf @@ -7,8 +7,7 @@ include { SENTIEON_DATAMETRICS } from '../../../modules/local/sentieon/datame include { SENTIEON_LOCUSCOLLECTOR } from '../../../modules/local/sentieon/locuscollector' include { SENTIEON_DEDUP } from '../../../modules/local/sentieon/dedup' include { SENTIEON_BQSR } from '../../../modules/local/sentieon/bqsr' -include { SENTIEON_READWRITER } from '../../../modules/local/sentieon/readwriter' - +include { SENTIEON_READWRITER } from '../../../modules/nf-core/sentieon/readwriter/main' workflow ALIGN_SENTIEON { take: ch_reads_input // channel: [mandatory] [ val(meta), path(reads_input) ] @@ -41,7 +40,7 @@ workflow ALIGN_SENTIEON { } .set{ merge_bams_in } - SENTIEON_READWRITER (merge_bams_in.multiple) + SENTIEON_READWRITER ( merge_bams_in.multiple, ch_genome_fasta, ch_genome_fai ) ch_bam_bai = merge_bams_in.single.mix(SENTIEON_READWRITER.out.bam_bai) SENTIEON_DATAMETRICS (ch_bam_bai, ch_genome_fasta, ch_genome_fai )