We've moved!
For WDL questions, see the WDL specification and WDL docs.
For Cromwell questions, see the Cromwell docs and please post any issues on Github.

Check is String Value is in Array[String]

erichpetersonerichpeterson Member

I have an array of String values passed to a variable (i.e., Array[String] multi_strings) from an input file to the workflow. I am wanting to call various tasks, based on the values within the array.. So, I am looking for a way to check if a certain string is found within the array.

Any idea how to do this?


Best Answer


  • mcovarrmcovarr Cambridge, MAMember, Broadie, Dev ✭✭


    Could you provide a bit more detail as to what you're trying to do exactly?


  • Hi @mcovarr ,

    I'm wanting to do something like the following:

    workflow test {
    Array[String] variant_callers = ["mutect2", "varscan2", "strelka2"]

    if ("mutect2" in variant_callers) {
    call mutect2
    if ("varscan2" in variant_callers) {
    call varscan2
    if ("strelka2" in variant_callers) {
    call strelka2

  • Hey @Ruchi ,
    It might.

    I had started to implement it in that way, but found there were some side-effects that were giving me some trouble. I think the problem was this; after the scatter finishes, I would have to use the select_first() function to grab the output from each call, as it seems to always produce an array of results for all calls within the scatter, even though each call is most likely called once (given that it is only listed once in the Array.

    Anyways, thanks for the help. I will keep trying.

  • RuchiRuchi Member, Broadie, Moderator, Dev admin

    Hey @erichpeterson that is an unfortunate side effect of using the scatter block and I totally agree it makes sense to be able to have such a function built in to the WDL language itself. I've filed a feature request and you can track it's progress if you'd like.

Sign In or Register to comment.