Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need an Expression Tool mode #413

Open
ghost opened this issue Oct 17, 2018 · 0 comments
Open

Need an Expression Tool mode #413

ghost opened this issue Oct 17, 2018 · 0 comments
Milestone

Comments

@ghost
Copy link

ghost commented Oct 17, 2018

Just like we have a CommandlineTool and Workflow editor, we should have an ExpressionTool editor. This editor would be largely like the CommandlineTool except that it would have no dockerImage field, no resource hints fields etc. and would create an ExpressionTool object. The workflow editor also needs to detect and understand ExpressionTool so it can be dropped into a canvas.

Please see the specification for fields supported by ExpressionTool. As a template, this is a bit like CommandlineTool with most fields stripped out and an expression field substituted for baseCommand

A simple example ExpressionTool is:

class: ExpressionTool
cwlVersion: v1.0
expression: '$({"out": inputs.word1 + inputs.word2 })'
id: expr_tool
inputs:
- id: word1
    label: Word 1
    type: string
- id: word2
    label: Word 2
    type: string
outputs:
- id: out
    label: Word out
    type: string

A more detailed example ExpressionTool, shamelessly lifted from https://www.biostars.org/p/226272/#226360 is:

#!/usr/bin/env cwl-runner
cwlVersion: v1.0
class: ExpressionTool

requirements:
  - class: InlineJavascriptRequirement

inputs:
  filename:
    type: string
    outputBinding:
      outputEval: $(inputs.datafile.basename)
  filecontent:
    type: string
    outputBinding:
      outputEval: $(inputs.datafile.contents)
  datafile:
    type: File
    inputBinding:
      loadContents: true

outputs:
  processedoutput:
    type: Any

expression: "${var lines = inputs.datafile.contents.split('\\n');
               var nblines = lines.length;
               var arrayofarrays = [];
               var setofarrays = {};
               for (var i = 0; i < nblines; i++) {
                  arrayofarrays.push(lines[i].split(','));
                  setofarrays[i] = lines[i].split(',');}
               return { 'processedoutput': setofarrays } ;
              }"

Needed to help out #407

@ghost ghost added this to the v1.1.0 milestone Oct 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants