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

Dynamically Change Workflow Output Based on Conditional

Hi,
I am needing to dynamically add/remove certain workflow outputs based on a conditional statement.

Below is an example of what I want to do (I am currently getting a syntax error using this method). If there is no way to it this way, could someone suggest an alternative way? I do not want to have to declare in if statement before multiple output sections, as there are quite a number of other tasks in the pipeline, which are to be kept in all cases---and doing it that way would require me to have an output section for each possible combination of possible outputs.

I thought about just querying the output metadata, and taking all those outputs which are not null. However, I do not want to keep all task outputs, as some of them are just intermediate outputs (e.g., a SAM file before it is converted to BAM). I would like to just have one set of output files, which include only the ones I want to keep, so that I can automate some things in our archiving of output files.

workflow example {
  String run_type = "this"

  # other task calls ...

  if (run_type == "this") {
    call this
  }
  if (run_type == "that") {
    call that
  }

  output {
    # other task outputs to keep ...

    if (run_type == "this") {
      File this_file = this.this_file
    }
    if (run_type == "that") {
      File that_file = that.that_file
    }
  }
}
Tagged:

Best Answer

  • mcovarrmcovarr Cambridge, MAMember, Broadie, Dev
    Accepted Answer

    I don't think you can do conditional outputs in current versions of WDL. I'm not sure if this helps you, but if you're interested in keeping only the non-null value in a single output:

    task this {
      command {}
      output {
        String out = "this"
      }
    }
    
    task that {
      command {}
      output {
        String out = "that"
      }
    }
    
    workflow example {
      String run_type = "this"
    
      # other task calls ...
    
      if (run_type == "this") {
        call this
      }
      if (run_type == "that") {
        call that
      }
    
      output {
        # other task outputs to keep ...
        Array[String?] outs = [this.out, that.out]
        String out = select_first(outs)
      }
    }
    

    The workflow out output will have the value this.

Answers

  • mcovarrmcovarr Cambridge, MAMember, Broadie, Dev
    Accepted Answer

    I don't think you can do conditional outputs in current versions of WDL. I'm not sure if this helps you, but if you're interested in keeping only the non-null value in a single output:

    task this {
      command {}
      output {
        String out = "this"
      }
    }
    
    task that {
      command {}
      output {
        String out = "that"
      }
    }
    
    workflow example {
      String run_type = "this"
    
      # other task calls ...
    
      if (run_type == "this") {
        call this
      }
      if (run_type == "that") {
        call that
      }
    
      output {
        # other task outputs to keep ...
        Array[String?] outs = [this.out, that.out]
        String out = select_first(outs)
      }
    }
    

    The workflow out output will have the value this.

Sign In or Register to comment.