I have a CWL file which has bam file as one of the inputs and takes bai file as secondary files. The script as CommandLineTool works and gives results when run in cwl-runner.
cat degradation.cwl
cwlVersion: v1.0
class: CommandLineTool
baseCommand: [python, degradation.py]
inputs:
annotation:
type: File
inputBinding:
position: 2
prefix: -a
bam:
type: File
inputBinding:
position: 1
prefix: -n
secondaryFiles: .bai
Now I would like to add this script as one of the steps in the workflow. How can this be done ?
cat workflow.cwl
cwlVersion: v1.0
class: Workflow
inputs:
------
------
outputs:
alignment_out:
type: File
outputSource: star/star_bam
steps:
star:
run: star.cwl
in: ---
-------
out: [star_bam]
bam_indexing:
run: index_bam.cwl
in:
bam: star/star_bam
out: [bai]
rna_degradation:
run: degradation.cwl
in:
annotation: annotation
bam: star/star_bam
bai: bam_indexing/bai
Error
expects secondaryFiles: .bai but
source 'star_bam' does not include secondaryFiles.
To fix, add secondaryFiles: .bai to definition of 'star_bam'.
The star_bamis an output from the step star and bai is an output from another step bam_indexing.
In that case, how could baibe given as an input(secondaryFile) to the step rna_degradation
Option 1 The script used in
degradation.cwldoes not have an option to givebaifiles as an input explicitly. It rather needs/searches for thebaifile within the same path where thebamfile exists. Hence givingbaias secondary file worked.Option 2 Trial
index_bam.cwlonly returns abaifile and does not return anybamfile. So givingbamas output would not work I guess. Anyways I tried and the results have been pasted down.index_bam.cwl (Working code)
index_bam.cwl (NOT Working code)
ERROR
Try adding an initial work dir requirement
index_bam.cwl (NOT Working code)
As another note, if you are using commonly used bioinformatics tools, it may be useful for you to try one of the prewritten CWL scripts here: https://github.com/common-workflow-language/workflows/tree/master/tools for your tools to hopefully make things run well without too much effort on your end. There is even a
samtools-index.cwlavailable.Yes, makes sense to use the pre-written codes. Thank you !!
By adding
InitialWorkDirRequirement, the scriptindex_bam.cwlcould capturebamandbaioutputscat index_bam.cwl
But still have problems in the workflow when trying to input the
secondaryfile outputs from the stepbam_indexingto the steprun_degradationThe step
run_degradationis still asking forbaiinputcat workflow.cwl
workflow.cwl:149:3: Step is missing required parameter 'bai'
Line 149 is the line with
in:of the stepdegradation.cwlin theworkflow.cwlIn your
degradation.cwlscript remove thebaientry underinputsAh.... my bad. I thought I removed it, but hadn't.
With that line removed it works. Thank you...