Skip to content

Instantly share code, notes, and snippets.

@viklund
Created March 22, 2018 10:16
Show Gist options
  • Save viklund/f7e969346bee7c3880627e1a868814e5 to your computer and use it in GitHub Desktop.
Save viklund/f7e969346bee7c3880627e1a868814e5 to your computer and use it in GitHub Desktop.
// Hack nextflow workflow that removes intermediate files generated
// by process A once process B is done with the files
inputA = Channel.from(
[1, file('f1')],
[2, file('f2')],
[3, file('f3')],
[4, file('f4')],
[5, file('f5')])
process A {
tag "$id - $f"
input:
set val(id), file(f) from inputA
output:
set val(id), file("f.${id}.A") into outputA
script: """
FILE=f.${id}.A
echo "A $id" > \$FILE
cat $f >> \$FILE
"""
}
outputA.into { inputB; outputAc }
process B {
tag "$id - $f"
input:
set val(id), file(f) from inputB
output:
set val(id), file("f.${id}.B") into outputB
publishDir "DONE"
script:
"""
FILE=f.${id}.B
echo "B $id" > \$FILE
cat $f >> \$FILE
"""
}
remover_input = outputAc.join( outputB )
process Remover {
tag "$id - $f1 - $f2"
input:
set val(id), file(f1), file(f2) from remover_input
script:
"""
ORIG=\$(readlink "$f1")
unlink "\$ORIG"
"""
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment