Last active
March 22, 2019 10:23
-
-
Save tdudgeon/8436f11603884906dab5647818e5aa1a to your computer and use it in GitHub Desktop.
Nextflow status reporting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
numbers = 0..10 | |
// Create the log file and write something to it as soon as we can. | |
// The file is located in the workflow directory. | |
File logfile = new File('status.log') | |
logfile << 'MSG Workflow started\n' | |
// This process writes the input to a file that is fed to the second process. | |
// The status message is generated using the process variable named status. | |
process p1 { | |
input: | |
val x from numbers | |
output: | |
file 'foo' into data | |
val status into receiver1 | |
script: | |
status = "MSG $x received by p1\n" | |
""" | |
echo "Number $x" >> foo | |
sleep \$[ ( \$RANDOM % 10 ) + 1 ] | |
""" | |
} | |
// This process generates the status message from the shell script that is executed by means of writing to a file. | |
process p2 { | |
input: | |
file f from data | |
output: | |
file 'status' into receiver2 | |
""" | |
echo $f | |
echo -n "MSG p2 processed " > status | |
cat $f >> status | |
sleep \$[ ( \$RANDOM % 10 ) + 1 ] | |
""" | |
} | |
receiver1.mix(receiver2) | |
.subscribe { | |
// content can be a string or a file Path | |
if (it instanceof java.nio.file.Path) { | |
logfile << it.text | |
} else { | |
logfile << it | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment