Do you have Split and Concatenate function for Filename or String manipulation in WDL?
And is there something like filename=basename $file in shell?
The closest thing we have to get a basename of a File/string is sub(input, pattern, replace) which is discussed here - https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#string-substring-string-string
sub(input, pattern, replace)
You can do something like this to get the filename of a gsutil path for instance
File unmapped_bam = "gs://bucket/directory/flowcell.lane.library_reads.bam"
String base_name = sub(sub(unmapped_bam, "gs://.*/", ""), ".bam$", "")
The first sub removes everything before the filename and the second sub removes the extension
I have created a ticket requesting this feature - https://github.com/broadinstitute/cromwell/issues/2249
Update: This function is being added in https://github.com/broadinstitute/wdl4s/pull/109 and will be available in Cromwell 27. There's an example to look at in the PR description.
I'm also looking to split a (tab- or space-delimited) string and index into the resulting array. Could that be done easily using sub or any other function? For example, I'd like to get the 4th column in a space-delimited string "1 2 3 4 5 6 7". Thanks!
@dinvlad I suspect this is beyond the WDL standard library at the moment. You're probably best off shelling this out to a task
Ok, thanks @ChrisL! We went with awk in a shell.