5.12 EXERCISE 3

Try to make the previous pipeline resilient to the failing of a process and store the results in order to skip the process execution when launched again.

First make the process reverseSequence failing by creating a mistake in the command line, then add the directive to the process.

Answer

/*
 * Broken process
 */
 
process reverseSequence {
    tag { "${seq}" }                
    publishDir "output"
    errorStrategy 'ignore'

    input:
    path seq 

    output:
    path "all.rev" 
 
    script:
    """
    cat ${seq} | AAAAAAA '{if (\$1~">") {print \$0} else system("echo " \$0 " |rev")}' > all.rev
    """
}

Write the first workflow using pipes. Nextflow DLS2 allows you to use pipes for connecting channels via input / output.
See the documentation on pipes.

Answer

workflow flow1 {
    take: sequences
    main:
    splitSequences(sequences) | reverseSequence | view()
}