From 9ae34a01d1747019fd37753ff4cafb05aec35a2b Mon Sep 17 00:00:00 2001 From: FriederikeHanssen Date: Fri, 8 Apr 2022 11:43:40 +0200 Subject: [PATCH] Fix Controlfreec: Add stub runs to test single sample input & make conda work with R scripts (#1504) * Fix typo * Add stub runs for testing input without matched normals * Add missing -stub-run * remove empty file checksum tests and change workflow names * test controlfreec naming * fix output file names * fix output file names * fix output file names * fix conda and container path difference for R scripts * update tar version to work with conda * fix version number in docker * try to fix path to script, pretty sure it won't work * try new ways to set path with wildcard * try which * add which but with escape * remove comment --- .../controlfreec/assesssignificance/main.nf | 13 ++++++- modules/controlfreec/freec/main.nf | 20 ++++++++++- modules/controlfreec/freec2bed/main.nf | 11 ++++++ modules/controlfreec/freec2circos/main.nf | 11 ++++++ modules/controlfreec/makegraph/main.nf | 14 +++++++- modules/untar/main.nf | 6 ++-- .../controlfreec/assesssignificance/main.nf | 35 ++++++++++++++++++ .../controlfreec/assesssignificance/test.yml | 10 +++++- tests/modules/controlfreec/freec/main.nf | 33 +++++++++++++++++ tests/modules/controlfreec/freec/test.yml | 16 ++++++++- tests/modules/controlfreec/freec2bed/main.nf | 36 ++++++++++++++++++- tests/modules/controlfreec/freec2bed/test.yml | 8 +++++ .../modules/controlfreec/freec2circos/main.nf | 34 ++++++++++++++++++ .../controlfreec/freec2circos/test.yml | 8 +++++ tests/modules/controlfreec/makegraph/main.nf | 35 ++++++++++++++++++ tests/modules/controlfreec/makegraph/test.yml | 10 ++++++ 16 files changed, 291 insertions(+), 9 deletions(-) diff --git a/modules/controlfreec/assesssignificance/main.nf b/modules/controlfreec/assesssignificance/main.nf index f85a3c7f..4bdb00b3 100644 --- a/modules/controlfreec/assesssignificance/main.nf +++ b/modules/controlfreec/assesssignificance/main.nf @@ -21,7 +21,7 @@ process CONTROLFREEC_ASSESSSIGNIFICANCE { def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" """ - cat /usr/local/bin/assess_significance.R | R --slave --args ${cnvs} ${ratio} + cat \$(which assess_significance.R) | R --slave --args ${cnvs} ${ratio} mv *.p.value.txt ${prefix}.p.value.txt @@ -30,4 +30,15 @@ process CONTROLFREEC_ASSESSSIGNIFICANCE { controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.p.value.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) + END_VERSIONS + """ } diff --git a/modules/controlfreec/freec/main.nf b/modules/controlfreec/freec/main.nf index eb66eeaa..857ffdee 100644 --- a/modules/controlfreec/freec/main.nf +++ b/modules/controlfreec/freec/main.nf @@ -21,7 +21,7 @@ process CONTROLFREEC_FREEC { output: tuple val(meta), path("*_ratio.BedGraph") , emit: bedgraph, optional: true - tuple val(meta), path("*_control.cpn") , emit: control_cpn + tuple val(meta), path("*_control.cpn") , emit: control_cpn, optional: true tuple val(meta), path("*_sample.cpn") , emit: sample_cpn tuple val(meta), path("GC_profile.*.cpn") , emit: gcprofile_cpn, optional:true tuple val(meta), path("*_BAF.txt") , emit: BAF @@ -155,4 +155,22 @@ process CONTROLFREEC_FREEC { controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}_ratio.BedGraph + touch ${prefix}_sample.cpn + touch GC_profile.${prefix}.cpn + touch ${prefix}_BAF.txt + touch ${prefix}_CNVs + touch ${prefix}_info.txt + touch ${prefix}_ratio.txt + touch config.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) + END_VERSIONS + """ } diff --git a/modules/controlfreec/freec2bed/main.nf b/modules/controlfreec/freec2bed/main.nf index 880e4716..aefc200e 100644 --- a/modules/controlfreec/freec2bed/main.nf +++ b/modules/controlfreec/freec2bed/main.nf @@ -28,4 +28,15 @@ process CONTROLFREEC_FREEC2BED { controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.bed + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) + END_VERSIONS + """ } diff --git a/modules/controlfreec/freec2circos/main.nf b/modules/controlfreec/freec2circos/main.nf index 8879d4c0..8f9be300 100644 --- a/modules/controlfreec/freec2circos/main.nf +++ b/modules/controlfreec/freec2circos/main.nf @@ -28,4 +28,15 @@ process CONTROLFREEC_FREEC2CIRCOS { controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) END_VERSIONS """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}.circos.txt + + cat <<-END_VERSIONS > versions.yml + "${task.process}": + controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) + END_VERSIONS + """ } diff --git a/modules/controlfreec/makegraph/main.nf b/modules/controlfreec/makegraph/main.nf index 9a0c7281..a8954d72 100644 --- a/modules/controlfreec/makegraph/main.nf +++ b/modules/controlfreec/makegraph/main.nf @@ -25,12 +25,24 @@ process CONTROLFREEC_MAKEGRAPH { def prefix = task.ext.prefix ?: "${meta.id}" def baf = baf ?: "" """ - cat /usr/local/bin/makeGraph.R | R --slave --args ${args} ${ratio} ${baf} + cat \$(which makeGraph.R) | R --slave --args ${args} ${ratio} ${baf} mv *_BAF.txt.png ${prefix}_BAF.png mv *_ratio.txt.log2.png ${prefix}_ratio.log2.png mv *_ratio.txt.png ${prefix}_ratio.png + cat <<-END_VERSIONS > versions.yml + "${task.process}": + controlfreec: \$(echo \$(freec -version 2>&1) | sed 's/^.*Control-FREEC //; s/:.*\$//' | sed -e "s/Control-FREEC v//g" ) + END_VERSIONS + """ + + stub: + def prefix = task.ext.prefix ?: "${meta.id}" + """ + touch ${prefix}_BAF.png + touch ${prefix}_ratio.log2.png + touch ${prefix}_ratio.png cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/untar/main.nf b/modules/untar/main.nf index 5aa6aa7f..bbfa0bfe 100644 --- a/modules/untar/main.nf +++ b/modules/untar/main.nf @@ -2,10 +2,10 @@ process UNTAR { tag "$archive" label 'process_low' - conda (params.enable_conda ? "conda-forge::tar=1.32" : null) + conda (params.enable_conda ? "conda-forge::tar=1.34" : null) container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? - 'https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv1/biocontainers_v1.2.0_cv1.img' : - 'biocontainers/biocontainers:v1.2.0_cv1' }" + 'https://containers.biocontainers.pro/s3/SingImgsRepo/biocontainers/v1.2.0_cv2/biocontainers_v1.2.0_cv2.img' : + 'biocontainers/biocontainers:v1.2.0_cv2' }" input: tuple val(meta), path(archive) diff --git a/tests/modules/controlfreec/assesssignificance/main.nf b/tests/modules/controlfreec/assesssignificance/main.nf index f8d8aa1d..e5ed1bf7 100644 --- a/tests/modules/controlfreec/assesssignificance/main.nf +++ b/tests/modules/controlfreec/assesssignificance/main.nf @@ -40,3 +40,38 @@ workflow test_controlfreec_assesssignificance { sig_in = CONTROLFREEC_FREEC.out.CNV.join(CONTROLFREEC_FREEC.out.ratio) CONTROLFREEC_ASSESSSIGNIFICANCE ( sig_in ) } + +workflow test_controlfreec_assesssignificance_single { + + input = [ + [ id:'test', single_end:false, sex:'XX' ], // meta map + [], + file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), + [],[],[],[] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) + + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz_tbi'], checkIfExists: true) + + chrfiles = [ [], file(params.test_data['homo_sapiens']['genome']['genome_21_chromosomes_dir'], checkIfExists: true) ] + target_bed = file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + + UNTAR(chrfiles) + CONTROLFREEC_FREEC (input, + fasta, + fai, + [], + dbsnp, + dbsnp_tbi, + UNTAR.out.untar.map{ it[1] }, + [], + target_bed, + [] + ) + + sig_in = CONTROLFREEC_FREEC.out.CNV.join(CONTROLFREEC_FREEC.out.ratio) + CONTROLFREEC_ASSESSSIGNIFICANCE ( sig_in ) +} diff --git a/tests/modules/controlfreec/assesssignificance/test.yml b/tests/modules/controlfreec/assesssignificance/test.yml index f8393330..19e54acf 100644 --- a/tests/modules/controlfreec/assesssignificance/test.yml +++ b/tests/modules/controlfreec/assesssignificance/test.yml @@ -7,4 +7,12 @@ - path: output/controlfreec/test.p.value.txt md5sum: 44e23b916535fbc1a3f47b57fad292df - path: output/controlfreec/versions.yml - md5sum: 0aa42fed10d61e4570fe1e0e83ffe932 + +- name: controlfreec assesssignificance test_controlfreec_assesssignificance_single + command: nextflow run tests/modules/controlfreec/assesssignificance -entry test_controlfreec_assesssignificance_single -c tests/config/nextflow.config -stub-run + tags: + - controlfreec/assesssignificance + - controlfreec + files: + - path: output/controlfreec/test.p.value.txt + - path: output/controlfreec/versions.yml diff --git a/tests/modules/controlfreec/freec/main.nf b/tests/modules/controlfreec/freec/main.nf index d14c8f65..1f4a069b 100644 --- a/tests/modules/controlfreec/freec/main.nf +++ b/tests/modules/controlfreec/freec/main.nf @@ -36,3 +36,36 @@ workflow test_controlfreec_freec { [] ) } + +workflow test_controlfreec_freec_single { + + input = [ + [ id:'test2', single_end:false, sex:'XX' ], // meta map + [], + file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), + [],[],[],[] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) + + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz_tbi'], checkIfExists: true) + + chrfiles = [ [], file(params.test_data['homo_sapiens']['genome']['genome_21_chromosomes_dir'], checkIfExists: true) ] + target_bed = file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + + UNTAR(chrfiles) + CONTROLFREEC_FREEC (input, + fasta, + fai, + [], + dbsnp, + dbsnp_tbi, + UNTAR.out.untar.map{ it[1] }, + [], + target_bed, + [] + ) +} + diff --git a/tests/modules/controlfreec/freec/test.yml b/tests/modules/controlfreec/freec/test.yml index d50fc063..1bd4e3a4 100644 --- a/tests/modules/controlfreec/freec/test.yml +++ b/tests/modules/controlfreec/freec/test.yml @@ -20,4 +20,18 @@ - path: output/controlfreec/test2.mpileup.gz_sample.cpn md5sum: c80dad58a77b1d7ba6d273999f4b4b4b - path: output/controlfreec/versions.yml - md5sum: 3ab250a2ab3be22628124c7c65324651 + +- name: controlfreec test_controlfreec_freec_single + command: nextflow run tests/modules/controlfreec/freec -entry test_controlfreec_freec_single -c tests/config/nextflow.config -stub-run + tags: + - controlfreec + - controlfreec/freec + files: + - path: output/controlfreec/config.txt + - path: output/controlfreec/test2_BAF.txt + - path: output/controlfreec/test2_CNVs + - path: output/controlfreec/test2_info.txt + - path: output/controlfreec/test2_ratio.BedGraph + - path: output/controlfreec/test2_ratio.txt + - path: output/controlfreec/test2_sample.cpn + - path: output/controlfreec/versions.yml diff --git a/tests/modules/controlfreec/freec2bed/main.nf b/tests/modules/controlfreec/freec2bed/main.nf index df121832..c1b0f04e 100644 --- a/tests/modules/controlfreec/freec2bed/main.nf +++ b/tests/modules/controlfreec/freec2bed/main.nf @@ -8,7 +8,7 @@ include { UNTAR } from '../../../../modules/untar/main.nf' workflow test_controlfreec_freec2bed { - input = [ + input = [ [ id:'test', single_end:false, sex:'XX' ], // meta map file(params.test_data['homo_sapiens']['illumina']['test_mpileup'], checkIfExists: true), file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), @@ -39,3 +39,37 @@ workflow test_controlfreec_freec2bed { CONTROLFREEC_FREEC2BED ( CONTROLFREEC_FREEC.out.ratio ) } + +workflow test_controlfreec_freec2bed_single { + + input = [ + [ id:'test', single_end:false, sex:'XX' ], // meta map + [], + file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), + [],[],[],[] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) + + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz_tbi'], checkIfExists: true) + + chrfiles = [ [], file(params.test_data['homo_sapiens']['genome']['genome_21_chromosomes_dir'], checkIfExists: true) ] + target_bed = file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + + UNTAR(chrfiles) + CONTROLFREEC_FREEC (input, + fasta, + fai, + [], + dbsnp, + dbsnp_tbi, + UNTAR.out.untar.map{ it[1] }, + [], + target_bed, + [] + ) + + CONTROLFREEC_FREEC2BED ( CONTROLFREEC_FREEC.out.ratio ) +} diff --git a/tests/modules/controlfreec/freec2bed/test.yml b/tests/modules/controlfreec/freec2bed/test.yml index 0198bac6..9abb3a54 100644 --- a/tests/modules/controlfreec/freec2bed/test.yml +++ b/tests/modules/controlfreec/freec2bed/test.yml @@ -6,3 +6,11 @@ files: - path: output/controlfreec/test.bed md5sum: abe10b7ce94ba903503e697394c17297 + +- name: controlfreec freec2bed test_controlfreec_freec2bed_single + command: nextflow run tests/modules/controlfreec/freec2bed -entry test_controlfreec_freec2bed_single -c tests/config/nextflow.config -stub-run + tags: + - controlfreec/freec2bed + - controlfreec + files: + - path: output/controlfreec/test.bed diff --git a/tests/modules/controlfreec/freec2circos/main.nf b/tests/modules/controlfreec/freec2circos/main.nf index 9b655f0e..6b34edb6 100644 --- a/tests/modules/controlfreec/freec2circos/main.nf +++ b/tests/modules/controlfreec/freec2circos/main.nf @@ -39,3 +39,37 @@ workflow test_controlfreec_freec2circos { CONTROLFREEC_FREEC2CIRCOS ( CONTROLFREEC_FREEC.out.ratio ) } + +workflow test_controlfreec_freec2circos_single { + + input = [ + [ id:'test', single_end:false, sex:'XX' ], // meta map + [], + file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), + [],[],[],[] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) + + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz_tbi'], checkIfExists: true) + + chrfiles = [ [], file(params.test_data['homo_sapiens']['genome']['genome_21_chromosomes_dir'], checkIfExists: true) ] + target_bed = file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + + UNTAR(chrfiles) + CONTROLFREEC_FREEC (input, + fasta, + fai, + [], + dbsnp, + dbsnp_tbi, + UNTAR.out.untar.map{ it[1] }, + [], + target_bed, + [] + ) + + CONTROLFREEC_FREEC2CIRCOS ( CONTROLFREEC_FREEC.out.ratio ) +} diff --git a/tests/modules/controlfreec/freec2circos/test.yml b/tests/modules/controlfreec/freec2circos/test.yml index 5758a828..c29111de 100644 --- a/tests/modules/controlfreec/freec2circos/test.yml +++ b/tests/modules/controlfreec/freec2circos/test.yml @@ -6,3 +6,11 @@ files: - path: output/controlfreec/test.circos.txt md5sum: 19cf35f2c36b46f717dc8342b8a5a645 + +- name: controlfreec freec2circos test_controlfreec_freec2circos_single + command: nextflow run tests/modules/controlfreec/freec2circos -entry test_controlfreec_freec2circos_single -c tests/config/nextflow.config -stub-run + tags: + - controlfreec + - controlfreec/freec2circos + files: + - path: output/controlfreec/test.circos.txt diff --git a/tests/modules/controlfreec/makegraph/main.nf b/tests/modules/controlfreec/makegraph/main.nf index ffea3d99..543216e1 100644 --- a/tests/modules/controlfreec/makegraph/main.nf +++ b/tests/modules/controlfreec/makegraph/main.nf @@ -40,3 +40,38 @@ workflow test_controlfreec_makegraph { makegraph_in = CONTROLFREEC_FREEC.out.ratio.join(CONTROLFREEC_FREEC.out.BAF) CONTROLFREEC_MAKEGRAPH ( makegraph_in ) } + +workflow test_controlfreec_makegraph_single { + + input = [ + [ id:'test', single_end:false, sex:'XX' ], // meta map + [], + file(params.test_data['homo_sapiens']['illumina']['test2_mpileup'], checkIfExists: true), + [],[],[],[] + ] + + fasta = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta'], checkIfExists: true) + fai = file(params.test_data['homo_sapiens']['genome']['genome_21_fasta_fai'], checkIfExists: true) + + dbsnp = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz'], checkIfExists: true) + dbsnp_tbi = file(params.test_data['homo_sapiens']['genome']['dbsnp_138_hg38_21_vcf_gz_tbi'], checkIfExists: true) + + chrfiles = [ [], file(params.test_data['homo_sapiens']['genome']['genome_21_chromosomes_dir'], checkIfExists: true) ] + target_bed = file(params.test_data['homo_sapiens']['genome']['genome_21_multi_interval_bed'], checkIfExists: true) + + UNTAR(chrfiles) + CONTROLFREEC_FREEC (input, + fasta, + fai, + [], + dbsnp, + dbsnp_tbi, + UNTAR.out.untar.map{ it[1] }, + [], + target_bed, + [] + ) + + makegraph_in = CONTROLFREEC_FREEC.out.ratio.join(CONTROLFREEC_FREEC.out.BAF) + CONTROLFREEC_MAKEGRAPH ( makegraph_in ) +} diff --git a/tests/modules/controlfreec/makegraph/test.yml b/tests/modules/controlfreec/makegraph/test.yml index 21e78766..02d1a165 100644 --- a/tests/modules/controlfreec/makegraph/test.yml +++ b/tests/modules/controlfreec/makegraph/test.yml @@ -10,3 +10,13 @@ md5sum: b3c7916b1b4951a0cc3da20d8e9e0262 - path: output/controlfreec/test_ratio.png md5sum: 1435b29536b3b1555b4c423f8f4fb000 + +- name: controlfreec makegraph test_controlfreec_makegraph_single + command: nextflow run tests/modules/controlfreec/makegraph -entry test_controlfreec_makegraph_single -c tests/config/nextflow.config -stub-run + tags: + - controlfreec + - controlfreec/makegraph + files: + - path: output/controlfreec/test_BAF.png + - path: output/controlfreec/test_ratio.log2.png + - path: output/controlfreec/test_ratio.png