diff --git a/subworkflows/nf-core/bam_stats_samtools/main.nf b/subworkflows/nf-core/bam_stats_samtools/main.nf index 463ec99d..188894a2 100644 --- a/subworkflows/nf-core/bam_stats_samtools/main.nf +++ b/subworkflows/nf-core/bam_stats_samtools/main.nf @@ -2,26 +2,25 @@ // Run SAMtools stats, flagstat and idxstats // -params.options = [:] - -include { SAMTOOLS_STATS } from '../../../modules/samtools/stats/main' addParams( options: params.options ) -include { SAMTOOLS_IDXSTATS } from '../../../modules/samtools/idxstats/main' addParams( options: params.options ) -include { SAMTOOLS_FLAGSTAT } from '../../../modules/samtools/flagstat/main' addParams( options: params.options ) +include { SAMTOOLS_STATS } from '../../../modules/samtools/stats/main' +include { SAMTOOLS_IDXSTATS } from '../../../modules/samtools/idxstats/main' +include { SAMTOOLS_FLAGSTAT } from '../../../modules/samtools/flagstat/main' workflow BAM_STATS_SAMTOOLS { take: - ch_bam_bai // channel: [ val(meta), [ bam ], [bai/csi] ] + bam_bai // channel: [ val(meta), [ bam/cram ], [bai/csi] ] + fasta // channel: [ fasta ] main: ch_versions = Channel.empty() - SAMTOOLS_STATS ( ch_bam_bai, [] ) + SAMTOOLS_STATS ( bam_bai, fasta ) ch_versions = ch_versions.mix(SAMTOOLS_STATS.out.versions.first()) - SAMTOOLS_FLAGSTAT ( ch_bam_bai ) + SAMTOOLS_FLAGSTAT ( bam_bai ) ch_versions = ch_versions.mix(SAMTOOLS_FLAGSTAT.out.versions.first()) - SAMTOOLS_IDXSTATS ( ch_bam_bai ) + SAMTOOLS_IDXSTATS ( bam_bai ) ch_versions = ch_versions.mix(SAMTOOLS_IDXSTATS.out.versions.first()) emit: diff --git a/subworkflows/nf-core/bam_stats_samtools/meta.yml b/subworkflows/nf-core/bam_stats_samtools/meta.yml index 38fe8647..e87822df 100644 --- a/subworkflows/nf-core/bam_stats_samtools/meta.yml +++ b/subworkflows/nf-core/bam_stats_samtools/meta.yml @@ -1,4 +1,4 @@ -name: samtools_stats +name: bam_stats_samtools description: Produces comprehensive statistics from SAM/BAM/CRAM file keywords: - statistics @@ -24,6 +24,10 @@ input: type: file description: Index for BAM/CRAM/SAM file pattern: "*.{bai,crai,sai}" + - fasta: + type: file + description: Reference genome fasta file + pattern: "*.{fasta,fa}" # TODO Update when we decide on a standard for subworkflow docs output: - meta: @@ -35,6 +39,14 @@ output: type: file description: File containing samtools stats output pattern: "*.{stats}" + - flagstat: + type: file + description: File containing samtools flagstat output + pattern: "*.{flagstat}" + - idxstats: + type: file + description: File containing samtools idxstats output + pattern: "*.{idxstats}" - versions: type: file description: File containing software versions diff --git a/subworkflows/nf-core/bam_stats_samtools/nextflow.config b/subworkflows/nf-core/bam_stats_samtools/nextflow.config deleted file mode 100644 index 2fd55747..00000000 --- a/subworkflows/nf-core/bam_stats_samtools/nextflow.config +++ /dev/null @@ -1 +0,0 @@ -params.options = [:] diff --git a/tests/config/pytest_modules.yml b/tests/config/pytest_modules.yml index 4040cfdd..16156bbf 100644 --- a/tests/config/pytest_modules.yml +++ b/tests/config/pytest_modules.yml @@ -2355,6 +2355,10 @@ subread/featurecounts: - modules/subread/featurecounts/** - tests/modules/subread/featurecounts/** +subworkflows/bam_stats_samtools: + - subworkflows/nf-core/bam_stats_samtools/** + - tests/subworkflows/nf-core/bam_stats_samtools/** + svdb/merge: - modules/svdb/merge/** - tests/modules/svdb/merge/** diff --git a/tests/subworkflows/nf-core/bam_stats_samtools/main.nf b/tests/subworkflows/nf-core/bam_stats_samtools/main.nf index a390c3eb..721972c6 100644 --- a/tests/subworkflows/nf-core/bam_stats_samtools/main.nf +++ b/tests/subworkflows/nf-core/bam_stats_samtools/main.nf @@ -2,22 +2,27 @@ nextflow.enable.dsl = 2 -include { BAM_STATS_SAMTOOLS } from '../../../../subworkflows/nf-core/bam_stats_samtools/main' addParams( options: [:] ) +include { BAM_STATS_SAMTOOLS as BAM_STATS_SAMTOOLS_SINGLE_END } from '../../../../subworkflows/nf-core/bam_stats_samtools/main' +include { BAM_STATS_SAMTOOLS as BAM_STATS_SAMTOOLS_PAIRED_END } from '../../../../subworkflows/nf-core/bam_stats_samtools/main' workflow test_bam_stats_samtools_single_end { - input = [ [ id:'test', single_end:false ], // meta map - file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam'], checkIfExists: true), - file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam_bai'], checkIfExists: true) + input = [ + [ id:'test', single_end:true ], // meta map + file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam'], checkIfExists: true), + file(params.test_data['sarscov2']['illumina']['test_single_end_sorted_bam_bai'], checkIfExists: true) ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - BAM_STATS_SAMTOOLS ( input ) + BAM_STATS_SAMTOOLS_SINGLE_END ( input, fasta ) } workflow test_bam_stats_samtools_paired_end { - input = [ [ id:'test', single_end:false ], // meta map - 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:false ], // meta map + 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) ] + fasta = file(params.test_data['sarscov2']['genome']['genome_fasta'], checkIfExists: true) - BAM_STATS_SAMTOOLS ( input ) + BAM_STATS_SAMTOOLS_PAIRED_END ( input, fasta ) } diff --git a/tests/subworkflows/nf-core/bam_stats_samtools/nextflow.config b/tests/subworkflows/nf-core/bam_stats_samtools/nextflow.config new file mode 100644 index 00000000..3a1c4fc8 --- /dev/null +++ b/tests/subworkflows/nf-core/bam_stats_samtools/nextflow.config @@ -0,0 +1,13 @@ +process { + + publishDir = { "${params.outdir}/${task.process.tokenize(':')[-1].tokenize('_')[0].toLowerCase()}" } + + withName: '.*:BAM_STATS_SAMTOOLS_SINGLE_END:.*' { + ext.prefix = { "${meta.id}.single_end.sorted.bam" } + } + + withName: '.*:BAM_STATS_SAMTOOLS_PAIRED_END:.*' { + ext.prefix = { "${meta.id}.paired_end.sorted.bam" } + } + +} \ No newline at end of file diff --git a/tests/subworkflows/nf-core/bam_stats_samtools/test.yml b/tests/subworkflows/nf-core/bam_stats_samtools/test.yml index 2b2e45d1..5c029590 100644 --- a/tests/subworkflows/nf-core/bam_stats_samtools/test.yml +++ b/tests/subworkflows/nf-core/bam_stats_samtools/test.yml @@ -1,13 +1,14 @@ - name: bam stats samtools single-end - command: nextflow run ./tests/subworkflows/nf-core/bam_stats_samtools -entry test_bam_stats_samtools_single_end -c tests/config/nextflow.config + command: nextflow run ./tests/subworkflows/nf-core/bam_stats_samtools -entry test_bam_stats_samtools_single_end -c ./tests/config/nextflow.config -c ./tests/subworkflows/nf-core/bam_stats_samtools/nextflow.config tags: - subworkflows - # - subworkflows/bam_stats_samtools + - subworkflows/bam_stats_samtools + - bam_stats_samtools # Modules - # - samtools - # - samtools/stats - # - samtools/idxstats - # - samtools/flagstat + - samtools + - samtools/stats + - samtools/idxstats + - samtools/flagstat files: - path: ./output/samtools/test.single_end.sorted.bam.flagstat md5sum: 2191911d72575a2358b08b1df64ccb53 @@ -16,15 +17,16 @@ - path: ./output/samtools/test.single_end.sorted.bam.stats - name: bam stats samtools paired-end - command: nextflow run ./tests/subworkflows/nf-core/bam_stats_samtools -entry test_bam_stats_samtools_paired_end -c tests/config/nextflow.config + command: nextflow run ./tests/subworkflows/nf-core/bam_stats_samtools -entry test_bam_stats_samtools_paired_end -c ./tests/config/nextflow.config -c ./tests/subworkflows/nf-core/bam_stats_samtools/nextflow.config tags: - subworkflows - # - subworkflows/bam_stats_samtools - # # Modules - # - samtools - # - samtools/stats - # - samtools/idxstats - # - samtools/flagstat + - subworkflows/bam_stats_samtools + - bam_stats_samtools + # Modules + - samtools + - samtools/stats + - samtools/idxstats + - samtools/flagstat files: - path: ./output/samtools/test.paired_end.sorted.bam.flagstat md5sum: 4f7ffd1e6a5e85524d443209ac97d783