Skip to content

Commit

Permalink
Move process config into pipeline code
Browse files Browse the repository at this point in the history
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
  • Loading branch information
bentsherman committed Oct 5, 2023
1 parent 5047998 commit 870769b
Show file tree
Hide file tree
Showing 11 changed files with 296 additions and 335 deletions.
320 changes: 0 additions & 320 deletions conf/modules.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,323 +23,3 @@ process {
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

//
// General alignment options
//

if (!params.skip_alignment) {
process {
withName: 'NFCORE_RNASEQ:RNASEQ:.*:BAM_SORT_STATS_SAMTOOLS:BAM_STATS_SAMTOOLS:.*' {
ext.prefix = { "${meta.id}.sorted.bam" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/samtools_stats" },
mode: params.publish_dir_mode,
pattern: "*.{stats,flagstat,idxstats}"
]
}

withName: 'NFCORE_RNASEQ:RNASEQ:.*:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_SORT' {
ext.prefix = { "${meta.id}.sorted" }
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: "*.bam",
enabled: ( ['star_salmon','hisat2'].contains(params.aligner) &&
( params.save_align_intermeds ||
( !params.with_umi && params.skip_markduplicates )
)
) || params.save_align_intermeds || params.skip_markduplicates
]
}

withName: 'NFCORE_RNASEQ:RNASEQ:.*:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_INDEX' {
ext.args = params.bam_csi_index ? '-c' : ''
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: "*.{bai,csi}",
enabled: ( ['star_salmon','hisat2'].contains(params.aligner) &&
( params.save_align_intermeds ||
( !params.with_umi && params.skip_markduplicates )
)
) || params.save_align_intermeds || params.skip_markduplicates
]
}
}

if (!params.skip_markduplicates && !params.with_umi) {
process {
withName: '.*:BAM_MARKDUPLICATES_PICARD:BAM_STATS_SAMTOOLS:.*' {
ext.prefix = { "${meta.id}.markdup.sorted.bam" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/samtools_stats" },
mode: params.publish_dir_mode,
pattern: '*.{stats,flagstat,idxstats}'
]
}
}
}

if (params.with_umi && ['star_salmon','hisat2'].contains(params.aligner)) {
process {
withName: '.*:BAM_DEDUP_STATS_SAMTOOLS_UMITOOLS_GENOME:UMITOOLS_DEDUP' {
ext.args = { [
meta.single_end ? '' : '--unpaired-reads=discard --chimeric-pairs=discard',
params.umitools_grouping_method ? "--method='${params.umitools_grouping_method}'" : '',
params.umitools_umi_separator ? "--umi-separator='${params.umitools_umi_separator}'" : ''
].join(' ').trim() }
ext.prefix = { "${meta.id}.umi_dedup.sorted" }
publishDir = [
[
path: { "${params.outdir}/${params.aligner}/umitools" },
mode: params.publish_dir_mode,
pattern: '*.tsv'
],
[
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: '*.bam',
enabled: (
params.save_align_intermeds ||
params.with_umi ||
params.save_umi_intermeds
)
]
]
}

withName: '.*:BAM_DEDUP_STATS_SAMTOOLS_UMITOOLS_GENOME:SAMTOOLS_INDEX' {
ext.args = params.bam_csi_index ? '-c' : ''
ext.prefix = { "${meta.id}.umi_dedup.sorted" }
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: '*.{bai,csi}',
enabled: (
params.save_align_intermeds ||
params.with_umi ||
params.save_umi_intermeds
)
]
}

withName: '.*:BAM_DEDUP_STATS_SAMTOOLS_UMITOOLS_GENOME:BAM_STATS_SAMTOOLS:.*' {
ext.prefix = { "${meta.id}.umi_dedup.sorted.bam" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/samtools_stats" },
mode: params.publish_dir_mode,
pattern: '*.{stats,flagstat,idxstats}'
]
}
}
}

if (!params.skip_bigwig) {
process {
withName: '.*:BEDGRAPH_BEDCLIP_BEDGRAPHTOBIGWIG_FORWARD:UCSC_BEDCLIP' {
ext.prefix = { "${meta.id}.clip.forward" }
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
enabled: false
]
}

withName: '.*:BEDGRAPH_BEDCLIP_BEDGRAPHTOBIGWIG_FORWARD:UCSC_BEDGRAPHTOBIGWIG' {
ext.prefix = { "${meta.id}.forward" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/bigwig" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

withName: '.*:BEDGRAPH_BEDCLIP_BEDGRAPHTOBIGWIG_REVERSE:UCSC_BEDCLIP' {
ext.prefix = { "${meta.id}.clip.reverse" }
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
enabled: false
]
}

withName: '.*:BEDGRAPH_BEDCLIP_BEDGRAPHTOBIGWIG_REVERSE:UCSC_BEDGRAPHTOBIGWIG' {
ext.prefix = { "${meta.id}.reverse" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/bigwig" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}
}
}
}

//
// STAR Salmon alignment options
//

if (!params.skip_alignment && params.aligner == 'star_salmon') {
process {
withName: '.*:QUANTIFY_STAR_SALMON:SALMON_QUANT' {
ext.args = params.extra_salmon_quant_args ?: ''
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') || filename.endsWith('_meta_info.json') ? null : filename }
]
}

withName: '.*:QUANTIFY_STAR_SALMON:SALMON_TX2GENE' {
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

withName: '.*:QUANTIFY_STAR_SALMON:SALMON_TXIMPORT' {
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

withName: '.*:QUANTIFY_STAR_SALMON:SALMON_SE_.*' {
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}
}

if (params.with_umi) {
process {
withName: 'NFCORE_RNASEQ:RNASEQ:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_SORT' {
ext.prefix = { "${meta.id}.transcriptome.sorted" }
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: '*.bam',
enabled: (
params.save_align_intermeds ||
params.save_umi_intermeds
)
]
}

withName: 'NFCORE_RNASEQ:RNASEQ:BAM_SORT_STATS_SAMTOOLS:SAMTOOLS_INDEX' {
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: '*.bai',
enabled: (
params.save_align_intermeds ||
params.save_umi_intermeds
)
]
}

withName: 'NFCORE_RNASEQ:RNASEQ:BAM_SORT_STATS_SAMTOOLS:BAM_STATS_SAMTOOLS:.*' {
ext.prefix = { "${meta.id}.transcriptome.sorted.bam" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/samtools_stats" },
mode: params.publish_dir_mode,
pattern: '*.{stats,flagstat,idxstats}',
enabled: (
params.save_align_intermeds ||
params.save_umi_intermeds
)
]
}

withName: '.*:BAM_DEDUP_STATS_SAMTOOLS_UMITOOLS_TRANSCRIPTOME:UMITOOLS_DEDUP' {
ext.args = { [
meta.single_end ? '' : '--unpaired-reads=discard --chimeric-pairs=discard',
params.umitools_grouping_method ? "--method='${params.umitools_grouping_method}'" : '',
params.umitools_umi_separator ? "--umi-separator='${params.umitools_umi_separator}'" : ''
].join(' ').trim() }
ext.prefix = { "${meta.id}.umi_dedup.transcriptome.sorted" }
publishDir = [
[
path: { "${params.outdir}/${params.aligner}/umitools" },
mode: params.publish_dir_mode,
pattern: '*.tsv'
],
[
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: '*.bam',
enabled: (
params.save_align_intermeds ||
params.save_umi_intermeds
)
]
]
}

withName: '.*:BAM_DEDUP_STATS_SAMTOOLS_UMITOOLS_TRANSCRIPTOME:SAMTOOLS_INDEX' {
publishDir = [
path: { "${params.outdir}/${params.aligner}" },
mode: params.publish_dir_mode,
pattern: '*.bai',
enabled: (
params.save_align_intermeds ||
params.save_umi_intermeds
)
]
}

withName: '.*:BAM_DEDUP_STATS_SAMTOOLS_UMITOOLS_TRANSCRIPTOME:BAM_STATS_SAMTOOLS:.*' {
ext.prefix = { "${meta.id}.umi_dedup.transcriptome.sorted.bam" }
publishDir = [
path: { "${params.outdir}/${params.aligner}/samtools_stats" },
mode: params.publish_dir_mode,
pattern: '*.{stats,flagstat,idxstats}'
]
}
}
}
}

//
// Salmon pseudo-alignment options
//

if (!params.skip_pseudo_alignment && params.pseudo_aligner == 'salmon') {
process {
withName: '.*:QUANTIFY_SALMON:SALMON_QUANT' {
ext.args = params.extra_salmon_quant_args ?: ''
publishDir = [
path: { "${params.outdir}/${params.pseudo_aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') || filename.endsWith('_meta_info.json') ? null : filename }
]
}

withName: '.*:QUANTIFY_SALMON:SALMON_TX2GENE' {
publishDir = [
path: { "${params.outdir}/${params.pseudo_aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

withName: '.*:QUANTIFY_SALMON:SALMON_TXIMPORT' {
publishDir = [
path: { "${params.outdir}/${params.pseudo_aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}

withName: '.*:QUANTIFY_SALMON:SALMON_SE_.*' {
publishDir = [
path: { "${params.outdir}/${params.pseudo_aligner}" },
mode: params.publish_dir_mode,
saveAs: { filename -> filename.equals('versions.yml') ? null : filename }
]
}
}
}
41 changes: 37 additions & 4 deletions subworkflows/local/align_star.nf
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,18 @@ workflow ALIGN_STAR {
].flatten().unique(false).join(' ').trim()
align_publish_dir = [
[
path: { "${params.outdir}/${params.aligner}/log" },
path: "${params.outdir}/${params.aligner}/log",
mode: params.publish_dir_mode,
pattern: '*.{out,tab}'
],
[
path: { "${params.outdir}/${params.aligner}" },
path: "${params.outdir}/${params.aligner}",
mode: params.publish_dir_mode,
pattern: '*.bam',
enabled: params.save_align_intermeds
],
[
path: { "${params.outdir}/${params.aligner}/unmapped" },
path: "${params.outdir}/${params.aligner}/unmapped",
mode: params.publish_dir_mode,
pattern: '*.fastq.gz',
enabled: params.save_unaligned
Expand Down Expand Up @@ -96,7 +96,40 @@ workflow ALIGN_STAR {
//
// Sort, index BAM file and run samtools stats, flagstat and idxstats
//
BAM_SORT_STATS_SAMTOOLS ( ch_orig_bam, fasta )
sort_ext_prefix = { "${meta.id}.sorted" }
sort_publish_dir = [
path: "${params.outdir}/${params.aligner}",
mode: params.publish_dir_mode,
pattern: "*.bam",
enabled: ( !params.with_umi && params.skip_markduplicates ) ||
params.save_align_intermeds ||
params.skip_markduplicates
]
index_ext_args = params.bam_csi_index ? '-c' : ''
index_publish_dir = [
path: "${params.outdir}/${params.aligner}",
mode: params.publish_dir_mode,
pattern: "*.{bai,csi}",
enabled: ( !params.with_umi && params.skip_markduplicates ) ||
params.save_align_intermeds ||
params.skip_markduplicates
]
stats_ext_prefix = { "${meta.id}.sorted.bam" }
stats_publish_dir = [
path: "${params.outdir}/${params.aligner}/samtools_stats",
mode: params.publish_dir_mode,
pattern: "*.{stats,flagstat,idxstats}"
]
BAM_SORT_STATS_SAMTOOLS (
ch_orig_bam,
fasta,
sort_ext_prefix,
sort_publish_dir,
index_ext_args,
index_publish_dir,
stats_ext_prefix,
stats_publish_dir
)
ch_versions = ch_versions.mix(BAM_SORT_STATS_SAMTOOLS.out.versions)

emit:
Expand Down
Loading

0 comments on commit 870769b

Please sign in to comment.