-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathsubsample_bam.nf
More file actions
executable file
·39 lines (31 loc) · 1.17 KB
/
subsample_bam.nf
File metadata and controls
executable file
·39 lines (31 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
process SUBSAMPLE_BAM {
tag "${meta.id}"
label 'process_tiny'
conda "bioconda::samtools=1.17"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/samtools:1.17--h00cdaf9_0' :
'biocontainers/samtools:1.17--h00cdaf9_0' }"
input:
tuple val(meta), path(mergedbam)
output:
tuple val(meta), path('*.bam'), emit: subsampled_bam
path "versions.yml", emit: versions
script:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
percentage=\$(wc -c ${mergedbam} | cut -d' ' -f1 | awk '{printf "%.2f\\n", 50000000000 / \$0}')
samtools view -s \$percentage -b ${mergedbam} > ${meta.id}_subsampled.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )
END_VERSIONS
"""
stub:
"""
touch ${meta.id}_subsampled.bam
cat <<-END_VERSIONS > versions.yml
"${task.process}":
samtools: \$(echo \$(samtools --version 2>&1) | sed 's/^.*samtools //; s/Using.*\$//' )
END_VERSIONS
"""
}