To celebrate the release of GATK 4.0, we are giving away free credits for running the GATK4 Best Practices pipelines in FireCloud, our secure online analysis portal. It’s first come first serve, so sign up now to claim your free credits worth $250. Sponsored by Google Cloud. Learn more at https://software.broadinstitute.org/firecloud/documentation/freecredits

[Feature request] Max/min functions or conditional expression

dshihdshih BostonMember, Broadie
edited October 2017 in Ask the WDL team

I am running into an issue where I would need max/min functions or conditional expressions.

To set a bound on a user input value... it would be great of any of the below examples could be supported:

Ternary if expression

task {
  Int memory
  Int _memory = (memory > 1) ? memory : 1
}

If expression

task {
  Int memory
  Int _memory =  if (memory > 1) { memory } else { 1 }
}

If statement

task {
  Int memory
  Int _memory =  1
  if (memory > 1) { _memory = memory }
}

Max function

task {
  Int memory
  Int _memory =  max(1, memory)
}

The "If statment" example currently does not work (tested on Cromwell 28.2), because If statements are only allowed inside workflow block but not inside task block. (I suppose you could move the variables up to the workflow and use conditional statement there... but this is undesirable, because it unnecessarily expands the scope of the variables.)

Answers

Sign In or Register to comment.