CommandLineTool API classes

CommandLineTool

class cwlgen.CommandLineTool(tool_id=None, base_command=None, label=None, doc=None, cwl_version='v1.0', stdin=None, stderr=None, stdout=None, path=None, requirements=None, hints=None, inputs=None, outputs=None, arguments=None)[source]

Contain all informations to describe a CWL command line tool.

__init__(tool_id=None, base_command=None, label=None, doc=None, cwl_version='v1.0', stdin=None, stderr=None, stdout=None, path=None, requirements=None, hints=None, inputs=None, outputs=None, arguments=None)[source]
Parameters:
  • tool_id (str) – Unique identifier for this tool
  • base_command (str | list[STRING]) – command line for the tool
  • label (str) – label of this tool
  • doc (str) – documentation for the tool, usually longer than the label
  • cwl_version (str) – version of the CWL tool
  • stdin (str) – path to a file whose contents must be piped into stdin
  • stderr (str) – capture stderr into the given file
  • stdout (str) – capture stdout into the given file

inputs (cwlgen.CommandInputParameter objects), outputs (cwlgen.CommandOutputParameter objects), arguments (cwlgen.CommandLineBinding objects), hints (any | cwlgen.Requirement objects) and requirements (cwlgen.Requirement objects) are stored in lists which are initialized empty.

export(outfile=None)[source]

Export the tool in CWL either on STDOUT or in outfile.

Input and outputs

CommandInputParameter

class cwlgen.CommandInputParameter(param_id, label=None, secondary_files=None, param_format=None, streamable=None, doc=None, input_binding=None, default=None, param_type=None)[source]

An input parameter for a cwlgen.CommandLineTool.

__init__(param_id, label=None, secondary_files=None, param_format=None, streamable=None, doc=None, input_binding=None, default=None, param_type=None)[source]
Parameters:
  • param_id (STRING) – unique identifier for this parameter
  • label (STRING) – short, human-readable label
  • secondary_files (STRING) – If type is a file, describes files that must be included alongside the primary file(s)
  • param_format (STRING) – If type is a file, uri to ontology of the format or exact format.
  • streamable (BOOLEAN) – If type is a file, true indicates that the file is read or written sequentially without seeking
  • doc (STRING) – documentation
  • input_binding (cwlgen.CommandLineBinding object) – describes how to handle the input
  • default (STRING) – default value
  • param_type (STRING) – type of data assigned to the parameter corresponding to CWLType

CommandOutputParameter

class cwlgen.CommandOutputParameter(param_id, label=None, secondary_files=None, param_format=None, streamable=None, doc=None, output_binding=None, param_type=None)[source]

An output parameter for a cwlgen.CommandLineTool.

__init__(param_id, label=None, secondary_files=None, param_format=None, streamable=None, doc=None, output_binding=None, param_type=None)[source]
Parameters:
  • param_id (STRING) – unique identifier for this parameter
  • label (STRING) – short, human-readable label
  • secondary_files (STRING) – If type is a file, describes files that must be included alongside the primary file(s)
  • param_format (STRING) – If type is a file, uri to ontology of the format or exact format
  • streamable (BOOLEAN) – If type is a file, true indicates that the file is read or written sequentially without seeking
  • doc (STRING) – documentation
  • output_binding (cwlgen.CommandOutputBinding object) – describes how to handle the output
  • param_type (STRING) – type of data assigned to the parameter corresponding to CWLType

CommandLineBinding

class cwlgen.CommandLineBinding(load_contents=None, position=None, prefix=None, separate=None, item_separator=None, value_from=None, shell_quote=None)[source]

The binding behavior when building the command line depends on the data type of the value. If there is a mismatch between the type described by the input schema and the effective value, such as resulting from an expression evaluation, an implementation must use the data type of the effective value.

Documentation: https://www.commonwl.org/v1.0/CommandLineTool.html#CommandLineBinding

__init__(load_contents=None, position=None, prefix=None, separate=None, item_separator=None, value_from=None, shell_quote=None)[source]
Parameters:
  • load_contents (BOOLEAN) – Read up to the fist 64 KiB of text from the file and place it in the “contents” field of the file object
  • position (INT) – The sorting key
  • prefix (STRING) – Command line prefix to add before the value
  • separate (BOOLEAN) –
  • item_separator (STRING) – Join the array elements into a single string separated by this item
  • value_from (STRING) – Use this as the value
  • shell_quote (BOOLEAN) – Value is quoted on the command line

CommandOutputBinding

class cwlgen.CommandOutputBinding(glob=None, load_contents=None, output_eval=None)[source]

Describes how to generate an output parameter based on the files produced.

__init__(glob=None, load_contents=None, output_eval=None)[source]
Parameters:
  • glob (STRING) – Find corresponding file(s)
  • load_contents (BOOLEAN) – For each file matched, read up to the 1st 64 KiB of text and place it in the contents field
  • output_eval (STRING) – Evaluate an expression to generate the output value

Special Types

class cwlgen.CommandInputRecordSchema(label=None, name=None)[source]

Documentation: https://www.commonwl.org/v1.0/Workflow.html#CommandInputRecordSchema

__init__(label=None, name=None)[source]
Parameters:
  • fields (array<InputRecordField>) – Defines the fields of the record.
  • label – A short, human-readable label of this object.
  • name – NF (Name of the InputRecord)
class cwlgen.CommandInputRecordSchema.CommandInputRecordField(name, input_type, doc=None, input_binding=None, label=None)

Documentation: https://www.commonwl.org/v1.0/Workflow.html#CommandInputRecordField

__init__(name, input_type, doc=None, input_binding=None, label=None)
Parameters:
  • name
  • input_type (CWLType | InputRecordSchema | InputEnumSchema | InputArraySchema | string | array<CWLType | InputRecordSchema | InputEnumSchema | InputArraySchema | string>) –
  • doc – A documentation string for this field
  • input_binding (CommandLineBinding) –
  • label
class cwlgen.CommandInputArraySchema(items=None, label=None, input_binding=None)[source]

Based on the parameter set out in the CWL spec: https://www.commonwl.org/v1.0/CommandLineTool.html#CommandInputArraySchema

__init__(items=None, label=None, input_binding=None)[source]
Parameters:
  • items – Defines the type of the array elements.
  • label (STRING) – A short, human-readable label of this object.
  • input_binding (CommandLineBinding) –
Type:

CWLType | CommandInputRecordSchema | CommandInputEnumSchema | CommandInputArraySchema | string | array<CWLType | CommandInputRecordSchema | CommandInputEnumSchema | CommandInputArraySchema | string>

class cwlgen.CommandInputEnumSchema(symbols, label=None, name=None, input_binding=None)[source]

Documentation: https://www.commonwl.org/v1.0/Workflow.html#CommandInputEnumSchema

__init__(symbols, label=None, name=None, input_binding=None)[source]
Parameters:
  • symbols (List[str]) – Defines the set of valid symbols.
  • label (str) – A short, human-readable label of this object.
  • name (str) –
  • input_binding (CommandLineBinding) –