Question: How to convert File to array of File? Type mismatch between source and sink, File to array
0
gravatar for karl.nordstrom
2.8 years ago by
karl.nordstrom90 wrote:

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?

cwl common workflow language • 1.2k views
ADD COMMENTlink modified 2.8 years ago by Michael R. Crusoe1.6k • written 2.8 years ago by karl.nordstrom90
4
gravatar for Michael R. Crusoe
2.8 years ago by
Common Workflow Language project
Michael R. Crusoe1.6k wrote:

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 COMMENTlink written 2.8 years ago by Michael R. Crusoe1.6k
Please log in to add an answer.

Help
Access

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