Question: Reading Array from File as Input at Runtime
gravatar for Lukas Rupprecht
2.3 years ago by
Lukas Rupprecht0 wrote:

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[].

cwl • 738 views
ADD COMMENTlink modified 2.3 years ago by bogdan.gavrilovic230 • written 2.3 years ago by Lukas Rupprecht0
gravatar for bogdan.gavrilovic
2.3 years ago by
bogdan.gavrilovic230 wrote:

The modified expression tool would look like this.

cwlVersion: v1.0
class: ExpressionTool

requirements: { InlineJavascriptRequirement: {} }

    type: File
      loadContents: true

expression: |
  ${ return { "array_string": JSON.parse(inputs.a_File.contents.replace('"',"'")) }; }

  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'.

ADD COMMENTlink written 2.3 years ago by bogdan.gavrilovic230
Please log in to add an answer.


Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 992 users visited in the last hour