How to output non-file types from a CommandLineTool?

I saw this page here:

https://www.commonwl.org/user_guide/misc/

Which describes how to load data from a file in order to output it ;


Non “File” types using evalFrom

cwlVersion: v1.0  # or v1.1
class: CommandLineTool
requirements:
  InlineJavascriptRequirement: {}

baseCommand: [ echo, "42" ]

inputs: []

stdout: my_number.txt

outputs:
  my_number:
    type: int
    outputBinding:
       glob: my_number.txt
       loadContents: True
       outputEval: $(parselnt(self[0].contents))

  my_number_as_string:
    type: string
    outputBinding:
       glob: my_number.txt
       loadContents: True
       outputEval: $(self[0].contents)

However, this is not what I want. In these examples, you would have to write out all your data into files and then load them back into output objects from files.

I want to be able to pass in any arbitrary input into a CommandLineTool, then pass that (or other) data back out, regardless of the involvement of any file. For example:

cwlVersion: v1.0  # or v1.1
class: CommandLineTool
requirements:
  InlineJavascriptRequirement: {}

baseCommand: [ touch, newfile.txt ]

inputs:
  some_value: int
  some_file: File

outputs:
  some_value: 
    value: $(inputs.some_value)
    type: int
  some_other_value: 
    value: ${ return `some_JS_expression_result` ; }
    type: int
  new_file:
    type: File
    outputBinding: 
      glob: newfile.txt

This is just a basic example with primitive data types, but ultimately what I would really like is the ability to pass in a record type as an input, with one or more fields including File objects, then inside my CommandLineTool do some processing to make a new file, and then output that same record but with an updated File in its fields.

I have tried writing this myself but I get syntax or “incorrect field” errors every time.

The CWL spec here describes several different types's of CommandOutput and CommandOutputRecord object;

https://www.commonwl.org/v1.0/CommandLineTool.html

But I have not been able to find any real-world examples that show how to output anything from CommandLineTool that is not from a file.

Hello @steve

What you describe should be possible.

You can have an outputBinding for records both at the overall record level, or at the level of each field of the record.

For an example of the overall record level outputBinding see Test for outputEval on a record type itself, not its fields · common-workflow-language/cwl-v1.2@5551e59 · GitHub

Does that help?

1 Like

Thanks, that helped a lot. I was able to combine that with “custom data types” to get some demo’s of taking a custom record with a File field as input, then outputting the record with a new file from a command line tool

https://github.com/stevekm/cwl-demos/blob/746d9b24c5277de99ee117d3f859f6218e0de120/custom-types/sampletypes.cwl

https://github.com/stevekm/cwl-demos/blob/746d9b24c5277de99ee117d3f859f6218e0de120/custom-types-array/sampletypes.cwl

1 Like