Skip to content

Commit 06c2e8e

Browse files
committed
Configure worksteps instead of an option for each tool
1 parent 52f5f9f commit 06c2e8e

File tree

2 files changed

+44
-24
lines changed

2 files changed

+44
-24
lines changed

main.nf

Lines changed: 43 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ if (!params.project) {
2626
exit 1, 'You need to specify what project to run under, see --help for more information'
2727
}
2828

29-
if (params.run_all) {
30-
params.run_fermikit = true
31-
params.run_manta = true
32-
}
29+
30+
workflowSteps = processWorkflowSteps(params.steps)
3331

3432

3533
startup_message()
@@ -55,7 +53,7 @@ if (!bamindex) {
5553
queue 'core'
5654
time params.short_job
5755

58-
when: params.run_manta == true
56+
when: 'indexbam' in workflowSteps
5957

6058
script:
6159
"""
@@ -81,7 +79,7 @@ process manta {
8179
module 'bioinfo-tools'
8280
module "$params.modules.manta"
8381

84-
when: params.run_manta == true
82+
when: 'manta' in workflowSteps
8583

8684
script:
8785
"""
@@ -134,7 +132,7 @@ if (!params.fastq) {
134132
queue 'core'
135133
time params.short_job
136134

137-
when: params.run_fermikit == true
135+
when: 'fastq' in workflowSteps
138136

139137
script:
140138
"""
@@ -162,7 +160,7 @@ process fermikit {
162160
module "$params.modules.vcftools"
163161
module "$params.modules.tabix"
164162

165-
when: params.run_fermikit == true
163+
when: 'fermikit' in workflowSteps
166164

167165
script:
168166
"""
@@ -183,7 +181,6 @@ process fermikit {
183181
// Collect vcfs and beds into one channel
184182
beds = manta_bed.mix( fermi_bed )
185183
vcfs = manta_vcf.mix( fermi_vcf )
186-
.tap { vcfs_snpeff }
187184

188185

189186
mask_files = [
@@ -220,11 +217,12 @@ process mask_beds {
220217
"""
221218
}
222219

220+
223221
// To make intersect files we need to combine them into one channel with
224222
// toList(). And also figure out if we have one or two files, therefore the
225223
// tap and count_beds.
226224
masked_beds.tap { count_beds_tmp }
227-
.tap { masked_beds_vep }
225+
.tap { masked_beds }
228226
.toList().set { intersect_input }
229227
count_beds_tmp.count().set { count_beds }
230228

@@ -233,7 +231,7 @@ process intersect_files {
233231
set file(bed1), file(bed2) from intersect_input
234232
val nbeds from count_beds
235233
output:
236-
file "combined*.bed"
234+
file "combined*.bed" into intersections
237235

238236
publishDir params.outdir, mode: 'copy'
239237

@@ -265,26 +263,25 @@ process intersect_files {
265263
"""
266264
}
267265

266+
annotate_files = intersections.flatten().mix( masked_beds.tap { masked_beds } )
268267

269-
vep_infiles = masked_beds_vep.mix(vcfs)
270-
271-
// TODO: Figure out running characteristics
272268
process variant_effect_predictor {
273269
input:
274-
file infile from vep_infiles
270+
file infile from annotate_files.tap { annotate_files }
275271
output:
276-
file '*.vep'
272+
file '*.vep' into vep_outfiles
277273

278274
publishDir params.outdir, mode: 'copy'
279275

280-
// We only need one core for this part
281276
executor choose_executor()
282277
queue 'core'
283278
time params.short_job
284279

285280
module 'bioinfo-tools'
286281
module "$params.modules.vep"
287282

283+
when: 'vep' in workflowSteps
284+
288285
script:
289286
"""
290287
infile="$infile"
@@ -300,7 +297,7 @@ process variant_effect_predictor {
300297
esac
301298
302299
variant_effect_predictor.pl \
303-
-i "\$infile" \
300+
-i "\$infile" \
304301
--format "\$format" \
305302
-cache --dir "\$vep_cache" \
306303
-o "\$outfile" \
@@ -322,7 +319,6 @@ process variant_effect_predictor {
322319
"""
323320
}
324321

325-
326322
process snpEff() {
327323
input:
328324
file vcf from vcfs_snpeff
@@ -340,6 +336,8 @@ process snpEff() {
340336
queue 'core'
341337
time params.short_job
342338

339+
when: 'snpeff' in workflowSteps
340+
343341
script:
344342
"""
345343
vcf="$vcf" ## Use bash-semantics for variables
@@ -381,9 +379,9 @@ def usage_message() {
381379
log.info ' Optional'
382380
log.info ' --help Show this message and exit'
383381
log.info ' --fastq Input fastqfile (default is bam but with fq as fileending)'
384-
log.info ' --run_manta Run manta (default)'
385-
log.info ' --run_fermikit Run fermikit'
386-
log.info ' --run_all Run all callers'
382+
log.info ' --steps Specify what steps to run, comma separated:'
383+
log.info ' Callers: manta, fermikit, cnvnator (choose one or many)'
384+
log.info ' Annotation: vep OR snpeff'
387385
log.info ' --long_job Running time for long job (callers, fermi and manta)'
388386
log.info ' --short_job Running time for short jobs (bam indexing and bam2fq)'
389387
log.info ' --outdir Directory where resultfiles are stored'
@@ -402,6 +400,7 @@ def startup_message() {
402400
log.info "Work dir : $workDir"
403401
log.info "Output dir : $params.outdir"
404402
log.info "Project : $params.project"
403+
log.info "Will run : " + workflowSteps.join(", ")
405404
log.info ""
406405
}
407406

@@ -454,3 +453,25 @@ def nextflow_running_as_slurmjob() {
454453
def choose_executor() {
455454
return nextflow_running_as_slurmjob() ? 'local' : 'slurm'
456455
}
456+
457+
def processWorkflowSteps(steps) {
458+
if ( ! steps ) {
459+
return []
460+
}
461+
462+
workflowSteps = steps.split(',').collect { it.trim().toLowerCase() }
463+
464+
if ('vep' in workflowSteps && 'snpeff' in workflowSteps) {
465+
exit 1, 'You can only run one annotator, either "vep" or "snpeff"'
466+
}
467+
468+
if ('manta' in workflowSteps) {
469+
workflowSteps.push( 'indexbam' )
470+
}
471+
472+
if ('fermikit' in workflowSteps) {
473+
workflowSteps.push( 'fastq' )
474+
}
475+
476+
return workflowSteps
477+
}

nextflow.config

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
params {
2+
steps = 'manta,vep' // Change on commandline --steps x,y,z
23
project = "" // Set project or supply on commandline ( --project )
34
outdir = "results"
45

@@ -26,8 +27,6 @@ params {
2627

2728
long_job = '10h' // used for the callers (fermikit & manta)
2829
short_job = '30m' // used for bam indexing and bam2fq
29-
30-
run_manta = true
3130
}
3231

3332
process {

0 commit comments

Comments
 (0)