Skip to content

Instantly share code, notes, and snippets.

@edawson
Last active March 3, 2019 17:16
Show Gist options
  • Save edawson/d0dd0f1968ebb4319acb7fbde135e0f7 to your computer and use it in GitHub Desktop.
Save edawson/d0dd0f1968ebb4319acb7fbde135e0f7 to your computer and use it in GitHub Desktop.
An example WDL file which documents some idioms of the language
## Tasks are upper camel-cased
task CheckSex{
File sampleBAM
File sampleIndex
## Optional parameters receive a '?' after the type
Int? diskGB
## select_first can be used to set default values
diskGB = select_first([diskGB, 100])
## Basename function is very useful
String outbase = basename(sampleBAM, ".bam")
## command can use this wacky three arrow syntax, which
## seems to sometimes work better in older Cromwell for
## reasons I don't understand.
command <<<
check_sex_samtools.sh ${sampleBAM} > ${outbase}.sex.txt
>>>
## Not useful in this command, but optional params are accepted like so:
# ${"-@=" + threads}
## and arrays can be serialized to file
# samtools merge -b ${write_lines(input_bams)} > out.bam
## and can be string-joined on the command line
# samtools merge ${sep=" " input_bams}
runtime{
## Docker pulls from public Docker Hub repos
docker : "erictdawson/check-sex"
## CPU is a string but sometimes an int...
cpu : "1"
## Memory is spelled out and uses "GB" for size.
memory : "1 GB"
## String append works for variable interpolation
disks : "local-disk " + diskGB + " HDD"
## Preemptible instances save money, but need to complete
## fast enought to maximize the probability they finish
## before being preempted.
preemptible : 2
}
output{
## Outputs have an equals sign, are in quotations, accept globs,
## and require variable signifiers/brackets.
File sexRatioFile = "${outbase}.sex.txt"
}
}
## Workflows are upper camel-cased
workflow CheckSexWorkflow{
File sampleBAM
File sampleIndex
# The size function in the stdlib can be used to generate
# dynamically-determined disks based on inputs
Int diskGB = ceil(size(sampleBAM, "GB") + 20)
call CheckSex{
## input is lower-case and separated by a colon.
input:
sampleBAM=sampleBAM,
sampleIndex=sampleIndex,
diskGB=diskGB
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment