Create/Move output of a tool to a specific location

Hi Sherish,

I’m sorry, there was one type too many in my initial suggestion. Please try the following tool wrapper:

#!/usr/bin/env cwl-runner

cwlVersion: v1.0
class: CommandLineTool

hints:
 DockerRequirement:
   dockerImageId: umccr/pipeline-cwl

requirements:
  InlineJavascriptRequirement: {}
  EnvVarRequirement:
    envDef:
      DEPLOY_ENV: $(inputs.denv)

inputs:
  denv: string
  samplesheet:
    type: File
    inputBinding:
      position: 1
  config:
    type: Directory
    inputBinding:
      position: 2

outputs:
  log_out:
    type: stdout
  split_samplesheets:
    type: Directory
    outputBinding:
      glob: .
      outputEval: |
        ${
          self[0].basename = "output";
          return self[0]
        }

stdout: samplesheet-check.log

baseCommand: [python, /scripts/samplesheet-check.py]

Regarding the outputBinding for split_samplesheet: glob: . instructs cwl to collect the current working directory as output. This should contain all the data that the python script has written. The working directory gets created by your cwl-runner at runtime, and will have a random collection of characters as a name. This is why we use outputEval to change the basename-property of the directory to a name of our choosing (in this case: “output”).

What you cannot do is instruct the CommandLineTool to create output at any specific location, it is constrained to the temporary directory used at runtime. For this purpose, use the corresponding argument of your cwl-runner. For cwltool this would be --outdir myDirectory

I hope this helps!

Cheers,
Tom

2 Likes