Question: Can I use output eval with CWL to create the list of output files (i.e. replace the glob results)?
0
gravatar for mavrommatis.konstantinos
6 weeks ago by

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

ADD COMMENTlink written 6 weeks ago by mavrommatis.konstantinos0

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.

ADD REPLYlink modified 5 weeks ago • written 5 weeks ago by Tom250
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 983 users visited in the last hour