Skip to content

Commit

Permalink
please do not emit channels with ch_ prefix - bam_rseqc subworkflows (n…
Browse files Browse the repository at this point in the history
…f-core#4844)

* please do not emit channels with ch_ prefix

* fix tests

* more global cohesion

* code polish

* fix typo
  • Loading branch information
maxulysse authored Feb 6, 2024
1 parent 7157328 commit 4d4041f
Show file tree
Hide file tree
Showing 4 changed files with 159 additions and 154 deletions.
207 changes: 106 additions & 101 deletions subworkflows/nf-core/bam_rseqc/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,168 +13,173 @@ include { RSEQC_TIN } from '../../../modules/nf-core/rseqc/tin/ma

workflow BAM_RSEQC {
take:
ch_bam_bai // channel: [ val(meta), [ bam, bai ] ]
ch_bed // file: /path/to/genome.bed
bam_bai // channel: [ val(meta), [ bam, bai ] ]
bed // channel: [ genome.bed ]
rseqc_modules // list: rseqc modules to run

main:

ch_versions = Channel.empty()
bam = bam_bai.map{ [ it[0], it[1] ] }

ch_bam_bai
.map { [ it[0], it[1] ] }
.set { ch_bam }
versions = Channel.empty()

//
// Run RSeQC bam_stat.py
//
ch_bamstat = Channel.empty()
bamstat_txt = Channel.empty()

if ('bam_stat' in rseqc_modules) {
RSEQC_BAMSTAT ( ch_bam )
ch_bamstat = RSEQC_BAMSTAT.out.txt
ch_versions = ch_versions.mix(RSEQC_BAMSTAT.out.versions.first())
RSEQC_BAMSTAT(bam)
bamstat_txt = RSEQC_BAMSTAT.out.txt
versions = versions.mix(RSEQC_BAMSTAT.out.versions.first())
}

//
// Run RSeQC inner_distance.py
//
ch_innerdistance = Channel.empty()
ch_innerdistance_distance = Channel.empty()
ch_innerdistance_freq = Channel.empty()
ch_innerdistance_mean = Channel.empty()
ch_innerdistance_pdf = Channel.empty()
ch_innerdistance_rscript = Channel.empty()
innerdistance_all = Channel.empty()
innerdistance_distance = Channel.empty()
innerdistance_freq = Channel.empty()
innerdistance_mean = Channel.empty()
innerdistance_pdf = Channel.empty()
innerdistance_rscript = Channel.empty()

if ('inner_distance' in rseqc_modules) {
RSEQC_INNERDISTANCE ( ch_bam, ch_bed )
ch_innerdistance_distance = RSEQC_INNERDISTANCE.out.distance
ch_innerdistance_freq = RSEQC_INNERDISTANCE.out.freq
ch_innerdistance_mean = RSEQC_INNERDISTANCE.out.mean
ch_innerdistance_pdf = RSEQC_INNERDISTANCE.out.pdf
ch_innerdistance_rscript = RSEQC_INNERDISTANCE.out.rscript
ch_innerdistance = ch_innerdistance_distance.mix(ch_innerdistance_freq, ch_innerdistance_mean, ch_innerdistance_pdf, ch_innerdistance_rscript)
ch_versions = ch_versions.mix(RSEQC_INNERDISTANCE.out.versions.first())
RSEQC_INNERDISTANCE(bam, bed)
innerdistance_distance = RSEQC_INNERDISTANCE.out.distance
innerdistance_freq = RSEQC_INNERDISTANCE.out.freq
innerdistance_mean = RSEQC_INNERDISTANCE.out.mean
innerdistance_pdf = RSEQC_INNERDISTANCE.out.pdf
innerdistance_rscript = RSEQC_INNERDISTANCE.out.rscript
innerdistance_all = innerdistance_distance.mix(innerdistance_freq, innerdistance_mean, innerdistance_pdf, innerdistance_rscript)
versions = versions.mix(RSEQC_INNERDISTANCE.out.versions.first())
}

//
// Run RSeQC infer_experiment.py
//
ch_inferexperiment = Channel.empty()
inferexperiment_txt = Channel.empty()
if ('infer_experiment' in rseqc_modules) {
RSEQC_INFEREXPERIMENT ( ch_bam, ch_bed )
ch_inferexperiment = RSEQC_INFEREXPERIMENT.out.txt
ch_versions = ch_versions.mix(RSEQC_INFEREXPERIMENT.out.versions.first())
RSEQC_INFEREXPERIMENT(bam, bed)
inferexperiment_txt = RSEQC_INFEREXPERIMENT.out.txt
versions = versions.mix(RSEQC_INFEREXPERIMENT.out.versions.first())
}

//
// Run RSeQC junction_annotation.py
//
ch_junctionannotation = Channel.empty()
ch_junctionannotation_bed = Channel.empty()
ch_junctionannotation_interact_bed = Channel.empty()
ch_junctionannotation_xls = Channel.empty()
ch_junctionannotation_pdf = Channel.empty()
ch_junctionannotation_events_pdf = Channel.empty()
ch_junctionannotation_rscript = Channel.empty()
ch_junctionannotation_log = Channel.empty()
junctionannotation_all = Channel.empty()
junctionannotation_bed = Channel.empty()
junctionannotation_interact_bed = Channel.empty()
junctionannotation_xls = Channel.empty()
junctionannotation_pdf = Channel.empty()
junctionannotation_events_pdf = Channel.empty()
junctionannotation_rscript = Channel.empty()
junctionannotation_log = Channel.empty()

if ('junction_annotation' in rseqc_modules) {
RSEQC_JUNCTIONANNOTATION ( ch_bam, ch_bed )
ch_junctionannotation_bed = RSEQC_JUNCTIONANNOTATION.out.bed
ch_junctionannotation_interact_bed = RSEQC_JUNCTIONANNOTATION.out.interact_bed
ch_junctionannotation_xls = RSEQC_JUNCTIONANNOTATION.out.xls
ch_junctionannotation_pdf = RSEQC_JUNCTIONANNOTATION.out.pdf
ch_junctionannotation_events_pdf = RSEQC_JUNCTIONANNOTATION.out.events_pdf
ch_junctionannotation_rscript = RSEQC_JUNCTIONANNOTATION.out.rscript
ch_junctionannotation_log = RSEQC_JUNCTIONANNOTATION.out.log
ch_junctionannotation = ch_junctionannotation_bed.mix(ch_junctionannotation_interact_bed, ch_junctionannotation_xls, ch_junctionannotation_pdf, ch_junctionannotation_events_pdf, ch_junctionannotation_rscript, ch_junctionannotation_log)
ch_versions = ch_versions.mix(RSEQC_JUNCTIONANNOTATION.out.versions.first())
RSEQC_JUNCTIONANNOTATION(bam, bed)
junctionannotation_bed = RSEQC_JUNCTIONANNOTATION.out.bed
junctionannotation_interact_bed = RSEQC_JUNCTIONANNOTATION.out.interact_bed
junctionannotation_xls = RSEQC_JUNCTIONANNOTATION.out.xls
junctionannotation_pdf = RSEQC_JUNCTIONANNOTATION.out.pdf
junctionannotation_events_pdf = RSEQC_JUNCTIONANNOTATION.out.events_pdf
junctionannotation_rscript = RSEQC_JUNCTIONANNOTATION.out.rscript
junctionannotation_log = RSEQC_JUNCTIONANNOTATION.out.log
junctionannotation_all = junctionannotation_bed.mix(junctionannotation_interact_bed, junctionannotation_xls, junctionannotation_pdf, junctionannotation_events_pdf, junctionannotation_rscript, junctionannotation_log)
versions = versions.mix(RSEQC_JUNCTIONANNOTATION.out.versions.first())
}

//
// Run RSeQC junction_saturation.py
//
ch_junctionsaturation = Channel.empty()
ch_junctionsaturation_pdf = Channel.empty()
ch_junctionsaturation_rscript = Channel.empty()
junctionsaturation_all = Channel.empty()
junctionsaturation_pdf = Channel.empty()
junctionsaturation_rscript = Channel.empty()

if ('junction_saturation' in rseqc_modules) {
RSEQC_JUNCTIONSATURATION ( ch_bam, ch_bed )
ch_junctionsaturation_pdf = RSEQC_JUNCTIONSATURATION.out.pdf
ch_junctionsaturation_rscript = RSEQC_JUNCTIONSATURATION.out.rscript
ch_junctionsaturation = ch_junctionsaturation_pdf.mix(ch_junctionsaturation_rscript)
ch_versions = ch_versions.mix(RSEQC_JUNCTIONSATURATION.out.versions.first())
RSEQC_JUNCTIONSATURATION(bam, bed)
junctionsaturation_pdf = RSEQC_JUNCTIONSATURATION.out.pdf
junctionsaturation_rscript = RSEQC_JUNCTIONSATURATION.out.rscript
junctionsaturation_all = junctionsaturation_pdf.mix(junctionsaturation_rscript)
versions = versions.mix(RSEQC_JUNCTIONSATURATION.out.versions.first())
}

//
// Run RSeQC read_distribution.py
//
ch_readdistribution = Channel.empty()
readdistribution_txt = Channel.empty()

if ('read_distribution' in rseqc_modules) {
RSEQC_READDISTRIBUTION ( ch_bam, ch_bed )
ch_readdistribution = RSEQC_READDISTRIBUTION.out.txt
ch_versions = ch_versions.mix(RSEQC_READDISTRIBUTION.out.versions.first())
RSEQC_READDISTRIBUTION(bam, bed)
readdistribution_txt = RSEQC_READDISTRIBUTION.out.txt
versions = versions.mix(RSEQC_READDISTRIBUTION.out.versions.first())
}

//
// Run RSeQC read_duplication.py
//
ch_readduplication = Channel.empty()
ch_readduplication_seq_xls = Channel.empty()
ch_readduplication_pos_xls = Channel.empty()
ch_readduplication_pdf = Channel.empty()
ch_readduplication_rscript = Channel.empty()
readduplication_all = Channel.empty()
readduplication_seq_xls = Channel.empty()
readduplication_pos_xls = Channel.empty()
readduplication_pdf = Channel.empty()
readduplication_rscript = Channel.empty()

if ('read_duplication' in rseqc_modules) {
RSEQC_READDUPLICATION ( ch_bam )
ch_readduplication_seq_xls = RSEQC_READDUPLICATION.out.seq_xls
ch_readduplication_pos_xls = RSEQC_READDUPLICATION.out.pos_xls
ch_readduplication_pdf = RSEQC_READDUPLICATION.out.pdf
ch_readduplication_rscript = RSEQC_READDUPLICATION.out.rscript
ch_readduplication = ch_readduplication_seq_xls.mix(ch_readduplication_pos_xls, ch_readduplication_pdf, ch_readduplication_rscript)
ch_versions = ch_versions.mix(RSEQC_READDUPLICATION.out.versions.first())
RSEQC_READDUPLICATION(bam )
readduplication_seq_xls = RSEQC_READDUPLICATION.out.seq_xls
readduplication_pos_xls = RSEQC_READDUPLICATION.out.pos_xls
readduplication_pdf = RSEQC_READDUPLICATION.out.pdf
readduplication_rscript = RSEQC_READDUPLICATION.out.rscript
readduplication_all = readduplication_seq_xls.mix(readduplication_pos_xls, readduplication_pdf, readduplication_rscript)
versions = versions.mix(RSEQC_READDUPLICATION.out.versions.first())
}

//
// Run RSeQC tin.py
//
ch_tin = Channel.empty()
tin_txt = Channel.empty()

if ('tin' in rseqc_modules) {
RSEQC_TIN ( ch_bam_bai, ch_bed )
ch_tin = RSEQC_TIN.out.txt
ch_versions = ch_versions.mix(RSEQC_TIN.out.versions.first())
RSEQC_TIN(bam_bai, bed)
tin_txt = RSEQC_TIN.out.txt
versions = versions.mix(RSEQC_TIN.out.versions.first())
}

emit:
ch_bamstat // channel: [ val(meta), txt ]
bamstat_txt // channel: [ val(meta), txt ]

ch_innerdistance
ch_innerdistance_distance // channel: [ val(meta), txt ]
ch_innerdistance_freq // channel: [ val(meta), txt ]
ch_innerdistance_mean // channel: [ val(meta), txt ]
ch_innerdistance_pdf // channel: [ val(meta), pdf ]
ch_innerdistance_rscript // channel: [ val(meta), r ]
innerdistance_all // channel: [ val(meta), {txt, pdf, r} ]
innerdistance_distance // channel: [ val(meta), txt ]
innerdistance_freq // channel: [ val(meta), txt ]
innerdistance_mean // channel: [ val(meta), txt ]
innerdistance_pdf // channel: [ val(meta), pdf ]
innerdistance_rscript // channel: [ val(meta), r ]

ch_inferexperiment // channel: [ val(meta), txt ]
inferexperiment_txt // channel: [ val(meta), txt ]

ch_junctionannotation
ch_junctionannotation_bed // channel: [ val(meta), bed ]
ch_junctionannotation_interact_bed // channel: [ val(meta), bed ]
ch_junctionannotation_xls // channel: [ val(meta), xls ]
ch_junctionannotation_pdf // channel: [ val(meta), pdf ]
ch_junctionannotation_events_pdf // channel: [ val(meta), pdf ]
ch_junctionannotation_rscript // channel: [ val(meta), r ]
ch_junctionannotation_log // channel: [ val(meta), log ]
junctionannotation_all // channel: [ val(meta), {bed, xls, pdf, r, log} ]
junctionannotation_bed // channel: [ val(meta), bed ]
junctionannotation_interact_bed // channel: [ val(meta), bed ]
junctionannotation_xls // channel: [ val(meta), xls ]
junctionannotation_pdf // channel: [ val(meta), pdf ]
junctionannotation_events_pdf // channel: [ val(meta), pdf ]
junctionannotation_rscript // channel: [ val(meta), r ]
junctionannotation_log // channel: [ val(meta), log ]

ch_junctionsaturation
ch_junctionsaturation_pdf // channel: [ val(meta), pdf ]
ch_junctionsaturation_rscript // channel: [ val(meta), r ]
junctionsaturation_all // channel: [ val(meta), {pdf, r} ]
junctionsaturation_pdf // channel: [ val(meta), pdf ]
junctionsaturation_rscript // channel: [ val(meta), r ]

ch_readdistribution // channel: [ val(meta), txt ]
readdistribution_txt // channel: [ val(meta), txt ]

ch_readduplication
ch_readduplication_seq_xls // channel: [ val(meta), xls ]
ch_readduplication_pos_xls // channel: [ val(meta), xls ]
ch_readduplication_pdf // channel: [ val(meta), pdf ]
ch_readduplication_rscript // channel: [ val(meta), r ]
readduplication_all // channel: [ val(meta), {xls, pdf, r} ]
readduplication_seq_xls // channel: [ val(meta), xls ]
readduplication_pos_xls // channel: [ val(meta), xls ]
readduplication_pdf // channel: [ val(meta), pdf ]
readduplication_rscript // channel: [ val(meta), r ]

ch_tin // channel: [ val(meta), txt ]
tin_txt // channel: [ val(meta), txt ]

versions = ch_versions // channel: [ versions.yml ]
versions // channel: [ versions.yml ]
}
Loading

0 comments on commit 4d4041f

Please sign in to comment.