Question: How to import environment variables from the system running it (like Ubuntu) to CWL?
0
gravatar for yuhangr2
8 weeks 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 • 141 views
ADD COMMENTlink modified 8 weeks ago by Tom430 • written 8 weeks ago by yuhangr20
0
gravatar for Tom
8 weeks ago by
Tom430
Bielefeld University, CeBiTec, Germany
Tom430 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 8 weeks ago • written 8 weeks ago by Tom430
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: 1048 users visited in the last hour