1
$\begingroup$

I'm updating my WDL from draft 2 (whichs works fine) to version 1. I'm stuck with a Py snippet

task getReadGroup {

    input {
        String inputFile
    }

    command {echo input = ${inputFile}}

    # command <<<
    # python <<CODE
    # print ("${inputFile}".strip().split('/'))
    # CODE
    # >>>

    output {
    Array[String] o = read_lines(stdout())
    }
}

This command gives the expected result:

input = /mnt/lustre/working/genomeinfo/data/20191015_LongRead/20191015_LongRead_1/data/LXBAB201271/LXBAB201271/LXBAB201271/20190417_0612_1-A7-D7_PAD44174_42dcde1a/fast5/test/

But the commented out python code:

print ("${inputFile}".strip().split('/'))

Gives an empty list - "${inputFile}" is empty in the code command for some reason!

Any ideas? I've tried using a File instead of String to make it just like the example in the docs (below) other than that I see no diff:

task heredoc {
  input {
    File in
  }

  command<<<
  python <<CODE
    with open("${in}") as fp:
      for line in fp:
        if not line.startswith('#'):
          print(line.strip())
  CODE
  >>>
}
$\endgroup$
6
  • $\begingroup$ print (inputFile.strip().split('/')). ?? $\endgroup$
    – pippo1980
    Jan 7 at 5:31
  • $\begingroup$ Is that a wild guess or do you know? $\endgroup$ Jan 7 at 5:32
  • $\begingroup$ Don’t know what is WDL and how it works but it’s like the variable it’s inputFile , and $ goes with echo, but could be wrong. Can’t try by my own given I don’t know WDL $\endgroup$
    – pippo1980
    Jan 7 at 5:53
  • $\begingroup$ Given u don't know what WDL is it would be best if you didn't make suggestions... $\endgroup$ Jan 7 at 12:13
  • $\begingroup$ Fine github.com/openwdl/wdl/blob/main/versions/1.0/… got the use of placeholders in whatever WDL is $\endgroup$
    – pippo1980
    Jan 7 at 19:46
2
$\begingroup$

Complements of Phil Shapiro;

Use ~{} instead of ${}.

So this example from the current docs is wrong:

task heredoc {
  input {
    File in
  }

  command<<<
  python <<CODE
    with open("${in}") as fp:
      for line in fp:
        if not line.startswith('#'):
          print(line.strip())
  CODE
  >>>
}

It should be :

task heredoc {
  input {
    File in
  }

  command<<<
  python <<CODE
    with open("~{in}") as fp:
      for line in fp:
        if not line.startswith('#'):
          print(line.strip())
  CODE
  >>>
}
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.