|
3 | 3 | # External libraries
|
4 | 4 | import ruamel.yaml
|
5 | 5 |
|
| 6 | +from cwlgen.commandlinebinding import CommandLineBinding |
6 | 7 | from .common import CWL_VERSIONS, DEF_VERSION, CWL_SHEBANG, Namespaces, Parameter
|
7 | 8 | from .requirements import *
|
8 | 9 | from .utils import literal, literal_presenter, Serializable
|
|
15 | 16 | # Class(es) ------------------------------
|
16 | 17 |
|
17 | 18 |
|
| 19 | +class CommandOutputBinding(Serializable): |
| 20 | + ''' |
| 21 | + Describes how to generate an output parameter based on the files produced. |
| 22 | + ''' |
| 23 | + |
| 24 | + def __init__(self, glob=None, load_contents=None, output_eval=None): |
| 25 | + ''' |
| 26 | + :param glob: Find corresponding file(s) |
| 27 | + :type glob: STRING |
| 28 | + :param load_contents: For each file matched, read up to the 1st 64 KiB of text and |
| 29 | + place it in the contents field |
| 30 | + :type load_contents: BOOLEAN |
| 31 | + :param output_eval: Evaluate an expression to generate the output value |
| 32 | + :type output_eval: STRING |
| 33 | + ''' |
| 34 | + self.glob = glob |
| 35 | + self.loadContents = load_contents |
| 36 | + self.outputEval = output_eval |
| 37 | + |
| 38 | + |
| 39 | +class CommandInputParameter(Parameter): |
| 40 | + """ |
| 41 | + An input parameter for a :class:`cwlgen.CommandLineTool`. |
| 42 | + """ |
| 43 | + |
| 44 | + parse_types = {"inputBinding": [CommandLineBinding]} |
| 45 | + |
| 46 | + def __init__(self, param_id, label=None, secondary_files=None, param_format=None, |
| 47 | + streamable=None, doc=None, input_binding=None, default=None, param_type=None): |
| 48 | + ''' |
| 49 | + :param param_id: unique identifier for this parameter |
| 50 | + :type param_id: STRING |
| 51 | + :param label: short, human-readable label |
| 52 | + :type label: STRING |
| 53 | + :param secondary_files: If type is a file, describes files that must be |
| 54 | + included alongside the primary file(s) |
| 55 | + :type secondary_files: STRING |
| 56 | + :param param_format: If type is a file, uri to ontology of the format or exact format. |
| 57 | + :type param_format: STRING |
| 58 | + :param streamable: If type is a file, true indicates that the file is read or written |
| 59 | + sequentially without seeking |
| 60 | + :type streamable: BOOLEAN |
| 61 | + :param doc: documentation |
| 62 | + :type doc: STRING |
| 63 | + :param input_binding: describes how to handle the input |
| 64 | + :type input_binding: :class:`cwlgen.CommandLineBinding` object |
| 65 | + :param default: default value |
| 66 | + :type default: STRING |
| 67 | + :param param_type: type of data assigned to the parameter corresponding to CWLType |
| 68 | + :type param_type: STRING |
| 69 | + ''' |
| 70 | + Parameter.__init__(self, param_id=param_id, label=label, |
| 71 | + secondary_files=secondary_files, param_format=param_format, |
| 72 | + streamable=streamable, doc=doc, param_type=param_type) |
| 73 | + self.inputBinding = input_binding |
| 74 | + self.default = default |
| 75 | + |
| 76 | + |
| 77 | +class CommandOutputParameter(Parameter): |
| 78 | + ''' |
| 79 | + An output parameter for a :class:`cwlgen.CommandLineTool`. |
| 80 | + ''' |
| 81 | + |
| 82 | + parse_types = {"outputBinding": [CommandOutputBinding]} |
| 83 | + |
| 84 | + def __init__(self, param_id, label=None, secondary_files=None, param_format=None, |
| 85 | + streamable=None, doc=None, output_binding=None, param_type=None): |
| 86 | + ''' |
| 87 | + :param param_id: unique identifier for this parameter |
| 88 | + :type param_id: STRING |
| 89 | + :param label: short, human-readable label |
| 90 | + :type label: STRING |
| 91 | + :param secondary_files: If type is a file, describes files that must be |
| 92 | + included alongside the primary file(s) |
| 93 | + :type secondary_files: STRING |
| 94 | + :param param_format: If type is a file, uri to ontology of the format or exact format |
| 95 | + :type param_format: STRING |
| 96 | + :param streamable: If type is a file, true indicates that the file is read or written |
| 97 | + sequentially without seeking |
| 98 | + :type streamable: BOOLEAN |
| 99 | + :param doc: documentation |
| 100 | + :type doc: STRING |
| 101 | + :param output_binding: describes how to handle the output |
| 102 | + :type output_binding: :class:`cwlgen.CommandOutputBinding` object |
| 103 | + :param param_type: type of data assigned to the parameter corresponding to CWLType |
| 104 | + :type param_type: STRING |
| 105 | + ''' |
| 106 | + Parameter.__init__(self, param_id, label, secondary_files, param_format, streamable, |
| 107 | + doc, param_type) |
| 108 | + self.outputBinding = output_binding |
| 109 | + |
| 110 | + |
18 | 111 | class CommandLineTool(Serializable):
|
19 | 112 | '''
|
20 | 113 | Contain all informations to describe a CWL command line tool.
|
21 | 114 | '''
|
22 | 115 |
|
23 | 116 | __CLASS__ = 'CommandLineTool'
|
24 | 117 |
|
| 118 | + parse_types = {'inputs': [[CommandInputParameter]], "outputs": [[CommandOutputParameter]]} |
| 119 | + ignore_fields_on_parse = ["namespaces", "class"] |
| 120 | + ignore_fields_on_convert = ["namespaces", "class", "metadata", "requirements"] |
| 121 | + |
25 | 122 | def __init__(self, tool_id=None, base_command=None, label=None, doc=None,
|
26 | 123 | cwl_version=None, stdin=None, stderr=None, stdout=None, path=None):
|
27 | 124 | '''
|
28 | 125 | :param tool_id: unique identifier for this tool
|
29 |
| - :type tool_id: STRING |
| 126 | + :type tool_id: str |
30 | 127 | :param base_command: command line for the tool
|
31 |
| - :type base_command: STRING | list[STRING] |
| 128 | + :type base_command: str | list[STRING] |
32 | 129 | :param label: label of this tool
|
33 |
| - :type label: STRING |
| 130 | + :type label: str |
34 | 131 | :param doc: documentation for the tool, usually longer than the label
|
35 |
| - :type doc: STRING |
| 132 | + :type doc: str |
36 | 133 | :param cwl_version: version of the CWL tool
|
37 |
| - :type cwl_version: STRING |
| 134 | + :type cwl_version: str |
38 | 135 | :param stdin: path to a file whose contents must be piped into stdin
|
39 |
| - :type stdin: STRING |
| 136 | + :type stdin: str |
40 | 137 | :param stderr: capture stderr into the given file
|
41 |
| - :type stderr: STRING |
| 138 | + :type stderr: str |
42 | 139 | :param stdout: capture stdout into the given file
|
43 |
| - :type stdout: STRING |
| 140 | + :type stdout: str |
44 | 141 |
|
45 | 142 | inputs (:class:`cwlgen.CommandInputParameter` objects),
|
46 | 143 | outputs (:class:`cwlgen.CommandOutputParameter` objects),
|
@@ -72,7 +169,6 @@ def __init__(self, tool_id=None, base_command=None, label=None, doc=None,
|
72 | 169 | self._path = path
|
73 | 170 | self.namespaces = Namespaces()
|
74 | 171 | self.metadata = {}
|
75 |
| - self.ignore_attributes = ["namespaces"] |
76 | 172 |
|
77 | 173 | def get_dict(self):
|
78 | 174 |
|
@@ -113,91 +209,3 @@ def export(self, outfile=None):
|
113 | 209 | out_write.write(CWL_SHEBANG + '\n\n')
|
114 | 210 | out_write.write(rep)
|
115 | 211 | out_write.close()
|
116 |
| - |
117 |
| - |
118 |
| -class CommandInputParameter(Parameter): |
119 |
| - ''' |
120 |
| - An input parameter for a :class:`cwlgen.CommandLineTool`. |
121 |
| - ''' |
122 |
| - |
123 |
| - def __init__(self, param_id, label=None, secondary_files=None, param_format=None, |
124 |
| - streamable=None, doc=None, input_binding=None, default=None, param_type=None): |
125 |
| - ''' |
126 |
| - :param param_id: unique identifier for this parameter |
127 |
| - :type param_id: STRING |
128 |
| - :param label: short, human-readable label |
129 |
| - :type label: STRING |
130 |
| - :param secondary_files: If type is a file, describes files that must be |
131 |
| - included alongside the primary file(s) |
132 |
| - :type secondary_files: STRING |
133 |
| - :param param_format: If type is a file, uri to ontology of the format or exact format. |
134 |
| - :type param_format: STRING |
135 |
| - :param streamable: If type is a file, true indicates that the file is read or written |
136 |
| - sequentially without seeking |
137 |
| - :type streamable: BOOLEAN |
138 |
| - :param doc: documentation |
139 |
| - :type doc: STRING |
140 |
| - :param input_binding: describes how to handle the input |
141 |
| - :type input_binding: :class:`cwlgen.CommandLineBinding` object |
142 |
| - :param default: default value |
143 |
| - :type default: STRING |
144 |
| - :param param_type: type of data assigned to the parameter corresponding to CWLType |
145 |
| - :type param_type: STRING |
146 |
| - ''' |
147 |
| - Parameter.__init__(self, param_id=param_id, label=label, |
148 |
| - secondary_files=secondary_files, param_format=param_format, |
149 |
| - streamable=streamable, doc=doc, param_type=param_type) |
150 |
| - self.inputBinding = input_binding |
151 |
| - self.default = default |
152 |
| - |
153 |
| - |
154 |
| -class CommandOutputParameter(Parameter): |
155 |
| - ''' |
156 |
| - An output parameter for a :class:`cwlgen.CommandLineTool`. |
157 |
| - ''' |
158 |
| - |
159 |
| - def __init__(self, param_id, label=None, secondary_files=None, param_format=None, |
160 |
| - streamable=None, doc=None, output_binding=None, param_type=None): |
161 |
| - ''' |
162 |
| - :param param_id: unique identifier for this parameter |
163 |
| - :type param_id: STRING |
164 |
| - :param label: short, human-readable label |
165 |
| - :type label: STRING |
166 |
| - :param secondary_files: If type is a file, describes files that must be |
167 |
| - included alongside the primary file(s) |
168 |
| - :type secondary_files: STRING |
169 |
| - :param param_format: If type is a file, uri to ontology of the format or exact format |
170 |
| - :type param_format: STRING |
171 |
| - :param streamable: If type is a file, true indicates that the file is read or written |
172 |
| - sequentially without seeking |
173 |
| - :type streamable: BOOLEAN |
174 |
| - :param doc: documentation |
175 |
| - :type doc: STRING |
176 |
| - :param output_binding: describes how to handle the output |
177 |
| - :type output_binding: :class:`cwlgen.CommandOutputBinding` object |
178 |
| - :param param_type: type of data assigned to the parameter corresponding to CWLType |
179 |
| - :type param_type: STRING |
180 |
| - ''' |
181 |
| - Parameter.__init__(self, param_id, label, secondary_files, param_format, streamable, |
182 |
| - doc, param_type) |
183 |
| - self.outputBinding = output_binding |
184 |
| - |
185 |
| - |
186 |
| -class CommandOutputBinding(Serializable): |
187 |
| - ''' |
188 |
| - Describes how to generate an output parameter based on the files produced. |
189 |
| - ''' |
190 |
| - |
191 |
| - def __init__(self, glob=None, load_contents=None, output_eval=None): |
192 |
| - ''' |
193 |
| - :param glob: Find corresponding file(s) |
194 |
| - :type glob: STRING |
195 |
| - :param load_contents: For each file matched, read up to the 1st 64 KiB of text and |
196 |
| - place it in the contents field |
197 |
| - :type load_contents: BOOLEAN |
198 |
| - :param output_eval: Evaluate an expression to generate the output value |
199 |
| - :type output_eval: STRING |
200 |
| - ''' |
201 |
| - self.glob = glob |
202 |
| - self.loadContents = load_contents |
203 |
| - self.outputEval = output_eval |
|
0 commit comments