Option 1
The script used in degradation.cwl does not have an option to give bai files as an input explicitly. It rather needs/searches for the bai file within the same path where the bam file exists. Hence giving bai as secondary file worked.
Option 2 Trial
index_bam.cwl only returns a bai file and does not return any bam file. So giving bam as output would not work I guess. Anyways I tried and the results have been pasted down.
index_bam.cwl (Working code)
cwlVersion: v1.0
class: CommandLineTool
baseCommand: [samtools]
doc: "samtools: index"
inputs:
bam:
type: File
inputBinding:
position: 1
prefix: index
outputs:
bai:
type: stdout
stdout: $(inputs.bam.basename).bai
index_bam.cwl (NOT Working code)
cwlVersion: v1.0
class: CommandLineTool
baseCommand: [samtools]
doc: "samtools: index"
inputs:
bam:
type: File
inputBinding:
position: 1
prefix: index
outputs:
indexed_bam:
type: File
secondaryFiles: .bai
outputBinding:
glob: $(inputs.bam.basename)
ERROR
cwl-runner index_bam.cwl index_bam.yml
conda/bin/cwl-runner 1.0.20180521150620
Resolved 'index_bam.cwl' to 'index_bam.cwl'
[job index_bam.cwl] /tmp/tmp7UywDj$ samtools \
index \
/tmp/tmpZe6GNu/stga7547f8b-8d5f-48d5-8d84-4348bb8e95ae/SampleA.bam
[job index_bam.cwl] Job error:
Error collecting output for parameter 'indexed_bam':
index_bam.cwl:27:4: Did not find output file with glob pattern: ‘[‘SampleA.bam']'
[job index_bam.cwl] completed permanentFail
{}