This is a test version of Biostars. For the public version, visit https://www.biostars.org.
In CWL, how to make arrays optional input

How do I make an array optional input?

This works:

cwlVersion: v1.0
class: CommandLineTool

inputs:
  insertSize:
    type:
      type: array
      items: int
      inputBinding:
        prefix: -s
        separate: true
    inputBinding:
      position: 2

I want to make insertSize optional, but changing array into array? gives a long list of errors (pasted below).

What is the correct way to do this?

Error:

Tool definition failed validation: Validation error in object file:///mnt/mc3_tcga/pindel/pindel.cwl   Could not validate `CommandLineTool` because
    CommandLineTool record could not validate field `inputs` because
      At position 16
        could not validate field `type` because
          the value `{'inputBinding': {'prefix': '-s', 'separate': True},
           'items': 'int',
           'type': [u'null', 'array']}`
           is not a valid type in the union, expected one of:
          - null, but
             the value `{'inputBinding': {'prefix': '-s', 'separate': True},
             'items': 'int',
             'type': [u'null', 'array']}` is not null
          - CWLType, but
             the value `{'inputBinding': {'prefix': '-s', 'separate': True},
             'items': 'int',
             'type': [u'null', 'array']}`
             is not a valid symbol in enum CWLType, expected one of 'File', 'Directory'
          - CommandInputRecordSchema, but
             could not validate field `type` because
              the value `[u'null', 'array']`
               is not a valid symbol in enum Record_symbol, expected one of 'record'

            could not validate field `items` because it is not recognized and strict is True, valid fields are: fields, type, label
            could not validate field `inputBinding` because it is not recognized and strict is True, valid fields are: fields, type, label
          - CommandInputEnumSchema, but
             missing required field `symbols`
            could not validate field `type` because
              the value `[u'null', 'array']`
               is not a valid symbol in enum Enum_symbol, expected one of 'enum'

            could not validate field `items` because it is not recognized and strict is True, valid fields are: symbols, type, label, inputBinding
          - CommandInputArraySchema, but
             could not validate field `type` because
              the value `[u'null', 'array']`
               is not a valid symbol in enum Array_symbol, expected one of 'array'

          - string, but
             the value `{'inputBinding': {'prefix': '-s', 'separate': True},
             'items': 'int',
             'type': [u'null', 'array']}` is not string
          - array of <CWLType or CommandInputRecordSchema or CommandInputEnumSchema or CommandInputArraySchema or string>, but
             the value `{'inputBinding': {'prefix': '-s', 'separate': True},
             'items': 'int',
             'type': [u'null', 'array']}` is not a list, expected list of CWLType or CommandInputRecordSchema or CommandInputEnumSchema or CommandInputArraySchema or string
cwl

1 answer

Setting

type: string[]?

makes it optional, but that only solves half the problem as it doesn't keep inputBinding

perhaps:

type:
- null
- type: array
  ...

I havn't tested it though

Log in to answer this question.