WDL run through input text file and sub into command

68 views Asked by At

I want my WDL script to run through a txt file which contains the ID for my fastq files and sub these into my command. Any idea where I'm going wrong?

WDL code:

version 1.0

workflow SampleLoop {
input {
File sampleFile
String outputDir
Int qualityThreshold
Int numProc
}

call FilterSeq {
input:
sample = read_lines(sampleFile),
outputDir = outputDir,
qualityThreshold = qualityThreshold,
numProc = numProc
}
}

task FilterSeq {
input {
Array[String] sample
String outputDir
Int qualityThreshold
Int numProc
}
command <<<
for s in ${sample};
do
FilterSeq.py quality -s ${outputDir}/${s}_R1.fq -q ${qualityThreshold} --log ${s}_R1_quality_log --outdir ${outputDir} --nproc ${numProc}
done
>>>
runtime {
continueOnReturnCode: true
}
}

inputs.json file:

{
  "SampleLoop.outputDir": "~/pipeline/test",
  "SampleLoop.numProc": "28",
  "SampleLoop.sampleFile": "~/pipeline/fastqs.txt",
  "SampleLoop.qualityThreshold": "20"
}

fastqs.txt file:

A11-A11_BD801
A11-A11_BD836
A12-A12_BD801
A12-A12_BD836
A13-A13_BD801
A13-A13_BD836
A14-A14_BD801
A14-A14_BD836
A15-A15_BD801
A15-A15_BD836

The command is running now and I'm getting no errors but it isn't carrying out the command.

1

There are 1 answers

0
DavyCats On

Using the heredoc-like command syntax (<<< >>>) will cause WDL to interpret ${} as plain text, to be used unchanged in the command. You will need to use the ~{} syntax for your placeholder instead:

command <<<
  for s in ~{sep=" " sample};
    do
      FilterSeq.py quality -s ~{outputDir}/~{s}_R1.fq -q ~{qualityThreshold} --log ~{s}_R1_quality_log --outdir ~{outputDir} --nproc ~{numProc}
    done
>>>

or change the command to section to use normal brackets (then either placeholder syntax can be used):

command {
  for s in ${sep=" " sample};
    do
      FilterSeq.py quality -s ${outputDir}/${s}_R1.fq -q ${qualityThreshold} --log ${s}_R1_quality_log --outdir ${outputDir} --nproc ${numProc}
    done
}

You'll also need to add sep=" " to the placeholder for the sample array to tell WDL to separate the values with a space.