-
Notifications
You must be signed in to change notification settings - Fork 176
Expand file tree
/
Copy pathbedtools_genomecov.nf
More file actions
55 lines (46 loc) · 1.55 KB
/
bedtools_genomecov.nf
File metadata and controls
55 lines (46 loc) · 1.55 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
process BEDTOOLS_GENOMECOV {
tag "$meta.id"
label 'process_medium'
conda "bioconda::bedtools=2.30.0"
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
'https://depot.galaxyproject.org/singularity/bedtools:2.30.0--hc088bd4_0':
'biocontainers/bedtools:2.30.0--hc088bd4_0' }"
input:
tuple val(meta), path(bam), path(flagstat)
output:
tuple val(meta), path("*.bedGraph"), emit: bedgraph
tuple val(meta), path("*.txt") , emit: scale_factor
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 pe = meta.single_end ? '' : '-pc'
"""
SCALE_FACTOR=\$(grep '[0-9] mapped (' $flagstat | awk '{print 1000000/\$1}')
echo \$SCALE_FACTOR > ${prefix}.scale_factor.txt
bedtools \\
genomecov \\
-ibam $bam \\
-bg \\
-scale \$SCALE_FACTOR \\
$pe \\
$args \\
| sort -T '.' -k1,1 -k2,2n > ${prefix}.bedGraph
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
END_VERSIONS
"""
stub:
def prefix = task.ext.prefix ?: "${meta.id}"
"""
touch ${prefix}.bedGraph
touch ${prefix}.scale_factor.txt
cat <<-END_VERSIONS > versions.yml
"${task.process}":
bedtools: \$(bedtools --version | sed -e "s/bedtools v//g")
END_VERSIONS
"""
}