diff --git a/modules/cnvkit/reference/main.nf b/modules/cnvkit/reference/main.nf index 71d9ed28..10458f27 100644 --- a/modules/cnvkit/reference/main.nf +++ b/modules/cnvkit/reference/main.nf @@ -21,13 +21,15 @@ process CNVKIT_REFERENCE { script: def args = task.ext.args ?: '' + def prefix = task.ext.prefix ?: targets.BaseName + """ cnvkit.py \\ reference \\ --fasta $fasta \\ --targets $targets \\ --antitargets $antitargets \\ - --output reference.cnn \\ + --output ${prefix}.reference.cnn \\ $args cat <<-END_VERSIONS > versions.yml diff --git a/modules/mosdepth/main.nf b/modules/mosdepth/main.nf index ff91e06f..5f6538e7 100644 --- a/modules/mosdepth/main.nf +++ b/modules/mosdepth/main.nf @@ -10,13 +10,13 @@ process MOSDEPTH { input: tuple val(meta), path(bam), path(bai) path bed - val window_size + path fasta output: tuple val(meta), path('*.global.dist.txt') , emit: global_txt tuple val(meta), path('*.region.dist.txt') , emit: regions_txt , optional:true tuple val(meta), path('*.summary.txt') , emit: summary_txt - tuple val(meta), path('*.per-base.d4') , emit: d4 , optional:true + tuple val(meta), path('*.per-base.d4') , emit: per_base_d4 , optional:true tuple val(meta), path('*.per-base.bed.gz') , emit: per_base_bed, optional:true tuple val(meta), path('*.per-base.bed.gz.csi'), emit: per_base_csi, optional:true tuple val(meta), path('*.regions.bed.gz') , emit: regions_bed , optional:true @@ -29,19 +29,21 @@ process MOSDEPTH { script: def args = task.ext.args ?: '' def prefix = task.ext.prefix ?: "${meta.id}" - if (window_size) { - interval = "--by ${window_size}" - } else if ( bed ) { - interval = "--by ${bed}" - } else { - interval = "" + def reference = fasta ? "--fasta ${fasta}" : "" + def interval = bed ? "--by ${bed}" : "" + if (bed && args.contains("--by")) { + exit 1, "'--by' can only be specified once when running mosdepth! Either remove input BED file definition or remove '--by' from 'ext.args' definition" } + """ mosdepth \\ + --threads ${task.cpus} \\ $interval \\ + $reference \\ $args \\ $prefix \\ $bam + cat <<-END_VERSIONS > versions.yml "${task.process}": mosdepth: \$(mosdepth --version 2>&1 | sed 's/^.*mosdepth //; s/ .*\$//') diff --git a/modules/mosdepth/meta.yml b/modules/mosdepth/meta.yml index 636e966b..6e9e34c9 100644 --- a/modules/mosdepth/meta.yml +++ b/modules/mosdepth/meta.yml @@ -30,10 +30,10 @@ input: type: file description: BED file with intersected intervals pattern: "*.{bed}" - - window_size: - type: integer - description: Window size - pattern: "[0-9]+" + - fasta: + type: file + description: Reference genome FASTA file + pattern: "*.{fa,fasta}" output: - meta: type: map @@ -60,6 +60,10 @@ output: type: file description: Index file for BED file with per-base coverage pattern: "*.{per-base.bed.gz.csi}" + - per_base_d4: + type: file + description: D4 file with per-base coverage + pattern: "*.{per-base.d4}" - regions_bed: type: file description: BED file with per-region coverage @@ -76,3 +80,4 @@ authors: - "@joseespinosa" - "@drpatelh" - "@ramprasadn" + - "@matthdsm" diff --git a/tests/modules/cnvkit/reference/test.yml b/tests/modules/cnvkit/reference/test.yml index b1b8c896..a5baf0a2 100644 --- a/tests/modules/cnvkit/reference/test.yml +++ b/tests/modules/cnvkit/reference/test.yml @@ -4,5 +4,5 @@ - cnvkit/reference - cnvkit files: - - path: output/cnvkit/reference.cnn + - path: output/cnvkit/multi_intervals.reference.cnn md5sum: 7c4a7902f5ab101b1f9d6038d331b3d9 diff --git a/tests/modules/mosdepth/main.nf b/tests/modules/mosdepth/main.nf index ddd68129..96a9ef20 100644 --- a/tests/modules/mosdepth/main.nf +++ b/tests/modules/mosdepth/main.nf @@ -2,35 +2,72 @@ nextflow.enable.dsl = 2 -include { MOSDEPTH } from '../../../modules/mosdepth/main.nf' +include { MOSDEPTH } from '../../../modules/mosdepth/main.nf' +include { MOSDEPTH as MOSDEPTH_FAIL } from '../../../modules/mosdepth/main.nf' +include { MOSDEPTH as MOSDEPTH_WINDOW } from '../../../modules/mosdepth/main.nf' workflow test_mosdepth { - input = [ [ id:'test', single_end:true ], - [ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], - [ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] - ] + input = [ + [ id:'test', single_end:true ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] + ] MOSDEPTH ( input, [], [] ) } - -workflow test_mosdepth_window { - input = [ [ id:'test', single_end:true ], - [ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], - [ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] - ] - window = 100 - - MOSDEPTH ( input, [], window ) -} - - workflow test_mosdepth_bed { - input = [ [ id:'test', single_end:true ], - [ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], - [ file(params.test_data['sarscov2']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] - ] - bed = [ file(params.test_data['sarscov2']['genome']['test_bed'], checkIfExists: true) ] + input = [ + [ id:'test', single_end:true ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] + ] + bed = [ file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true) ] MOSDEPTH ( input, bed, [] ) } + +workflow test_mosdepth_cram { + input = [ + [ id:'test', single_end:true ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true) ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true) ] + ] + fasta = [ file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) ] + + MOSDEPTH ( input, [], fasta ) +} + +workflow test_mosdepth_cram_bed { + input = [ + [ id:'test', single_end:true ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram'], checkIfExists: true) ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_cram_crai'], checkIfExists: true) ] + ] + bed = [ file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true) ] + fasta = [ file(params.test_data['homo_sapiens']['genome']['genome_fasta'], checkIfExists: true) ] + + MOSDEPTH ( input, bed, fasta ) +} + +workflow test_mosdepth_window { + input = [ + [ id:'test', single_end:true ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] + ] + bed = [ file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true) ] + + MOSDEPTH_WINDOW ( input, [], [] ) +} + +workflow test_mosdepth_fail { + input = [ + [ id:'test', single_end:true ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam'], checkIfExists: true) ], + [ file(params.test_data['homo_sapiens']['illumina']['test_paired_end_sorted_bam_bai'], checkIfExists: true) ] + ] + bed = [ file(params.test_data['homo_sapiens']['genome']['genome_bed'], checkIfExists: true) ] + + MOSDEPTH_FAIL ( input, bed, [] ) +} diff --git a/tests/modules/mosdepth/nextflow.config b/tests/modules/mosdepth/nextflow.config index 8730f1c4..4a6153e6 100644 --- a/tests/modules/mosdepth/nextflow.config +++ b/tests/modules/mosdepth/nextflow.config @@ -1,5 +1,10 @@ process { publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } - + withName: MOSDEPTH_FAIL { + ext.args = "--by 100" + } + withName: MOSDEPTH_WINDOW { + ext.args = "--by 100" + } } diff --git a/tests/modules/mosdepth/test.yml b/tests/modules/mosdepth/test.yml index c66e0b89..a3115d6e 100644 --- a/tests/modules/mosdepth/test.yml +++ b/tests/modules/mosdepth/test.yml @@ -1,53 +1,93 @@ -- name: mosdepth - command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config +- name: mosdepth test_mosdepth + command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config tags: - mosdepth files: - - path: ./output/mosdepth/test.per-base.bed.gz.csi - md5sum: b2aad62c41a7146680d31df505fcc8c5 - - path: ./output/mosdepth/test.per-base.bed.gz - md5sum: 11b3f649072c2c7453febb085b1a9c33 - - path: ./output/mosdepth/test.mosdepth.global.dist.txt - md5sum: 2a1de1b0ecc361a21cd296ec4e1efd6a - - path: ./output/mosdepth/test.mosdepth.summary.txt - md5sum: 7b249dd3b3e58cc122fbd25ea84aa25d + - path: output/mosdepth/test.mosdepth.global.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.summary.txt + md5sum: 4f0d231060cbde4efdd673863bd2fb59 + - path: output/mosdepth/test.per-base.bed.gz + md5sum: bc1df47d46f818fee5275975925d769a + - path: output/mosdepth/test.per-base.bed.gz.csi + md5sum: 9e649ac749ff6c6073bef5ab63e8aaa4 -- name: mosdepth window - command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_window -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config +- name: mosdepth test_mosdepth_bed + command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_bed -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config tags: - mosdepth files: - - path: ./output/mosdepth/test.per-base.bed.gz.csi - md5sum: b2aad62c41a7146680d31df505fcc8c5 - - path: ./output/mosdepth/test.per-base.bed.gz - md5sum: 11b3f649072c2c7453febb085b1a9c33 - - path: ./output/mosdepth/test.mosdepth.global.dist.txt - md5sum: 2a1de1b0ecc361a21cd296ec4e1efd6a - - path: ./output/mosdepth/test.regions.bed.gz - md5sum: 64e1ced01c4443d7c1796ef553992f0c - - path: ./output/mosdepth/test.regions.bed.gz.csi - md5sum: 9e312b4b0784bd46dfbd23b3a8afed6a - - path: ./output/mosdepth/test.mosdepth.region.dist.txt - md5sum: 65fbc824c4212c6884354d8ac72ad37e - - path: ./output/mosdepth/test.mosdepth.summary.txt - md5sum: 11804907dab069ddb99ca97bf2698572 + - path: output/mosdepth/test.mosdepth.global.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.region.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.summary.txt + md5sum: 96c037f769974b904beb53edc4f56d82 + - path: output/mosdepth/test.per-base.bed.gz + md5sum: bc1df47d46f818fee5275975925d769a + - path: output/mosdepth/test.per-base.bed.gz.csi + md5sum: 9e649ac749ff6c6073bef5ab63e8aaa4 + - path: output/mosdepth/test.regions.bed.gz + md5sum: 5d398caf7171ec4406278e2add3009ae + - path: output/mosdepth/test.regions.bed.gz.csi + md5sum: 47669cfe41f3e222e74d81e1b1be191f -- name: mosdepth bed - command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_bed -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config +- name: mosdepth test_mosdepth_cram + command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_cram -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config tags: - mosdepth files: - - path: ./output/mosdepth/test.per-base.bed.gz.csi - md5sum: b2aad62c41a7146680d31df505fcc8c5 - - path: ./output/mosdepth/test.per-base.bed.gz - md5sum: 11b3f649072c2c7453febb085b1a9c33 - - path: ./output/mosdepth/test.mosdepth.global.dist.txt - md5sum: 2a1de1b0ecc361a21cd296ec4e1efd6a - - path: ./output/mosdepth/test.regions.bed.gz - md5sum: 347f877700d1dc42c95157199eff25d5 - - path: ./output/mosdepth/test.regions.bed.gz.csi - md5sum: ed5fbf46e3bdcbf60094df295bc40356 - - path: ./output/mosdepth/test.mosdepth.region.dist.txt - md5sum: 295564628113d2ec0ca34d7f661cfea8 - - path: ./output/mosdepth/test.mosdepth.summary.txt - md5sum: b07817412fd17819c14541e63bc4926c + - path: output/mosdepth/test.mosdepth.global.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.summary.txt + md5sum: 4f0d231060cbde4efdd673863bd2fb59 + - path: output/mosdepth/test.per-base.bed.gz + md5sum: bc1df47d46f818fee5275975925d769a + - path: output/mosdepth/test.per-base.bed.gz.csi + md5sum: 9e649ac749ff6c6073bef5ab63e8aaa4 + +- name: mosdepth test_mosdepth_cram_bed + command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_cram_bed -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config + tags: + - mosdepth + files: + - path: output/mosdepth/test.mosdepth.global.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.region.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.summary.txt + md5sum: 96c037f769974b904beb53edc4f56d82 + - path: output/mosdepth/test.per-base.bed.gz + md5sum: bc1df47d46f818fee5275975925d769a + - path: output/mosdepth/test.per-base.bed.gz.csi + md5sum: 9e649ac749ff6c6073bef5ab63e8aaa4 + - path: output/mosdepth/test.regions.bed.gz + md5sum: 5d398caf7171ec4406278e2add3009ae + - path: output/mosdepth/test.regions.bed.gz.csi + md5sum: 47669cfe41f3e222e74d81e1b1be191f + +- name: mosdepth test_mosdepth_window + command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_window -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config + tags: + - mosdepth + files: + - path: output/mosdepth/test.mosdepth.global.dist.txt + md5sum: e82e90c7d508a135b5a8a7cd6933452e + - path: output/mosdepth/test.mosdepth.region.dist.txt + md5sum: 39e0e707ec32feb5176fd20a95f1f468 + - path: output/mosdepth/test.mosdepth.summary.txt + md5sum: 96c037f769974b904beb53edc4f56d82 + - path: output/mosdepth/test.per-base.bed.gz + md5sum: bc1df47d46f818fee5275975925d769a + - path: output/mosdepth/test.per-base.bed.gz.csi + md5sum: 9e649ac749ff6c6073bef5ab63e8aaa4 + - path: output/mosdepth/test.regions.bed.gz + md5sum: f02e2cb49cc050e13d76942d6960827a + - path: output/mosdepth/test.regions.bed.gz.csi + md5sum: 257d67678136963d9dd904330079609d + +- name: mosdepth test_mosdepth_fail + command: nextflow run ./tests/modules/mosdepth -entry test_mosdepth_fail -c ./tests/config/nextflow.config -c ./tests/modules/mosdepth/nextflow.config + tags: + - mosdepth + exit_code: 1