Hi,
I have a tool that is creating a number of files and stores their names in an another file summary.txt
. The program generates a number of files with various (random) filenames, and I want to select only few based on some filters based on values inside the summary.txt
file.
Is there a way to load the contents of this summary.txt
file (using loadContents: true etc) and select the list of the files from it and return it as an array of Files? In essence I would like to replace the list that glob *
would return with my list of files.
I have tried something like:
class: CommandLineTool
cwlVersion: v1.0
<various lines>
outputs:
- id: outputFileList
type: 'File[]'
outputBinding:
loadContents: true
glob: summary.txt
outputEval: |
${
var str = self[0].contents
var file=[]
var lines=str.split(/\n/)
for( var i = 1 ; i < lines.length; i ++) {
if(lines[i] === '' ){continue}
var fields=lines[i].split(",")
file.push( runtime.outdir + "/" + fields[4] )
}
return( file )
}
Which returns the list of the files, but they are treated as list of Strings, and downstream tools cannot access them.
Thanks in advance for your help
This javascript code only concatenates strings and returns them, not actual files. I am not sure if what you ask can be done in a single CommandLineTool. I suspect you need a workflow to solve this.
*edit: Let us know if you need suggestions on how to build said workflow.