Question: CWL: Organise outputs in subdirectories
gravatar for mareq
8 weeks ago by
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: 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
gravatar for Tom
7 weeks ago by
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.

  InlineJavascriptRequirement: {}

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

    type: Directory

expression: |
    var outputList = [];
    for (var count = 0; count < inputs.file_array.length; count++) {
      var nextfile = inputs.file_array[count];
    for (var count = 0; count < inputs.dir_array.length; count++) {
      var nextdir = inputs.dir_array[count];
    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.


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