Codebase list ctdconverter / ad83ed4
Using ruamel.yaml to generate easier-to-read output files. Luis de la Garza 6 years ago
2 changed file(s) with 24 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
33 ## Dependencies
44 `CTDConverter` has the following python dependencies:
55
6 - [CTDopts]
6 - [CTDopts]
77 - `lxml`
8 - `pyyaml`
8 - `ruamel.yaml`
99
1010 ### Installing Dependencies
1111 We recommend the use of `conda` to manage all dependencies. If you're not sure what `conda` is, make sure to read the [using-conda](conda documentation).
1212
1313 The easiest way to get you started with CTD conversion is to create a `conda` environment on which you'll install all dependencies. Using environments in `conda` allows you to have parallel, independent python environments, thus avoiding conflicts between libraries. If you haven't installed `conda`, check [conda-install](conda's installation guide).
1414
15 Once you've installed `conda`, create an environment named `ctd-converter` and list all dependencies, like so:
15 Once you've installed `conda`, create an environment named `ctd-converter`, like so:
1616
1717 ```sh
18 $ conda create --name ctd-converter --channel workflowconversion ctdopts lxml pyyaml libxml2=2.9.2
18 $ conda create --name ctd-converter
1919 ```
20
21 [CTDopts] is a python module available on the `workflowconversion` channel in the Anaconda cloud. Of course, you could just download [CTDopts] and make it available through your `PYTHONPATH` environment variable, if you're into that. To get more information about how to install python modules, visit: https://docs.python.org/2/install/.
22
23 `lxml` depends on `libxml2`. When you install `lxml` you'll get the latest version of `libxml2` (2.9.4) by default. You would usually want the latest version, but there is, however, a bug in validating XML files against a schema in this version of `libxml2`.
24
25 If you require validation of input CTDs against a schema (which we recommend), you will need to downgrade to the latest known version of `libxml2` that works, namely, 2.9.2.
2620
2721 You will now need to *activate* the environment by executing the following command:
2822
2923 ```sh
3024 $ source activate ctd-converter
3125 ```
26
27 Install the required dependencies as follows (the order of execution **is actually important**, due to transitive dependencies):
28
29 ```sh
30 $ conda install --channel workflowconversion ctdopts
31 $ conda install lxml
32 $ conda install --channel conda-forge ruamel.yaml
33 $ conda install libxml2=2.9.2
34 ```
35
36 `lxml` depends on `libxml2`. When you install `lxml` you'll get the latest version of `libxml2` (2.9.4) by default. You would usually want the latest version, but there is, however, a bug in validating XML files against a schema in this version of `libxml2`.
37
38 If you require validation of input CTDs against a schema (which we recommend), you will need to downgrade to the latest known version of `libxml2` that works, namely, 2.9.2.
39
40 You could just download dependencies manually and make them available through your `PYTHONPATH` environment variable, if you're into that. To get more information about how to install python modules without using `conda`, visit: https://docs.python.org/2/install/.
3241
3342 ## How to install `CTDConverter`
3443 `CTDConverter` is not a python module, rather, a series of scripts, so installing it is as easy as downloading the source code from https://github.com/genericworkflownodes/CTDConverter. Once you've installed all dependencies, downloaded `CTDConverter` and activated your `conda` environment, you're good to go.
88 # since cwlgen is just "fancy classes" around the yaml.dump() method, we implemented our own generation of yaml
99
1010
11 import yaml
12 try:
13 from yaml import CLoader as Loader
14 except ImportError:
15 from yaml import Loader
11 import ruamel.yaml as yaml
1612
1713 from CTDopts.CTDopts import _InFile, _OutFile, ParameterGroup, _Choices, _NumericRange, _FileFormat, ModelError, _Null
1814 from common import utils, logger
7672
7773 stream = file(output_file, 'w')
7874 stream.write(CWL_SHEBANG + '\n\n')
79 yaml.dump(cwl_tool, stream, default_flow_style=True)
75 stream.write("# This CWL file was automatically generated using CTDConverter.\n")
76 stream.write("# Visit https://github.com/WorkflowConversion/CTDConverter for more information.\n\n")
77 yaml.dump(cwl_tool, stream, default_flow_style=False)
8078 stream.close()
8179
8280 return 0
10199 for param in utils.extract_and_flatten_parameters(ctd_model):
102100 if param.name in args.blacklisted_parameters:
103101 continue
104
102
105103 param_name = utils.extract_param_name(param)
106104 cwl_fixed_param_name = fix_param_name(param_name)
107105 hardcoded_value = args.parameter_hardcoder.get_hardcoded_value(param_name, ctd_model.name)