I have a 2-step CWL workflow in which the first step produces a file with multiple entries in array form:
[
'entry11 entry12 entry13',
'entry21 entry22 entry23',
'entry31 entry32 entry33',
...
]
I would like to read the entries as a string[] in the second step to be able to scatter over them. Is this possible in CWL? Can it be achieved without writing an ExpressionTool? I found this previous post but that only describes converting a file to a string and I am not sure how to adapt it to string[].
1 answer
The modified expression tool would look like this.
cwlVersion: v1.0
class: ExpressionTool
requirements: { InlineJavascriptRequirement: {} }
inputs:
a_File:
type: File
inputBinding:
loadContents: true
expression: |
${ return { "array_string": JSON.parse(inputs.a_File.contents.replace('"',"'")) }; }
outputs:
array_string: string[]
JSON.parse function would use contents of the file, but would need to replace double quotes with single quotes. If you scatter the tool that receives this array of strings, each job would get one string, e.g. 'entry11 entry12 entry13'.
Log in to answer this question.