These are chat archives for nextflow-io/nextflow

17th
Jun 2016
Rickard Hammarén
@Hammarn
Jun 17 2016 12:44

Hi @pditommaso! I'm trying to add a flag to our pipeline that inactivates some of the steps of the pipeline. So I'm toying around with the when declaration but can't seem to get it to work. Wrote a simple test:

params.sampleLevel = false

process evaluate {

    input:
    file 'input.file' 
    when:
    $params.sampleLevel == true
    script: 
    """
    echo sampleLevel==true
    """
}

But I end up with

Cannot get property 'sampleLevel' on null object
Johan Viklund
@viklund
Jun 17 2016 12:44
put the process in a if instead
if ($params.sampleLevel) { process { ... } }
sorry
if (params.sampleLevel) { process { ... } }
(maybe your version will work without the $)
Phil Ewels
@ewels
Jun 17 2016 12:50
Nice :) On this topic - is it possible to skip a process in that way but still get its output channel to emit files?
I'm thinking eg. of having a trimming step which could be omitted
Or maybe having both fastq and bam files as inputs, but them starting the pipeline at different points
Both entirely hypothetical, was just bouncing the idea around my head this morning ;)
Rickard Hammarén
@Hammarn
Jun 17 2016 12:52

Yeah that works! Thanks! only problem is how to I get it to actuallt run now?

nextflow hello_world.nf -c conf --sampleLevel true
N E X T F L O W  ~  version 0.20.0
Launching hello_world.nf

i.e. I get no process starting

Phil Ewels
@ewels
Jun 17 2016 12:52
@Hammarn - I guess if the process is the final step in the pipeline it doesn't matter? That process will just be skipped?
Johan Viklund
@viklund
Jun 17 2016 12:53
I've done something like that here:
Rickard Hammarén
@Hammarn
Jun 17 2016 12:53
yeah, but I want to be able to get it to run when I want. Otherwise I could just delete it :D
Johan Viklund
@viklund
Jun 17 2016 12:54
I don't get it, if sampleLevel is false it shoudn't run right?
Rickard Hammarén
@Hammarn
Jun 17 2016 12:55
correct, but it should run if it's true
Johan Viklund
@viklund
Jun 17 2016 12:57
yes
Phil Ewels
@ewels
Jun 17 2016 13:00
@Hammarn - so if you set it to true it still doesn't run? Can you post the example code?
Paolo Di Tommaso
@pditommaso
Jun 17 2016 14:22
exactly, you don need $ to escape variables in the whendefinition. That is required only to interpolate strings
Mike Smoot
@mes5k
Jun 17 2016 17:02

@pditommaso I'm seeing some unexpected behavior with errorStrategy = finish. Here's my nextflow.config

process {
  errorStrategy = 'finish'
}

and here's my main.nf

ch = Channel.from(1,2,3)

process first {
    input:
    val time from ch

    output:
    stdout into ch2

    script:
    """
    if [ "${time}" == "2" ]
    then
        exit 1
    fi
    sleep ${time}
    echo ${time}
    """
}

process second {
    input:
    val time from ch2

    script:
    """
    sleep ${time}
    echo ${time}
    """
}

When I run this the 'first' process fails when time value is 2 as expected and I see the error message:

Execution cancelled -- Finishing pending tasks before exit

but then nextflow hangs. I would have expected nextflow to quit after about 3 seconds (the length of the longer of the two good 'first' processes). Is this a bug or am I misunderstanding the 'finish' error strategy?

Paolo Di Tommaso
@pditommaso
Jun 17 2016 17:04
let me try
Mike Smoot
@mes5k
Jun 17 2016 17:08
I just tweaked my script to add a touch ${time}.txt in the 'first' process and I see that 1.txt and 3.txt are being created, but nextflow doesn't quit after 3.txt has been created.
Paolo Di Tommaso
@pditommaso
Jun 17 2016 17:09
yes, something strange let me debug it
Mike Smoot
@mes5k
Jun 17 2016 17:12
cool, no rush. I just wanted to bring it to your attention!
Paolo Di Tommaso
@pditommaso
Jun 17 2016 17:12
thanks!
Paolo Di Tommaso
@pditommaso
Jun 17 2016 17:27
spotted !