How to import environment variables from the system running it (like Ubuntu) to CWL?
1
0
Entering edit mode
5.4 years ago
yuhangr2 • 0

Does anyone know if CWL is capable of create a random number to an output file, like the environment variable $RANDOM in UNIX? Or how to import the environment variables of one's system, like in Ubuntu, to CWL?

cwl • 914 views
ADD COMMENT
0
Entering edit mode
5.4 years ago
Tom ▴ 540

If you just need a random number i would recommend solving this through a javascript expression.

As an expression tool, this might look like:

cwlVersion: v1.0
class: ExpressionTool

requirements:
  InlineJavascriptRequirement: {}

inputs:
  min:
    type: int
  max:
    type: int

outputs:
  random_integer:
    type: int

expression: |
  ${
    var randomInt;
    var min = Math.ceil(inputs.min);
    var max = Math.floor(inputs.max);
    randomInt = Math.floor(Math.random() * (max - min + 1)) + min;
    return {"random_integer": randomInt};
  }

You can also just add a javascript expression directly into your tool or workflow, without the overhead of an expression tool. The javascript math is plucked from stackoverflow, but it looks like it should provide random integers.

ADD COMMENT

Login before adding your answer.

Traffic: 2734 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6