Forum Login Issue:
Currently the "Log in with Google" button redirects you to a "Page not found." Our forum vendors have implemented a fix, and now we are just waiting on a patch to be released. In the meantime, while on the "Page not found" you can edit the URL to delete the second gatk, firecloud, or wdl (depending on what subforum you are acessing).
ex: https://gatkforums.broadinstitute.org/gatk/gatk/entry/...

Optional WDL Inputs to Toggle Flag

Hi,

The WDL Spec describes a situation similar to what I'm trying to do here:

https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#prepending-a-string-to-an-optional-parameter

In this case, I assume that Cromwell knows that it should do the "--val" here because of the concatenation with the val parameters contents. However, my problem is that I do not want to concatenate the contents of val, because my flag is a toggle that does not take a parameter. So what I want is that if val is specified, I just want:

python script.py --val

and if it is not, I want

python script.py

How can I accomplish this with the constraints of the WDL language?

Answers

  • danbdanb Member, Broadie

    You can accomplish this by declaring a boolean flag and then running a bash if statement,

    if [ ${flag} ]
    then
      python script.py --val
    else
      python script.py
    fi
    
  • amr@broadinstitute.orgeamr@broadinstitute.orge Member, Broadie
    edited March 15

    Sorry, I neglected to mention that my "python script.py" is wrapped inside a command line python call within the command block of the WDL task, so bash won't work, and apparently command line python doesn't accept expressions, only statements.

  • danbdanb Member, Broadie

    Could you paste your command?

    so bash won't work, and apparently command line python doesn't accept expressions, only statements.

    I don't think these statements are accurate as ultimately the command is a bash statement, and can be parameterized via an expression.

  • RuchiRuchi Member, Broadie, Moderator, Dev

    Alternatively, you could also try:

    task test {
      String? val
      command <<<
        python script.py ${"--val=" + val}
      >>>
    }
    
  • ChrisLChrisL Cambridge, MAMember, Broadie, Moderator, Dev
    edited March 23

    @Ruchi I think that won't help because the val isn't wanted. Luckily the WDL if then else should help:

    EDIT: Oops, I think you wanted the --val to be --${val}? I think this should work:

    task test {
      String? val
      String cmdLineVal = if isDefined(val) then "--${val}" else ""
      command <<<
        python script.py ${cmdLineVal}
      >>>
    }
    
Sign In or Register to comment.