How to convert File to array of File? Type mismatch between source and sink, File to array
1
0
Entering edit mode
8.1 years ago

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?

Common-Workflow-Language cwl • 2.2k views
ADD COMMENT
4
Entering edit mode
8.0 years ago

Hello Karl,

The following hack should work; a future version of the standard should make this easier.

  1. Add StepInputExpressionRequirement & InlineJavascriptRequirement to your requirements list

  2. 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 ]; }
ADD COMMENT

Login before adding your answer.

Traffic: 1611 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6