This is a test version of Biostars. For the public version, visit https://www.biostars.org.
CWL: How to refer to input or scattered value of a step

I have a workflow that scatters a step over an array input called intervals. I want to use the value interval[i] to construct another parameter to the step.

cwlVersion: v1.0
class: Workflow
requirements:
   - class: ScatterFeatureRequirement
   - class: StepInputExpressionRequirement
   - class: InlineJavascriptRequirement
inputs:
   bam: File
   intervals: string[]
outputs:
  hc_vcf:
  type: File[]
  outputSource: step_hc/output_HaplotypeCaller
steps:
  step_hc:
    run: dummy_HC.cwl
    scatter: [interval_string]
    in:
      inputBam: bam
      interval_string: intervals
      outputVcf:
      # This is where I would like the output to be named something like 
      # $(inputs.bam.nameroot).$(interval_string).vcf

I can refer to the inputs to workflow, but I have not figured out how to refer to the input to a particular step.

Thank you Manisha

cwl

2 answers

Hello Manisha,

Thank you for your question; my apologies for the delay in getting a response.

You have at least two options:

A. Use valueFrom ( http://www.commonwl.org/v1.0/Workflow.html#WorkflowStepInput)

steps:
  step_hc:
    run: dummy_HC.cwl
    scatter: [interval_string]
    in:
      inputBam: bam
      interval_string: intervals
      outputVcf:
        valueFrom: $(inputs.inputBam.nameroot).$(inputs.interval_string).vcf

Here a full expression is need instead of a parameter reference due to combining multiple inputs.

B. Adjust dummy_HC.cwl to compute the the outputVCF filename itself, so that other CWL workflows don't have to repeat Option A

arguments:
 - position: 0 # adjust or remove as necessary
   prefix: --output_file # just an example, adjust or remove as necessary
   valueFrom: $(inputs.inputBam.nameroot).$(inputs.interval_string).vcf

I hope you find this helpful.

[edited 2020-10-01 to clean up syntax]

Hello again Manisha,

I have an update on my answers, there is a simpler syntax available as documented here

A:

steps:
  step_hc:
    run: dummy_HC.cwl
    scatter: [interval_string]
    in:
      inputBam: bam
      interval_string: intervals
      outputVcf:
        valueFrom: $(inputs.inputBam.nameroot).$(inputs.interval_string).vcf

B:

arguments:
 - position: 0 # adjust or remove as necessary
   prefix: --output_file # just an example, adjust or remove as necessary
   valueFrom: $(inputs.inputBam.nameroot).$(inputs.interval_string).vcf

I would like to know how to use an interval_string to define the path of an input file. For example, if the command above required an input bed file:

--bed passing_regions.$(inputs.interval_string).bed

How can I update the path for the input file for each "interval_string"?

Hello jshelton; thank you for your question,

(I think it should maybe be a new question on its own and not a "answer" to the original question above?)

Can you share a link to which bedtools CWL description you are using?

Log in to answer this question.