Update: July 26, 2019
This section of the forum is now closed; we are working on a new support model for WDL that we will share here shortly. For Cromwell-specific issues, see the Cromwell docs and post questions on Github.

Check is String Value is in Array[String]

erichpetersonerichpeterson Member

Hi,
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?

Thanks.

Best Answer

Answers

  • mcovarrmcovarr Cambridge, MAMember, Broadie, Dev ✭✭

    Hello,

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

    Thanks

  • 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.