diff --git a/modules/nf-core/genrich/main.nf b/modules/nf-core/genrich/main.nf index 4adcd968f1f..a5580ff11a2 100644 --- a/modules/nf-core/genrich/main.nf +++ b/modules/nf-core/genrich/main.nf @@ -8,54 +8,43 @@ process GENRICH { 'biocontainers/genrich:0.6.1--h5bf99c6_1' }" input: - tuple val(meta), path(treatment_bam) - path control_bam + tuple val(meta), path(treatment_bam), path(control_bam) path blacklist_bed - val save_pvalues - val save_pileup - val save_bed - val save_duplicates output: - tuple val(meta), path("*narrowPeak") , emit: peaks - tuple val(meta), path("*pvalues.bedGraph"), optional:true, emit: bedgraph_pvalues - tuple val(meta), path("*pileup.bedGraph") , optional:true, emit: bedgraph_pileup - tuple val(meta), path("*intervals.bed") , optional:true, emit: bed_intervals - tuple val(meta), path("*duplicates.txt") , optional:true, emit: duplicates - path "versions.yml" , emit: versions + tuple val(meta), path("*.narrowPeak") , emit: peak + path "versions.yml" , emit: versions + + tuple val(meta), path("*.pvalues.bedGraph"), optional:true, emit: bedgraph_pvalues + tuple val(meta), path("*.pileup.bedGraph") , optional:true, emit: bedgraph_pileup + tuple val(meta), path("*.intervals.bed") , optional:true, emit: bed_intervals + tuple val(meta), path("*.duplicates.txt") , optional:true, emit: duplicates when: task.ext.when == null || task.ext.when script: - def args = task.ext.args ?: '' - def prefix = task.ext.prefix ?: "${meta.id}" - def control = control_bam ? "-c $control_bam" : '' - def blacklist = blacklist_bed ? "-E $blacklist_bed" : "" - def pvalues = save_pvalues ? "-f ${prefix}.pvalues.bedGraph" : "" - def pileup = save_pileup ? "-k ${prefix}.pileup.bedGraph" : "" - def bed = save_bed ? "-b ${prefix}.intervals.bed" : "" - def duplicates = "" - if (save_duplicates) { - if (args.contains('-r')) { - duplicates = "-R ${prefix}.duplicates.txt" - } else { - log.info '[Genrich] Duplicates can only be saved if they are filtered, defaulting to -r option (Remove PCR duplicates).' - duplicates = "-r -R ${prefix}.duplicates.txt" - } + def args = task.ext.args ?: "" + def prefix = task.ext.prefix ?: "${meta.id}" + def treatment = treatment_bam ? "-t ${treatment_bam.join(',')}" : "" + def control = control_bam ? "-c ${control_bam.join(',')}" : "" + def blacklist = blacklist_bed ? "-E $blacklist_bed" : "" + + if (meta.single_end && (!args.contains("-y") && !args.contains("-w"))) { + log.info '[Genrich] Single-end data can only be analyzed if unpaired alignments are kept (-y or -w ), defaulting to -y option.' + args = "-y ${args}" + } + if (args.contains("-R") && !args.contains("-r")) { + log.info '[Genrich] Duplicates can only be saved if they are filtered out, defaulting to -r option (Remove PCR duplicates).' + args = "-r ${args}" } """ Genrich \\ - -t $treatment_bam \\ $args \\ + $treatment \\ $control \\ $blacklist \\ - -o ${prefix}.narrowPeak \\ - $pvalues \\ - $pileup \\ - $bed \\ - $duplicates \\ - $control + -o ${prefix}.narrowPeak cat <<-END_VERSIONS > versions.yml "${task.process}": diff --git a/modules/nf-core/genrich/meta.yml b/modules/nf-core/genrich/meta.yml index adf69880bb7..414821f65d8 100644 --- a/modules/nf-core/genrich/meta.yml +++ b/modules/nf-core/genrich/meta.yml @@ -23,11 +23,11 @@ input: e.g. [ id:'test', single_end:false ] - treatment_bam: type: file - description: Coordinate sorted BAM/SAM file from treatment sample + description: Coordinate sorted BAM/SAM file from treatment sample or list of BAM/SAM files from biological replicates pattern: "*.{bam,sam}" - control_bam: type: file - description: Coordinate sorted BAM/SAM file from control sample + description: Coordinate sorted BAM/SAM file from control sample or list of BAM/SAM files from control samples pattern: "*.{bam,sam}" - blacklist_bed: type: file @@ -77,3 +77,4 @@ output: pattern: "*.{version.txt}" authors: - "@JoseEspinosa" + - "@samuelruizperez" diff --git a/tests/modules/nf-core/genrich/main.nf b/tests/modules/nf-core/genrich/main.nf index 71f9b21ccbe..a1cb9f0f8da 100644 --- a/tests/modules/nf-core/genrich/main.nf +++ b/tests/modules/nf-core/genrich/main.nf @@ -4,76 +4,73 @@ nextflow.enable.dsl = 2 include { GENRICH } from '../../../../modules/nf-core/genrich/main.nf' include { GENRICH as GENRICH_CTRL } from '../../../../modules/nf-core/genrich/main.nf' +include { GENRICH as GENRICH_SE } from '../../../../modules/nf-core/genrich/main.nf' include { GENRICH as GENRICH_ALL } from '../../../../modules/nf-core/genrich/main.nf' include { GENRICH as GENRICH_ATACSEQ } from '../../../../modules/nf-core/genrich/main.nf' +include { GENRICH as GENRICH_LIST } from '../../../../modules/nf-core/genrich/main.nf' workflow test_genrich { input = [ [ id:'test', single_end:false ], // meta map - [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] - control = [ ] + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ], + [ ]] blacklist = [ ] - save_pvalues = false - save_pileup = false - save_bed = false - save_duplicates = false - - GENRICH ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) + GENRICH ( input, blacklist ) } workflow test_genrich_ctrl { input = [ [ id:'test', single_end:false ], // meta map - [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] - control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ] + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ], + [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]] blacklist = [ ] - save_pvalues = false - save_pileup = false - save_bed = false - save_duplicates = false + GENRICH_CTRL ( input, blacklist ) +} + +workflow test_genrich_se { + input = [ [ id:'test', single_end:true ], // meta map + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ], + [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]] + blacklist = [ ] - GENRICH_CTRL ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) + GENRICH_SE ( input, blacklist ) } + workflow test_genrich_all_outputs { input = [ [ id:'test', single_end:false ], // meta map - [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] - control = [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ] + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ], + [ file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true) ]] blacklist = [ ] - save_pvalues = true - save_pileup = true - save_bed = true - save_duplicates = true - - GENRICH_ALL ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) + GENRICH_ALL ( input, blacklist ) } workflow test_genrich_blacklist { input = [ [ id:'test', single_end:false ], // meta map - [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] - control = [ ] + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ], + [ ]] blacklist = [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)] - save_pvalues = false - save_pileup = false - save_bed = false - save_duplicates = false - - GENRICH ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) + GENRICH ( input, blacklist ) } workflow test_genrich_atacseq { input = [ [ id:'test', single_end:false ], // meta map - [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ]] - control = [ ] + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true) ], + [ ]] blacklist = [ ] - save_pvalues = false - save_pileup = false - save_bed = false - save_duplicates = false + GENRICH_ATACSEQ ( input, blacklist ) +} + +workflow test_genrich_list { + input = [ [ id:'test', single_end:false ], // meta map + [ file( params.test_data['homo_sapiens']['illumina']['test_paired_end_name_sorted_bam'], checkIfExists: true), + file( params.test_data['homo_sapiens']['illumina']['test2_paired_end_name_sorted_bam'], checkIfExists: true)], + [ ]] + blacklist = [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true)] - GENRICH_ATACSEQ ( input, control, blacklist, save_pvalues, save_pileup, save_bed, save_duplicates ) + GENRICH_LIST ( input, blacklist ) } diff --git a/tests/modules/nf-core/genrich/nextflow.config b/tests/modules/nf-core/genrich/nextflow.config index 8f79d7be2e9..a9372b44707 100644 --- a/tests/modules/nf-core/genrich/nextflow.config +++ b/tests/modules/nf-core/genrich/nextflow.config @@ -10,12 +10,27 @@ process { ext.args = '-p 0.9' } + withName: GENRICH_SE { + ext.args = '-p 0.9' + } + withName: GENRICH_ALL { - ext.args = '-r -p 0.1' + ext.args = { + [ + "-p 0.9", + "-k ${meta.id}.pileup.bedGraph", + "-f ${meta.id}.pvalues.bedGraph", + "-b ${meta.id}.intervals.bed", + "-R ${meta.id}.duplicates.txt" + ].join(' ').trim() + } } withName: GENRICH_ATACSEQ { ext.args = '-j -p 0.1' } + withName: GENRICH_LIST { + ext.args = '-p 0.1' + } } diff --git a/tests/modules/nf-core/genrich/test.yml b/tests/modules/nf-core/genrich/test.yml index 6d9f2139444..f6a6a56c8c3 100644 --- a/tests/modules/nf-core/genrich/test.yml +++ b/tests/modules/nf-core/genrich/test.yml @@ -1,21 +1,32 @@ - name: genrich test_genrich - command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich -c ./tests/config/nextflow.config tags: - genrich files: - path: output/genrich/test.narrowPeak md5sum: 6afabdd3f691c7c84c66ff8a23984681 + - path: output/genrich/versions.yml - name: genrich test_genrich_ctrl - command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_ctrl -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_ctrl -c ./tests/config/nextflow.config tags: - genrich files: - path: output/genrich/test.narrowPeak md5sum: 2fcc392360b317f5ebee88cdbc149e05 + - path: output/genrich/versions.yml + +- name: genrich test_genrich_se + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_se -c ./tests/config/nextflow.config + tags: + - genrich + files: + - path: output/genrich/test.narrowPeak + md5sum: 1a835e303b090b5eea91b8e4f5cc1df6 + - path: output/genrich/versions.yml - name: genrich test_genrich_all_outputs - command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_all_outputs -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_all_outputs -c ./tests/config/nextflow.config tags: - genrich files: @@ -24,24 +35,36 @@ - path: output/genrich/test.intervals.bed md5sum: 4bea65caa3f4043d703af4b57161112e - path: output/genrich/test.narrowPeak - md5sum: d41d8cd98f00b204e9800998ecf8427e + md5sum: 82bc06c2e44e4d91152a6ac6557a2c6e - path: output/genrich/test.pileup.bedGraph md5sum: 03e53848de695b5794f32f15b2709203 - path: output/genrich/test.pvalues.bedGraph - md5sum: b14feef34b6d2379a173a734ca963cde + md5sum: 21ad9731340e9bedc30c4d34f7db7751 + - path: output/genrich/versions.yml - name: genrich test_genrich_blacklist - command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_blacklist -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_blacklist -c ./tests/config/nextflow.config tags: - genrich files: - path: output/genrich/test.narrowPeak md5sum: 6afabdd3f691c7c84c66ff8a23984681 + - path: output/genrich/versions.yml - name: genrich test_genrich_atacseq - command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_atacseq -c ./tests/config/nextflow.config -c ./tests/modules/nf-core/genrich/nextflow.config + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_atacseq -c ./tests/config/nextflow.config tags: - genrich files: - path: output/genrich/test.narrowPeak md5sum: ddea556b820f8be3695ffdf6c6f70aff + - path: output/genrich/versions.yml + +- name: genrich test_genrich_list + command: nextflow run ./tests/modules/nf-core/genrich -entry test_genrich_list -c ./tests/config/nextflow.config + tags: + - genrich + files: + - path: output/genrich/test.narrowPeak + md5sum: f793e0ff59274e6364151a7cd4eeeafd + - path: output/genrich/versions.yml