ExpressionTool with Record output

I was wondering if anyone could suggest a fix this issue with an ExpressionTool that has outputs of type: record.

The output JSON at the end of the run only shows null values for these records:

...
    "unfiltered_bams": [
        null,
        null,
        null,
        null,
        null,
        null
    ],
...
#!toil-cwl-runner

# This tool returns a CWL record object,
# which contains a Bam file, and associated metadata

cwlVersion: v1.0

class: ExpressionTool

requirements:
  InlineJavascriptRequirement: {}
  ResourceRequirement:
    ramMin: 2000
  SchemaDefRequirement:
    types:
      - $import: ../../resources/schemas/bam_sample.yaml

inputs:

    bam: File
    add_rg_SM: string
    patient_id: string
    sample_class: string

outputs:

  sample_record: ../../resources/schemas/bam_sample.yaml#bam_sample

expression: |
  ${
    return {
      'file': inputs.bam,
      'sampleId': inputs.add_rg_SM,
      'patientId': inputs.patient_id,
      'tumorOrNormal': inputs.sample_class
    }
  }

Hei,
in the return statement you miss the name of the output port.

It should be like this:

expression: |
  ${
    return {
      'sample_record': {
        'file': inputs.bam,
        'sampleId': inputs.add_rg_SM,
        'patientId': inputs.patient_id,
        'tumorOrNormal': inputs.sample_class
      }
    };
  }

Iā€™m returning records from the expression tool in cwl and they work for me.

Hope it helps.

Cheers!

2 Likes