This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to specify enum symbols in record type definition?

I like to use SchemaDefRequirements to define parameter groups for our tools. Is it possible to include the symbols field under the record fields that have type enum? Thank you!

name: vcf2maf_params
type: record
fields:
  species:
    type: enum?
    # This doesn't pass validation:
#    symbols: [homo_sapiens, mus_musculus]

  ncbi_build:
    type: enum?
#    symbols: [GRCh37, GRCh38, GRCm38]
cwl

1 answer

Hello @ionox0, in CWL v1.0 inline enums & the ? shortcut aren't combinable, you have to use the long syntax.

Additionally, because of a bug in the CWL reference runner (found while researching your issue; thanks!), you'll need to give those enums names

cwlVersion: v1.0
class: CommandLineTool
requirements:
  SchemaDefRequirement:
    types:
      - name: vcf2maf_params
        type: record
        fields:
          species:
              - "null"
              - type: enum
                name: species
                symbols: [homo_sapiens, mus_musculus]
          ncbi_build:
              - "null"
              - type: enum
                name: build
                symbols: [GRCh37, GRCh38, GRCm38]
baseCommand: echo
outputs: []
inputs: []

With the newly released version 1.0.20181201184214 of cwltool the above is now simpler:

cwlVersion: v1.0
class: CommandLineTool
requirements:
  SchemaDefRequirement:
    types:
      - name: vcf2maf_params
        type: record
        fields:
          species:
              - "null"
              - type: enum
                symbols: [homo_sapiens, mus_musculus]
          ncbi_build:
              - "null"
              - type: enum
                symbols: [GRCh37, GRCh38, GRCm38]
baseCommand: echo
outputs: []
inputs: []

Thank you for the help and improvements!

Log in to answer this question.