#!/usr/bin/env nextflow
nextflow.enable.dsl=2
Basepath = System.getProperty("user.dir")
// touches files $Basepath/test/a, $Basepath/test/b, $Basepath/test/c
process Process1 {
output:
val start
script:
start = System.currentTimeMillis()
print("starting process 1")
"""
bash $Basepath/testscript.sh -p $Basepath
"""
}
// prints if channel passed checks and was created with Process1
process Process2 {
input:
val fromProcess1
val fromChannel
exec:
print("processed $fromChannel")
}
workflow {
Process1()
Channel
.from(['a', 'b'], ['c', 'd'])
.branch{
// Check wheter all samples exist with Function1
// and emit samples with passed tests as out_ch.passed
failed_first: (Function1(it[0]) == 1);
return 1
failed_second: (Function1(it[1]) == 1);
return 1
passed: true
return it
}
.set{ out_ch}
Process2(Process1.out, out_ch.passed)
}
// tests wheter a file test/$value exists for the given value
def Function1(value){
fileslist = new FileNameByRegexFinder().getFileNames("test/", value)
if (fileslist.size() == 0){
print("failed $value")
return 1
}
return 0
}
testscript.sh
while getopts p: flag
do
case "${flag}" in
p) Basepath=${OPTARG};;
esac
done
mkdir -p $Basepath/test
sleep 3
touch $Basepath/test/a
touch $Basepath/test/b
touch $Basepath/test/c