From a095fa9d642424a0d8e1f643bcb76c0d5696cb06 Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent@modolo.fr> Date: Wed, 19 Dec 2018 16:11:40 +0100 Subject: [PATCH] deepTools: bam_to_bigwig working --- src/nf_modules/deepTools/bam_to_bigwig.config | 13 +++++ src/nf_modules/deepTools/bam_to_bigwig.nf | 51 +++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 src/nf_modules/deepTools/bam_to_bigwig.nf diff --git a/src/nf_modules/deepTools/bam_to_bigwig.config b/src/nf_modules/deepTools/bam_to_bigwig.config index 6ecf0ac2..90eada5d 100644 --- a/src/nf_modules/deepTools/bam_to_bigwig.config +++ b/src/nf_modules/deepTools/bam_to_bigwig.config @@ -3,6 +3,9 @@ profiles { docker.temp = 'auto' docker.enabled = true process { + withName: index_bam { + container = "sambamba:0.6.7" + } withName: bam_to_bigwig { container = "deeptools:3.0.2" } @@ -10,6 +13,16 @@ profiles { } psmn { process{ + withName: index_bam { + beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules" + module = "sambamba/0.6.7" + executor = "sge" + clusterOptions = "-m e -cwd -V" + memory = "30GB" + time = "24h" + queue = 'E5-2670deb128A,E5-2670deb128B,E5-2670deb128C,E5-2670deb128D,E5-2670deb128E,E5-2670deb128F' + penv = 'openmp16' + } withName: bam_to_bigwig { beforeScript = "source /usr/share/lmod/lmod/init/bash; module use ~/privatemodules" module = "deepTools/3.0.2" diff --git a/src/nf_modules/deepTools/bam_to_bigwig.nf b/src/nf_modules/deepTools/bam_to_bigwig.nf new file mode 100644 index 00000000..012de76a --- /dev/null +++ b/src/nf_modules/deepTools/bam_to_bigwig.nf @@ -0,0 +1,51 @@ +params.bam = "$baseDir/data/bam/*.bam" +params.bamidx = "$baseDir/data/bam/*.idx" + +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 +""" +} + -- GitLab