Conditional execution of processes

806 views
Skip to first unread message

pmca

unread,
Apr 12, 2017, 7:19:06 AM4/12/17
to Nextflow
Hi,

is there any way to tell NextFlow to just execute a process if the output file doesn't exist, otherwise skip that process.
I thought this was a native feature of NF but couldn't find anything in the docs and the following code is giving me a syntax error saying Unknown variable 'file' :

process fastqc {

 publishDir
"fastqc/${name}", mode: 'move',

 input
:
 
set val(name), file(reads) from reads

 output
:
 file
"*_fastqc.{zip,html}" into fastqc_results

 script
:
 
if (!file) {
   
"""
   fastqc
-q $reads
   """

 
} else {
   log
.warn "File already exists: ${file}"
 
}
}

Thanks,
Pedro

Phil Ewels

unread,
Apr 12, 2017, 7:52:44 AM4/12/17
to next...@googlegroups.com
Hi Pedro,

You don't have any variables here called file - you're typing the output as a file type, but not defining any variables of that name.

Also, as every nextflow process executes in its own work directory, it will never already exist. What's your use case here? If you're trying to skip completed processes on a pipeline rerun you can just use -resume

Phil
--
You received this message because you are subscribed to the Google Groups "Nextflow" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nextflow+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/nextflow.
For more options, visit https://groups.google.com/d/optout.

pmca

unread,
Apr 12, 2017, 8:00:49 AM4/12/17
to Nextflow
Hi Phil,

thanks for your reply. The intention would be to skip any process that already has an output during a rerun. I guess -resume was indeed what I was looking for. 

Best,
Pedro

Phil Ewels

unread,
Apr 12, 2017, 8:11:03 AM4/12/17
to next...@googlegroups.com
Great! Yes in that case, no special logic is required.

Phil
Reply all
Reply to author
Forward
0 new messages