Question: Can I use output eval with CWL to create the list of output files (i.e. replace the glob results)?
1
gravatar for mavrommatis.konstantinos
12 months 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 modified 3 months ago by michael.franklin10 • written 12 months ago by mavrommatis.konstantinos10

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 12 months ago • written 12 months ago by Tom520
1
gravatar for michael.franklin
3 months ago by
michael.franklin10 wrote:

I'm very late to the party, but you need to return an array of file objects with the minimum properties path and basename:

file.push({
  path: runtime.outdir + "/" + fields[4],
  basename: fields[4]
})
ADD COMMENTlink written 3 months ago by michael.franklin10
0
gravatar for kaushik.ghose
7 months ago by
kaushik.ghose70 wrote:

Hi! I suspect that the best way to do this is to have a small bash script that runs after the main script, reads summary.txt and copies those files to a new directory say outputs and the CWL declares the output to be that directory. The bash script can be either part of the docker image or injected in as a InitialWorkingDirectoryRequirement

ADD COMMENTlink written 7 months ago by kaushik.ghose70
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: 1829 users visited in the last hour