CWL Workflow renaming outputs
2
1
Entering edit mode
6.4 years ago
giacomo.tag ▴ 10

let's say I have a workflow like

cwlVersion: v1.0
class: Workflow
inputs:
  inputA: File
  inputB: File

steps:
  untarA:
    run: tar-param.cwl
    in:
      tarfile: inputA
    out: [example_out]
  untarB:
    run: tar-param.cwl
    in:
      tarfile: inputB
    out: [example_out]

outputs:
  outA:
    type: File
    outputSource: untar/example_out
  outB:
    type: File
    outputSource: untar/example_out

I exclude the content of tar-param.cwl because it's just a trivial example of a step with one output and one input. The problem is that there will be two outputs (outA and outB) with the same file name, since they are coming from param.cwl#example_out. is there a way to rename the workflow output files?

cwl • 2.7k views
ADD COMMENT
0
Entering edit mode

Will you add the tar-param.cwl script anyway so that we can figure out what you are referring to as having the same name? I think if you add it we can help you better. You can rename the output files, but I'm not 100% sure that's what you need in this case without seeing the command line tool.

ADD REPLY
0
Entering edit mode

I believe in your outputs, you actually need to specify:

outputs:
outA:
  type: File
  outputSource: untarA/example_out
outB:
  type: File
  outputSource: untarB/example_out

However, I'm also not clear on how you would rename example_out so they don't conflict.

ADD REPLY
1
Entering edit mode
6.4 years ago
drkennetz ▴ 560

You will first need to do the recommendations above for your outputs from the workflow that tom.tubb suggested above.

Second, in your tar-param.cwl, you can tell the code to name the output file to match the input filename, see the example script below:

cwlVersion: v1.0
class: CommandLineTool
requirements:
 - class: ShellCommandRequirement ## this may not be necessary

baseCommand: [tar]
inputs:
  inFile:
    type: File

outputs:
  outFile:
    type: File
    outputBinding: {glob: $(inputs.inFile.basename).tar}

The outputBinding above is just making the output filename a variable that matches your input filename, then adding ".tar" on the end of it. I am not entirely sure if ".tar" will be added anyway because you are tarring the file. This should fix your output problem of having the same filename because it is no longer a static name.

ADD COMMENT
0
Entering edit mode
6.4 years ago
Tom ▴ 540

I am fairly new to cwl, so take everything i say with a grain (or even more) of salt.

First of all, the outputSource fields seem faulty. They do not correctly reference the two steps.

outputs:
  outA:
    type: File
    outputSource: untarA/example_out
  outB:
    type: File
    outputSource: untarB/example_out

This lets you discern between the different outputs in the context of the workflow. Now as far as i know there is no option to make any changes to a file (including its name) in a workflow. So you would have to either

  • generate different filenames in untarA/untarB

    or

  • write a CommandLineTool which manipulates the name of a given input file and add it to your workflow

ADD COMMENT
0
Entering edit mode

In case somebody comes to this thread looking for the second solution i mentioned: Here is a CommandLineTool i use for changing file names during a workflow.

cwlVersion: v1.0
class: CommandLineTool
baseCommand: mv
label: Changes the name of a file and returns the renamed file as output

requirements:
  InlineJavascriptRequirement: {}

inputs:
  newname:
    type: string
    inputBinding:
      position: 2
  rename_this:
    type: File
    inputBinding:
      position: 1

outputs:
  file_renamed:
    type: File
    outputBinding:
      glob: $(inputs.newname)

This is what i came up with using my very limited CWL-experience, so there is probably a more elegant solution.

ADD REPLY

Login before adding your answer.

Traffic: 2634 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