https://github.com/multimeric/wdlparserpackaging
A repo for packaging the official Python WDL parser
https://github.com/multimeric/wdlparserpackaging
Last synced: 12 months ago
JSON representation
A repo for packaging the official Python WDL parser
- Host: GitHub
- URL: https://github.com/multimeric/wdlparserpackaging
- Owner: multimeric
- License: gpl-3.0
- Created: 2018-12-19T00:37:10.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-19T05:51:25.000Z (over 7 years ago)
- Last Synced: 2025-03-15T22:09:03.491Z (about 1 year ago)
- Language: Python
- Size: 26.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# WDL Parser
This repo contains code used to publish pip packages for the parsers located in the [official WDL repository](https://github.com/openwdl/wdl).
Using those packages, you can parse WDL workflows under any version of the WDL specification.
## Installation
To install the parsers, run:
```bash
pip install wdl-parser
```
## Usage
### Direct Import
The WDL parsers are provided within one package named `wdl_parser`.
One module exists inside this for each version of the spec, with all hyphens and dots replaced by underscores.
Thus, the modules available to import are:
* `wdl_parser.version_1_0`
* `wdl_parser.development`
* `wdl_parser.draft_2`
* `wdl_parser.draft_3`
Each of these modules exposes a `parse` function, which takes a string containing the WDL to parse.
For example:
```python
from wdl_parser import draft_2
with open('./gatk4-data-processing/processing-for-variant-discovery-gatk4.wdl') as wdlfile:
tree = draft_2.parse(wdlfile.read())
```
### Parser Dictionary
Alternatively, if you want to access a parser based on its official name, you can import the base module, and access
the parser dictionary like this:
```python
import wdl_parser
with open('./gatk4-data-processing/processing-for-variant-discovery-gatk4.wdl') as wdlfile:
tree = wdl_parser.parsers['draft-2'].parse(wdlfile.read())
```
### Operating on the AST
Once you have the AST, refer to the [Hermes documentation](https://github.com/scottfrazer/hermes/blob/develop/DOCS.md) for more
information on how to use it.