2021-03-22 12:48:23 +00:00
|
|
|
process SAMTOOLS_MERGE {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_low'
|
|
|
|
|
2022-02-28 11:42:29 +00:00
|
|
|
conda (params.enable_conda ? "bioconda::samtools=1.15" : null)
|
2021-11-26 07:58:40 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-02-28 11:42:29 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/samtools:1.15--h1170115_1' :
|
|
|
|
'quay.io/biocontainers/samtools:1.15--h1170115_1' }"
|
2021-03-22 12:48:23 +00:00
|
|
|
|
|
|
|
input:
|
2021-10-29 11:01:05 +00:00
|
|
|
tuple val(meta), path(input_files)
|
|
|
|
path fasta
|
2021-03-22 12:48:23 +00:00
|
|
|
|
|
|
|
output:
|
2022-01-07 17:52:39 +00:00
|
|
|
tuple val(meta), path("${prefix}.bam") , optional:true, emit: bam
|
2021-10-29 11:01:05 +00:00
|
|
|
tuple val(meta), path("${prefix}.cram"), optional:true, emit: cram
|
|
|
|
path "versions.yml" , emit: versions
|
2021-03-22 12:48:23 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-03-22 12:48:23 +00:00
|
|
|
script:
|
2021-12-07 14:00:43 +00:00
|
|
|
def args = task.ext.args ?: ''
|
|
|
|
prefix = task.ext.prefix ?: "${meta.id}"
|
2021-10-29 11:01:05 +00:00
|
|
|
def file_type = input_files[0].getExtension()
|
|
|
|
def reference = fasta ? "--reference ${fasta}" : ""
|
2021-03-22 12:48:23 +00:00
|
|
|
"""
|
2022-01-07 17:52:39 +00:00
|
|
|
samtools \\
|
|
|
|
merge \\
|
|
|
|
--threads ${task.cpus-1} \\
|
|
|
|
$args \\
|
|
|
|
${reference} \\
|
|
|
|
${prefix}.${file_type} \\
|
|
|
|
$input_files
|
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-03-22 12:48:23 +00:00
|
|
|
"""
|
2022-03-28 15:48:39 +00:00
|
|
|
|
|
|
|
stub:
|
|
|
|
prefix = task.ext.suffix ? "${meta.id}${task.ext.suffix}" : "${meta.id}"
|
|
|
|
def file_type = input_files[0].getExtension()
|
|
|
|
"""
|
|
|
|
touch ${prefix}.${file_type}
|
|
|
|
|
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//')
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
2021-03-22 12:48:23 +00:00
|
|
|
}
|