2021-10-29 08:46:34 +00:00
|
|
|
process SAMTOOLS_BAM2FQ {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_low'
|
|
|
|
|
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-10-29 08:46:34 +00:00
|
|
|
|
|
|
|
input:
|
|
|
|
tuple val(meta), path(inputbam)
|
2022-01-07 17:52:39 +00:00
|
|
|
val split
|
2021-10-29 08:46:34 +00:00
|
|
|
|
|
|
|
output:
|
|
|
|
tuple val(meta), path("*.fq.gz"), emit: reads
|
2022-01-07 17:52:39 +00:00
|
|
|
path "versions.yml" , emit: versions
|
2021-10-29 08:46:34 +00:00
|
|
|
|
2022-02-04 08:53:32 +00:00
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
|
|
|
|
2021-10-29 08:46:34 +00:00
|
|
|
script:
|
2021-11-26 07:58:40 +00:00
|
|
|
def args = task.ext.args ?: ''
|
2021-12-02 12:39:55 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}"
|
2021-10-29 08:46:34 +00:00
|
|
|
|
|
|
|
if (split){
|
|
|
|
"""
|
|
|
|
samtools \\
|
|
|
|
bam2fq \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-10-29 08:46:34 +00:00
|
|
|
-@ $task.cpus \\
|
|
|
|
-1 ${prefix}_1.fq.gz \\
|
|
|
|
-2 ${prefix}_2.fq.gz \\
|
|
|
|
-0 ${prefix}_other.fq.gz \\
|
|
|
|
-s ${prefix}_singleton.fq.gz \\
|
|
|
|
$inputbam
|
|
|
|
|
|
|
|
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-10-29 08:46:34 +00:00
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
} else {
|
|
|
|
"""
|
|
|
|
samtools \\
|
|
|
|
bam2fq \\
|
2021-11-26 07:58:40 +00:00
|
|
|
$args \\
|
2021-10-29 08:46:34 +00:00
|
|
|
-@ $task.cpus \\
|
2022-05-05 13:41:13 +00:00
|
|
|
$inputbam | gzip --no-name > ${prefix}_interleaved.fq.gz
|
2021-10-29 08:46:34 +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-10-29 08:46:34 +00:00
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|
|
|
|
}
|