Problem with + and optional variable
See original GitHub issueHello! I used this snippet of code successfully on the Cromwell with Google backend:
task fastqc {
input {
File f1
File? f2
Int? cpu=1
Int? machine_mem_gb
Int? preemptible_attempts
String mode
Float f2size = if (mode == "PE") then size(f2, "GB") else 0.0
Int disk_space_gb = ceil(size(f1, "GB") + f2size) + 20
}
command {
fastqc -t ~{cpu} --outdir $PWD ~{f1} ~{f2}
}
output {
Array[File] html = glob("*html")
Array[File] zip = glob("*zip")
}
runtime {
docker: "biocontainers/fastqc:v0.11.5_cv2"
memory: select_first([machine_mem_gb, 4]) + " GB"
cpu: cpu
disks: "local-disk " + disk_space_gb + " HDD"
preemptible: select_first([preemptible_attempts, 3])
}
}
On local backend I got this error: _Failed to evaluate input '_disk_space_gb’ (reason 1 of 1): Sorry! Operation + is not supported on empty optional values. You might resolve this using select_first([optional, default]) to guarantee that you have a filled value.
I tried following the advice (even though I don’t see what is missing) Float f2size = select_first([if (mode == “PE”) then size(f2, “GB”) else 0.0]) And then I got an even more confusing error: Failed to process task definition ‘fastqc’ (reason 1 of 1): Failed to process expression ‘select_first([f2size, select_first([if (mode == “PE”) then size(f2, “GB”) else 0.0])])’ (reason 1 of 1): Invalid parameter ‘ArrayLiteral(Vector(TernaryIf(Equals(IdentifierLookup(mode),StringLiteral(PE)),Size(IdentifierLookup(f2),Some(StringLiteral(GB))),PrimitiveLiteralExpressionElement(WomFloat(0.0)))))’. Expected an array of optional values (eg ‘Array[X?]’) but got ‘Array[Float]+’
Can you help me understand? It all passes Womtools validation.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5
Top GitHub Comments
OK, solved it. The whole block was in inputs which seem to be evaluated out of order or without it.
Moving the lines with basename out of the input block solved it!
Thanks!
Actually, upon further examination b1 and b2 come up empty. Why does this triple basename return empty string? Is this not a valid synthax?