[Feature request] Max/min functions or conditional expression

dshihdshih BostonMember, Broadie
edited October 2017 in Ask the Cromwell + 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.