Question: How to import environment variables from the system running it (like Ubuntu) to CWL?
0
gravatar for yuhangr2
12 months ago by
yuhangr20
yuhangr20 wrote:

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 • 297 views
ADD COMMENTlink modified 12 months ago by Tom530 • written 12 months ago by yuhangr20
0
gravatar for Tom
12 months ago by
Tom530
Tom530 wrote:

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 COMMENTlink modified 12 months ago • written 12 months ago by Tom530
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: 1019 users visited in the last hour