Newer
Older
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
params.bam = "$baseDir/data/bam/*.bam"
log.info "bams files : ${params.bam}"
Channel
.fromPath( params.bam )
.ifEmpty { error "Cannot find any bam files matching: ${params.bam}" }
.map { it -> [(it.baseName =~ /([^\.]*)/)[0][1], it]}
.set { bam_files }
bam_files.into{
bam_files_index;
bam_files_bigwig
}
process index_bam {
tag "$file_id"
cpus 4
input:
set file_id, file(bam) from bam_files_index
output:
set file_id, "*.bam*" into indexed_bam_file
script:
"""
sambamba index -t ${task.cpus} ${bam}
"""
}
bam_files_indexed = bam_files_bigwig.join(indexed_bam_file, by: 0)
process bam_to_bigwig {
tag "$file_id"
cpus 4
publishDir "results/mapping/bigwig/", mode: 'copy'
input:
set file_id, file(bam), file(idx) from bam_files_indexed
output:
set file_id, "*.bw" into sorted_bam_files
script:
"""
bamCoverage -p ${task.cpus} --ignoreDuplicates -b ${bam} -o ${file_id}.bw
"""
}