'How to declare a new Nextflow variable in a shell block?

I am currently writing my first Nextflow pipeline and I try to declare a new Nextflow variable in a script but I don't manage doing it.

I would like to set up a variable, min_length, with a value read in a text file (parsed with awk) and use this value later in my pipeline as a parameter. This is what I've tried :

process get_min_len{

  input:
  file "./foo.tab"

  output:
  val length_min into min_len_channel

  shell:
  """
  !{length_min}=`awk '{if (\$1=="!{params.bar}") {print \$2}}' ./foo.tab`
  """
}

I get this error message :

Error executing process > 'get_min_max_len'

Caused by:
  No such variable: length_min

(I also tried to initialize min_length like so : min_length=0 but it does not work either.)

Is there a way to do that ? Thanks !



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source