Below is a simple workflow that conditionally creates an index file for a FASTA reference file before using it as an input to a CWL tool.
#!/usr/bin/env bash
if ! [ -f data/reference.fa.sa ]; then
bwa index data/reference.fa
fi
for sample in samples; do
bwa mem data/reference.fa $sample > outputs/$sample.sam
done
# we have limited storage space so we
# cleanup indices once we are done
rm -f data/reference.fa.*
The step in this script that creates an index is in a conditional. In the beginner tutorial this script is presented without the conditional but this gives us an opportunity to introduce conditional steps in the intermediate tutorial.
Here is an example workflow using conditional:
#!/usr/bin/env cwl-runner
cwlVersion: v1.2
class: Workflow
requirements:
InlineJavascriptRequirement: {}
StepInputExpressionRequirement: {}
MultipleInputFeatureRequirement: {}
inputs:
reference:
type: File
reads:
type: File[]
outputs:
mapped:
type: File
outputSource: map/reads_stdout
steps:
index:
run: bwa/BWA-Index.cwl
in:
InputFile: reference
IndexName:
valueFrom: $(inputs.InputFile.basename)
out:
- index
when:
$( typeof inputs.InputFile.secondaryFiles === 'undefined' || inputs.InputFile.secondaryFiles.length != 4 )
map:
run: bwa/BWA-Mem.cwl
in:
InputFile: reads
Index:
source:
- index/index
- reference
pickValue: first_non_null
out:
- reads_stdout
where the input can either be:
reference:
class: File
path: /home/pvh/Data/fasta/MN908947_3_Wuhan-Hu-1.fasta
format: edam:format_1929
reads:
- class: File
path: /home/pvh/Data/fastq/foss_caseB_single.fastq.gz
format: edam:format_1931
$namespaces:
edam: http://edamontology.org/
$schemas:
- http://edamontology.org/EDAM_1.18.owl
or (if the index is pre-computed)
reference:
class: File
path: /home/pvh/Data/fasta/MN908947_3_Wuhan-Hu-1.fasta.bwt
format: edam:format_1929
secondaryFiles:
- class: File
path: /home/pvh/Data/fasta/MN908947_3_Wuhan-Hu-1.fasta.ann
- class: File
path: /home/pvh/Data/fasta/MN908947_3_Wuhan-Hu-1.fasta.amb
- class: File
path: /home/pvh/Data/fasta/MN908947_3_Wuhan-Hu-1.fasta.pac
- class: File
path: /home/pvh/Data/fasta/MN908947_3_Wuhan-Hu-1.fasta.sa
reads:
- class: File
path: /home/pvh/Data/fastq/foss_caseB_single.fastq.gz
format: edam:format_1931
$namespaces:
edam: http://edamontology.org/
$schemas:
- http://edamontology.org/EDAM_1.18.owl
Below is a simple workflow that conditionally creates an index file for a FASTA reference file before using it as an input to a CWL tool.
The step in this script that creates an index is in a conditional. In the beginner tutorial this script is presented without the conditional but this gives us an opportunity to introduce conditional steps in the intermediate tutorial.
Here is an example workflow using conditional:
where the input can either be:
or (if the index is pre-computed)