Hi CWL folks,
I’m trying to use an input from a workflow’s inputs
section as a variable in a valueFrom expression.
The following works, but hardcodes to extract a substring of 11 characters from nameroot:
cwlVersion: v1.2
class: Workflow
requirements:
ScatterFeatureRequirement: {}
StepInputExpressionRequirement: {}
InlineJavascriptRequirement: {}
inputs:
InputReadsMultipleSamples:
type:
type: array
items:
type: array
items: File
steps:
quant:
run: quant.cwl
scatter:
- InputReads
- QuantOutfolder
scatterMethod: dotproduct
in:
InputReads: InputReadsMultipleSamples
QuantOutfolder:
source: InputReadsMultipleSamples
valueFrom: $(self[0].nameroot.substring(0,11))
Index: index/index
out: [outFolder]
outputs:
finalOut:
type: Directory[]
outputSource: quant/outFolder
The workflow takes an array of File arrays (InputReadsMultipleSamples). With the latter being one or more files belonging to a single sample. The goal is to generically find a name for the output folder (QuantOutfolder), e.g. if the sample files are called sample_001_R1.fastq.gz
and sample_001_R2.fastq.gz
it shall simply return the matching part sample_001
. Since I was not successful extracting the matching part, and it might sometimes be desired to explicitly take x chars from the file names, I wanted to add an input numCharsFileName: int?
to use in the substring(0, numCharsFileName)
.
Is this possible? Or can somebody guide me on a more sophisticated way?
Thanks!