Question: CWL Workflow renaming outputs
1
gravatar for giacomo.tag
9 days 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 • 121 views
ADD COMMENTlink modified 7 days ago by drkennetz310 • written 9 days 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 7 days ago by biokcb150
1
gravatar for drkennetz
7 days ago by
drkennetz310
drkennetz310 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 7 days ago by drkennetz310
0
gravatar for Tom
7 days 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 7 days 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 1 day ago • written 1 day 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: 982 users visited in the last hour