This is a test version of Biostars. For the public version, visit https://www.biostars.org.
cwl and resolution of enviroment variables

Hello,

I want to make CommandLineTool to wrap the platypus variant caller. Platypus expects to invoked as:


python Platypus.py <arg>

In other words, by default it doesn't have a handy wrapper script. Obviously, I could write one but I thought I ought to be handle a scenario like this in CWL as follows.

In my envar-global.yml I have:


class: EnvVarRequirement
envDef:
  - envName: "PLATYPUS"
    envValue: "/path/to/Platypus_0.8.1"

In my platypus.cwl, I have


baseCommand: [python, $PLATYPUS/Platypus.py]

However, when the command is invoked it looks the variable $PLATYPUS is not being resolved but inserted literally into the command line.


[step platyus] start
[job platyus] /stornext/HPCScratch/home/thomas.e/tmp/tmpCOMw0f$ /bin/sh \
    -c \
    'python' '$PLATYPUS/Platypus.py' '--bamFiles=/stornext/HPCScratch/home/thomas.e/tmp/tmpJtjVOc/stg695d99c7-792c-4f68-87da-62d472cec7c9/S1_R1.fastq.trimmed.human.sam' '--output=S1_R1.fastq.trimmed.human.vcf' '--refFile=/home/thomas.e/home/dev/Homo_sapiens.GRCh38.dna.toplevel.fa'
python: can't open file '$PLATYPUS/Platypus.py': [Errno 2] No such file or directory

Is the expected behaviour? Is there a correct way to handle this sort of scenario?

cwl

1 answer

This should be expected behavior. Values in baseCommand are not executed in a shell and thus environment variables not evaluated. I personally would recommend to make Platypus.py an executable and invoke it like this:

baseCommand: [Platypus.py]

or if cwl-runner cannot find it:

baseCommand: [(absolute path)/Platypus.py]

Note: Some programming languages distinguish between ["command", "arg1"] and "command arg1". Only in the second version the command will be executed in shell and environment variables are evaluated.

Log in to answer this question.