process createFile {
output: file 'file' into files
exec: new File('file').withWriter{ it.println 'hello world' }
}N E X T F L O W ~ version 0.12.4[warm up] executor > local[54/d1583d] Submitted process > createFile (1)Error executing process > 'createFile (1)'
Caused by: Missing output file(s): 'file' expected by process: createFile (1)
Source block: new File('file').withWriter{ it.println 'hello world' }process createFile {
output: file 'file' into files
script: ''' #!/usr/bin/env groovy new File('file').withWriter{ it.println 'hello world' } '''
}
as you can see here, script/exec are interchangable and optional (if I understood correctly). So you may just leave it out.
Hence any code outside of the ''' ''' block is actually running inside the Nextflow process. Anything inside the ''' ''' block is ran as a separate process, either on your local system or on a compute cluser. What nextflow does is it takes the part inside the ''' ''' block and creates a shell script from it behind the scenes (have a look inside the work folder to understand better).
So it really boils down to what you want to do. If you need to create a file before the process starts, you put it outside the whole process {} block, i.e a the top of your nextflow file. If you want to create a file as part of your process, you put it inside the """ """ block, like in your last example. Note that you don't have to use groovy code in there, it could just as well be "echo "Hello World" > somefile".
process foo {
output:file 'file' into filesexec:
Also note that underlying files are implement as Path objects not Filetask.workDir.resolve('file').text = 'Hello world!'}files.subscribe { println it.text }
Enjoy.
--
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 http://groups.google.com/group/nextflow.
For more options, visit https://groups.google.com/d/optout.