* [Java parser](java) which provides only a parser to convert a WDL string into an AST
13
* [wdl4s](http://github.com/broadinstitute/wdl4s) provides Scala bindings for WDL and uses the above Java parser
14
* [PyWDL](https://github.com/broadinstitute/pywdl) provides Python bindings for WDL
15
* [Cromwell](http://github.com/broadinstitute/cromwell) is an engine for running WDL workflows. This uses [wdl4s](http://github.com/broadinstitute/wdl4s)
The Workflow Description Language is a domain specific language for describing tasks and workflows.
39
40
An example WDL file that describes three tasks to run UNIX commands (in this case, `ps`, `grep`, and `wc`) and then link them together in a workflow would look like this:
WDL aims to be able to describe tasks with abstract commands which have inputs. Abstract commands are a template with parts of the command left for the user to provide a value for. In the example above, the `task wc` declaration defines a task with one input (`in_file` of type file) and one output (`count` of type int).
Once tasks are defined, WDL allows you to construct a workflow of these tasks. Since each task defines its inputs and outputs explicitly, you can wire together one task's output to be another task's input and create a dependency graph. An execution engine can then collect the set of inputs it needs from the user to run each task in the workflow up front and then run the tasks in the right order.
WDL also lets you define more advanced structures, like the ability to call a task in parallel (referred to as 'scattering'). In the example below, the `wc` task is being called n-times where n is the length of the `Array[String] str_array` variable. Each element of the `str_array` is used as the value of the `str` parameter in the call to the `wc` task.
We'll use [Cromwell](https://github.com/broadinstitute/cromwell) and [wdltool](https://github.com/broadinstitute/wdltool) to run these examples but you can use any WDL engine of your choice.
114
115
If you don't already have a reference to the Cromwell JAR file, one can be [downloaded](https://github.com/broadinstitute/cromwell/releases)
116
117
If you don't already have a reference to the wdltool JAR file, one can be [downloaded](https://github.com/broadinstitute/wdltool/releases)
WDL has a concept of fully-qualified names. In the above output, `test.hello.name` is a fully-qualified name which should be read as: the `name` input on the `hello` call within workflow `test`. Fully-qualified names are used to unambiguously refer to specific elements of a workflow. All inputs are specified by fully-qualified names and all outputs are returned as fully-qualified names.
`read_string` is a function in the [standard library](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#standard-library), which provides other useful functions for converting outputs to WDL data types.
`read_string` is a function in the [standard library](https://github.com/broadinstitute/wdl/blob/develop/SPEC.md#standard-library), which provides other useful functions for converting outputs to WDL data types.
Here the inputs and outputs are exactly the same as previous examples, however the intermediate output file name of this task is named differently for every invocation.
301
302
##Aliasing Calls
303
304
Say we wanted to call the `hello` task twice. Simply adding two `call hello` statements to the body of `workflow test` would result in non-unique fully-qualified names. To resolve this issue, `call` statements can be aliased using an `as` clause:
A `call` can have an optional section to define inputs. As seen below, the key/value pairs represent the name of the input on the left-hand side and the expression for the input's value on the right-hand side:
So far every example has used the default type of `String` for every input. Passing files along to tasks is simply a matter of defining the input type as `File`:
The `read_int()` function here would read the contents of its parameter, and interpret the first line as an integer and return that value as a WDL `Int` type.
461
462
If I specified a file called `test_file` with the contents of:
463
464
```
465
foo
466
bar
467
baz
468
quux
469
```
470
471
And then the inputs JSON file would be:
472
473
```
474
{
475
"test.grep.file": "test_file"
476
}
477
```
478
479
The result of running this would be:
480
481
```
482
$ java -jar cromwell.jar run grep.wdl grep.json
483
... truncated ...
484
{
485
"test.grep.count": 3
486
}
487
```
488
489
##Scatter/Gather
490
491
Scatter blocks can be used to run the same call multiple times but only varying a specific parameter on each invocation. Consider the following example:
This example calls the `analysis` task once for each element in the array that the `prepare` task outputs. The resulting outputs of this workflow would be: