nf-core_modules/modules/stadeniolib/scramble/main.nf
Matthias De Smet e19a9a2474
new tool: staden_io_lib (#1499)
* new tool: staden_io_lib

* update docker containers

* add test.yml

* add fai index input

* typo

* fix version.yml

* update md5sum

* omit md5sum for cram

* move scramble to submodule

* add missing in/output

* remove some comments

Co-authored-by: Sateesh Peri <33637490+sateeshperi@users.noreply.github.com>
2022-04-08 09:54:15 -04:00

61 lines
1.7 KiB
Text

process STADENIOLIB_SCRAMBLE {
tag "$meta.id"
label 'process_medium'
conda (params.enable_conda ? "bioconda::staden_io_lib=1.14.14" : null)
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/staden_io_lib:1.14.14--h0d9da7e_3' :
'quay.io/biocontainers/staden_io_lib:1.14.14--h0d9da7e_3' }"
input:
tuple val(meta), path(reads)
path(fasta)
path(fai)
path(gzi)
output:
tuple val(meta), path("*.cram") ,emit: cram
path "*.gzi" ,emit: gzi, optional: true
path "versions.yml" ,emit: versions
when:
task.ext.when == null || task.ext.when
script:
def args = task.ext.args ?: ''
def prefix = task.ext.prefix ?: "${meta.id}"
def inputformat = reads.getExtension
def outputformat = "cram"
if ("-O sam" in args) {
outputformat = "sam"
} else if ("-O bam" in args) {
outputformat = "bam"
}
def reference = if fasta && fai : "--r ${fasta}" else ""
if (outputformat == "cram" && !reference) {
error "Cannot convert to CRAM without a reference"
}
def gz_index = if gzi : "--g ${gzi}" else ""
if (outputformat == "cram" || outputformat == "sam") {
gz_index = ""
warning "Cannot use gzip index for CRAM or SAM output"
}
"""
scramble \
$args \
-I ${inputformat} \
$reference \
-t $task.cpus \
${reads} \
${prefix}.${outputformat}
cat <<-END_VERSIONS > versions.yml
"${task.process}":
stadeniolib: \$(echo \$(scramble -h | head -n 1 |sed 's/^.*version //'))
END_VERSIONS
"""
}