I wonder how I convert a File to an array of files? This might be a completely trivial question, but I have a hard time solving it.
Below is a summary of my problem:
I have a small pipeline (trimming ==> mapping ==> sorting). Sorting is done with picardtools, which allows for multiple input files. Below is the section in the tool description file:
inputs:
...
- id: "inputFileName_mergedSam"
type:
type: array
items: File
streamable: true
inputBinding: { prefix: "INPUT=" }
inputBinding: { position: 5 }
...
My problem is that the mapping step before returns a single file. Connecting the two steps in a workflow fails:
steps:
...
- id: alignment
...
outputs:
- id: alignment
- id: sort
inputs:
- id: inputFileName_mergedSam
source: "#alignment/alignment"
...
The error thrown is a mismatch between source (File) and sink ({'items': 'File', 'streamable': True, 'inputBinding': {'prefix': 'INPUT='}, 'type': 'array'}).
How do I convert the File output from the alignment step to an array?
1 answer
Hello Karl,
The following hack should work; a future version of the standard should make this easier.
Add StepInputExpressionRequirement & InlineJavascriptRequirement to your requirements list
Use valueFrom to wrap the single item into an array
All together
requirements:
- class: StepInputExpressionRequirement
- class: InlineJavascriptRequirement
steps:
...
- id: alignment
...
outputs:
- id: alignment
- id: sort
inputs:
- id: inputFileName_mergedSam
source: "#alignment/alignment
valueFrom: ${ return [ self ]; }
Log in to answer this question.