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.

scatter across Array[Pair[]]

NicoBxlNicoBxl Member
edited February 2018 in Ask the Cromwell + WDL Team


I've three String arrays that I put in a Array[Pair[]]. I would like to call a task on each of the elements of the new Array[Pair[]] as :

workflow test{
    Array[String] a
    Array[String] b
    Array[String] c
    Array[Pair[String,String,String]] x = zip(a,b,c) 
    scatter (y in x ) {
        call stuff{
            input :

task stuff{
    String a
    String b
    String c
    command {
        echo ${a}" "${b}" "${c}

In this example the lines in the call stuff{} will not work (e.g. a=lane.a)

Is there a way to do that ? Or maybe an other design than using Array[Pair[]] to group three arrays ?

Thank you


  • kshakirkshakir Broadie, Dev ✭✭✭

    A Pair only contains two members left and right. One can zip-a-zip though to create a structure with three elements.

    For example:

    workflow zip3 {
        Array[String] a = ["1a", "2a", "3a"]
        Array[String] b = ["1b", "2b", "3b"]
        Array[String] c = ["1c", "2c", "3c"]
        Array[Pair[String,String]] inner = zip(b,c)
        Array[Pair[String,Pair[String,String]]] outer = zip(a,inner)
        scatter (element in outer) {
            # Create a variable to access the "inner" pair
            Pair[String, String] right_pair = element.right
            call stuff {
                    a = element.left,
                    b = right_pair.left,
                    c = right_pair.right
    task stuff {
        String a
        String b
        String c
        command {
            echo ${a} ${b} ${c}
        output { String out = read_string(stdout()) }
Sign In or Register to comment.