Question: CWL Workflow renaming outputs
1
gravatar for giacomo.tag
4 months ago by
giacomo.tag10
giacomo.tag10 wrote:

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 • 300 views
ADD COMMENTlink modified 4 months ago by drkennetz360 • written 4 months ago by giacomo.tag10

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 REPLYlink written 4 months ago by biokcb160
1
gravatar for drkennetz
4 months ago by
drkennetz360
drkennetz360 wrote:

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 COMMENTlink written 4 months ago by drkennetz360
0
gravatar for Tom
4 months ago by
Tom50
Bielefeld University, CeBiTec, Germany
Tom50 wrote:

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 COMMENTlink written 4 months ago by Tom50

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 REPLYlink modified 4 months ago • written 4 months ago by Tom50
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: 1206 users visited in the last hour