From 66d36c045658849cb713e090d9c3f7df01800fe3 Mon Sep 17 00:00:00 2001 From: Laurent Modolo <laurent.modolo@ens-lyon.fr> Date: Mon, 25 Oct 2021 16:52:14 +0200 Subject: [PATCH] uscs: modify wig_to_bedgraph --- src/nf_modules/danpos/main.nf | 9 +++-- src/nf_modules/ucsc/main.nf | 64 +++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 18 deletions(-) diff --git a/src/nf_modules/danpos/main.nf b/src/nf_modules/danpos/main.nf index bb8a8ed7..a099b713 100644 --- a/src/nf_modules/danpos/main.nf +++ b/src/nf_modules/danpos/main.nf @@ -12,12 +12,13 @@ params.dpos_out = "" workflow dpos_bam_bg { take: + fasta fastq bam main: dpos_bam(fastq, bam) - wig2_to_bedgraph2(dpos_bam.out.wig) + wig2_to_bedgraph2(fasta, dpos_bam.out.wig) emit: bedgraph = wig2_to_bedgraph2.out.bedgraph @@ -249,10 +250,11 @@ awk -v FS='\t' -v OFS='\t' 'FNR > 1 { print \$1, \$4-1, \$4, "Interval_"NR-1, \$ workflow dpeak_bw { take: + fasta fastq bw main: - dpeak_wig(fastq, bigwig2_to_wig2(bw)) + dpeak_wig(fasta, fastq, bigwig2_to_wig2(bw)) wig2_to_bedgraph2(dpeak_wig.out.wig) emit: @@ -311,6 +313,7 @@ awk -v FS='\t' -v OFS='\t' 'FNR > 1 { print \$1, \$4-1, \$4, "Interval_"NR-1, \$ workflow dpeak_bwvsbw { take: + fasta fastq bw_a bw_b @@ -320,7 +323,7 @@ workflow dpeak_bwvsbw { bigwig2_to_wig2(bw_a), bigwig2_to_wig2(bw_b), ) - wig2_to_bedgraph2(dpeak_wigvswig.out.wig) + wig2_to_bedgraph2(fasta, dpeak_wigvswig.out.wig) emit: bedgraph = wig2_to_bedgraph2.out.bedgraph diff --git a/src/nf_modules/ucsc/main.nf b/src/nf_modules/ucsc/main.nf index 369a00d6..77d91695 100644 --- a/src/nf_modules/ucsc/main.nf +++ b/src/nf_modules/ucsc/main.nf @@ -37,46 +37,80 @@ sort -T ./ -k1,1 -k2,2n ${bg} > \ params.wig_to_bedgraph = "" params.wig_to_bedgraph_out = "" -process wig_to_bedgraph { +workflow wig_to_bedgraph { + take: + fasta + wig + main: + wig_to_bigwig( + fasta, + wig + ) + wig_to_bedgraph( + wig_to_bigwig.out.bw + ) + emit: + bg = wig_to_bigwig.out.bg +} + +workflow wig2_to_bedgraph2 { + take: + fasta + wig + main: + wig2_to_bigwig2( + fasta, + wig + ) + wig2_to_bedgraph2( + wig2_to_bigwig2.out.bw + ) + emit: + bg = wig2_to_bigwig2.out.bg +} + +params.bigwig_to_bedgraph = "" +params.bigwig_to_bedgraph_out = "" +process bigwig_to_bedgraph { container = "${container_url}" label "big_mem_mono_cpus" tag "${file_id}" - if (params.wig_to_bedgraph_out != "") { - publishDir "results/${params.wig_to_bedgraph_out}", mode: 'copy' + if (params.bigwig_to_bedgraph_out != "") { + publishDir "results/${params.bigwig_to_bedgraph_out}", mode: 'copy' } input: - tuple val(file_id), path(wig) + tuple val(file_id) path(bw) output: - tuple val(file_id), path("${wig.simpleName}.bg"), emit: bedgraph + tuple val(file_id), path("*.bg"), emit: bg script: """ -awk '{print \$1"\\t"\$2-1"\\t"\$2"\\t"\$3}' ${wig} > ${wig.simpleName}.bg +bigWigToBedGraph ${bw} ${bw.simpleName}.bg """ } -params.wig2_to_bedgraph2 = "" -params.wig2_to_bedgraph2_out = "" -process wig2_to_bedgraph2 { +params.bigwig2_to_bedgraph2 = "" +params.bigwig2_to_bedgraph2_out = "" +process bigwig2_to_bedgraph2 { container = "${container_url}" label "big_mem_mono_cpus" tag "${file_id}" - if (params.wig2_to_bedgraph2_out != "") { - publishDir "results/${params.wig2_to_bedgraph2_out}", mode: 'copy' + if (params.bigwig_to_bedgraph_out != "") { + publishDir "results/${params.bigwig_to_bedgraph_out}", mode: 'copy' } input: - tuple val(file_id), path(wig_a), path(wig_b) + tuple val(file_id), path(bw_a), path(bw_b) output: - tuple val(file_id), path("${wig_a.simpleName}.bg"), path("${wig_b.simpleName}.bg"), emit: bedgraph + tuple val(file_id), path("${bw_a.simpleName}.bg"), path("${bw_b.simpleName}.bg"), emit: bg script: """ -awk '{print \$1"\\t"\$2-1"\\t"\$2"\\t"\$3}' ${wig_a} > ${wig_a.simpleName}.bg -awk '{print \$1"\\t"\$2-1"\\t"\$2"\\t"\$3}' ${wig_b} > ${wig_b.simpleName}.bg +bigWigToBedGraph ${bw_a} ${bw_a.simpleName}.bg +bigWigToBedGraph ${bw_b} ${bw_b.simpleName}.bg """ } -- GitLab