Question: CWL: Organise outputs in subdirectories
0
gravatar for mareq
8 weeks ago by
mareq0
mareq0 wrote:

I have a CWL workflow with lots of outputs. All of those are just written flat to the output directory. Therefore, I would like to organise outputs into subdirectories. Is anything like that possible with CWL?

Note: The two toy workflows I am playing with atm are here: https://github.com/mareq/cwl-tutor/tree/master/workflows However, these are just toy examples, I play with. This is supposed to be a generic question, so that I can eventually apply the answer to the real workflow.

cwl subdir • 104 views
ADD COMMENTlink modified 7 weeks ago by Tom210 • written 8 weeks ago by mareq0
0
gravatar for Tom
7 weeks ago by
Tom210
Bielefeld University, CeBiTec, Germany
Tom210 wrote:

I don't think what you ask for is possible. I tackle the issue at tool-level. Every tool that might provide a workflows final output returns a directory which name is somehow derived from the tools input. Your other option would be appending a tool to the workflow which handles creating the folder structure you want.

ADD COMMENTlink written 7 weeks ago by Tom210

I realized i have use for the latter option as well. I wrote an ExpressionTool which can be stitched to the end of a workflow. It can be used to group files/directories at the end of a workflow using scatter. [Warning: I have not yet tested what happens if an empty array is passed to this tool as input for either or both of the arrays.]

cwlVersion: v1.0
class: ExpressionTool

doc: |
  Returns a directory named after inputs.newname, containing all files and directories contained in inputs.file_array and inputs.dir_array.

requirements:
  InlineJavascriptRequirement: {}

inputs:
  file_array:
    type: File[]
    label: Files which will be put in the output-directory
  dir_array:
    type: Directory[]
    label: Directories that will be put in the output-directory as subdirectories
  newname:
    type: string
    label: Name of the output-directory

outputs:
  newdir:
    type: Directory

expression: |
  ${
    var outputList = [];
    for (var count = 0; count < inputs.file_array.length; count++) {
      var nextfile = inputs.file_array[count];
      outputList.push(nextfile);
    }
    for (var count = 0; count < inputs.dir_array.length; count++) {
      var nextdir = inputs.dir_array[count];
      outputList.push(nextdir);
    }
    return {"parent_dir": {
      "class": "Directory", 
      "basename": inputs.newname,
      "listing": outputList
    } };
  }
ADD REPLYlink modified 7 weeks ago • written 7 weeks ago by Tom210
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: 686 users visited in the last hour