scatter over optional array

Post author
tariq nawaz

I have a case where I want to iterate over two arrays, one of which shall be optionally present or not. I created the test WDL below. In the case of create_inner_array = false it throws the error

Failed to evaluate input 'CreateArray.echo' (reason 1 of 1): Failed to lookup input value for required input echo

But in the case of create_inner_array = true it throws the error

assertion failed: base member type WomMaybeEmptyArrayType(WomOptionalType(WomAnyType)) and womtype WomMaybeEmptyArrayType(WomOptionalType(WomStringType)) are not compatible

version development

workflow runIterationWithNone {
input {
Array[String] outer_array = ["1", "2"]
Boolean create_inner_array = false
}

if (create_inner_array) {
scatter (count in ["one", "two"]) {
call Echo as CreateArray {
input:
non_optional_string=count
}
}
}

scatter (non_optional_string in outer_array) {
scatter (optional_string in select_first([CreateArray.echo, [None]])) {
call Echo as GetEcho {
input:
non_optional_string=non_optional_string,
optional_string=optional_string
}
}
}

output {
Array[String] echo = flatten(GetEcho.echo)
}
}

task Echo {
input {
String non_optional_string
String? optional_string
# runtime
String gatk_docker = "broadinstitute/gatk:4.0.0.0"
Int? boot_disk_sizeGB = 12
Int disk_spaceGB = 1
Int memoryGB = 1
Int command_memGB = 1
Int? preemptible = 0
Int? max_retries = 0
Int cpu = 1
}

String string = non_optional_string + select_first([optional_string, ""])

command <<<
echo ~{string}
>>>

output {
String echo = read_string(stdout())
}

runtime {
docker: gatk_docker
bootDiskSizeGb: boot_disk_sizeGB
memory: memoryGB + " GB"
disks: "local-disk " + disk_spaceGB + " HDD"
preemptible: preemptible
maxRetries: max_retries
cpu: cpu
}
}



Thanks!!
Best Regards
Jessa

Comments

1 comment

  • Comment author
    Pamela Bretscher

    Hi tariq nawaz,

    Thanks for writing in about this issue. Could you please take a look at the suggestions offered in this previous forum post about the same error and let me know if it helps solve the issue you're seeing?

    Kind regards,

    Pamela

    0

Please sign in to leave a comment.