2021-01-29 16:18:45 +00:00
|
|
|
process SAMTOOLS_VIEW {
|
|
|
|
tag "$meta.id"
|
2021-03-16 17:16:47 +00:00
|
|
|
label 'process_medium'
|
2021-01-29 16:18:45 +00:00
|
|
|
|
2022-04-11 12:26:28 +00:00
|
|
|
conda (params.enable_conda ? "bioconda::samtools=1.15.1" : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-04-11 12:26:28 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/samtools:1.15.1--h1170115_0' :
|
|
|
|
'quay.io/biocontainers/samtools:1.15.1--h1170115_0' }"
|
2021-01-29 16:18:45 +00:00
|
|
|
|
|
|
|
input:
|
2022-04-22 08:01:47 +00:00
|
|
|
tuple val(meta), path(input), path(index)
|
2021-10-29 11:01:05 +00:00
|
|
|
path fasta
|
2021-01-29 16:18:45 +00:00
|
|
|
|
|
|
|
output:
|
2021-11-18 21:24:47 +00:00
|
|
|
tuple val(meta), path("*.bam") , emit: bam , optional: true
|
|
|
|
tuple val(meta), path("*.cram"), emit: cram, optional: true
|
|
|
|
path "versions.yml" , emit: versions
|
2021-01-29 16:18:45 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-01-29 16:18:45 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2022-01-11 21:39:21 +00:00
|
|
|
def args2 = task.ext.args2 ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-10-29 11:01:05 +00:00
|
|
|
def reference = fasta ? "--reference ${fasta} -C" : ""
|
|
|
|
def file_type = input.getExtension()
|
2022-01-07 17:52:39 +00:00
|
|
|
if ("$input" == "${prefix}.${file_type}") error "Input and output names are the same, use \"task.ext.prefix\" to disambiguate!"
|
2021-01-29 16:18:45 +00:00
|
|
|
"""
|
2022-01-07 17:52:39 +00:00
|
|
|
samtools \\
|
|
|
|
view \\
|
|
|
|
--threads ${task.cpus-1} \\
|
|
|
|
${reference} \\
|
|
|
|
$args \\
|
|
|
|
$input \\
|
2022-01-11 21:39:21 +00:00
|
|
|
$args2 \\
|
2022-01-07 17:52:39 +00:00
|
|
|
> ${prefix}.${file_type}
|
2021-11-18 21:24:47 +00:00
|
|
|
|
2021-09-27 08:41:24 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
2021-11-26 07:58:40 +00:00
|
|
|
"${task.process}":
|
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
2021-09-27 08:41:24 +00:00
|
|
|
END_VERSIONS
|
2021-01-29 16:18:45 +00:00
|
|
|
"""
|
2022-05-02 08:34:14 +00:00
|
|
|
|
|
|
|
stub:
|
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
|
|
|
"""
|
|
|
|
touch ${prefix}.bam
|
|
|
|
touch ${prefix}.cram
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
2021-01-29 17:01:58 +00:00
|
|
|
}
|