I'm writing an expression tool in CWL to handle getting an array of file names based on extension.
In a directory that contains .bed, .vcf.gz, I'd like to return an array of vcf.gz files. It doesn't seem like file.nameext is working as I expect it to.
class: ExpressionTool
cwlVersion: v1.0
inputs:
vcfsdir: Directory
outputs:
samples: string[]
vcfgzs:
type: File[]
secondaryFiles: [.tbi]
beds: File[]
requirements:
InlineJavascriptRequirement: {}
expression: |
${
var vcfgzs = [];
for (var i = 0; i < inputs.vcfsdir.listing.length; i++) {
var file = inputs.vcfsdir.listing[i];
if (file.nameext == '.gz') {
var main = file;
vcfgzs.push(main);
}
}
return {"vcfgzs": vcfgzs};
The return output I'm getting is simply:
{
"vcfgzs": []
}
I've confirmed that this bug also exists in the CWL reference runner: https://github.com/common-workflow-language/cwltool/issues/1074