Mercurial > repos > fubar > tool_factory_2
annotate toolfactory/galaxyxml/tool/parameters/__init__.py @ 38:a30536c100bf draft
Updated history outputs
author | fubar |
---|---|
date | Wed, 12 Aug 2020 01:43:46 -0400 |
parents | ce2b1f8ea68d |
children |
rev | line source |
---|---|
38 | 1 from builtins import object |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
2 from builtins import str |
38 | 3 |
4 from galaxyxml import Util | |
5 | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
6 from lxml import etree |
38 | 7 |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
8 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
9 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
10 class XMLParam(object): |
36 | 11 name = "node" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
12 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
13 def __init__(self, *args, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
14 # http://stackoverflow.com/a/12118700 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
15 self.children = [] |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
16 kwargs = {k: v for k, v in list(kwargs.items()) if v is not None} |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
17 kwargs = Util.coerce(kwargs, kill_lists=True) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
18 kwargs = Util.clean_kwargs(kwargs, final=True) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
19 self.node = etree.Element(self.name, **kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
20 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
21 def append(self, sub_node): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
22 if self.acceptable_child(sub_node): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
23 # If one of ours, they aren't etree nodes, they're custom objects |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
24 if issubclass(type(sub_node), XMLParam): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
25 self.node.append(sub_node.node) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
26 self.children.append(sub_node) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
27 else: |
36 | 28 raise Exception( |
38 | 29 "Child was unacceptable to parent (%s is not appropriate for %s)" % (type(self), type(sub_node)) |
36 | 30 ) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
31 else: |
36 | 32 raise Exception( |
38 | 33 "Child was unacceptable to parent (%s is not appropriate for %s)" % (type(self), type(sub_node)) |
36 | 34 ) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
35 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
36 def validate(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
37 # Very few need validation, but some nodes we may want to have |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
38 # validation routines on. Should only be called when DONE. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
39 for child in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
40 # If any child fails to validate return false. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
41 if not child.validate(): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
42 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
43 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
44 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
45 def cli(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
46 lines = [] |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
47 for child in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
48 lines.append(child.command_line()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
49 # lines += child.command_line() |
36 | 50 return "\n".join(lines) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
51 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
52 def command_line(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
53 return None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
54 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
55 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
56 class RequestParamTranslation(XMLParam): |
36 | 57 name = "request_param_translation" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
58 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
59 def __init__(self, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
60 self.node = etree.Element(self.name) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
61 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
62 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
63 return isinstance(child, RequestParamTranslation) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
64 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
65 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
66 class RequestParam(XMLParam): |
36 | 67 name = "request_param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
68 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
69 def __init__(self, galaxy_name, remote_name, missing, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
70 # TODO: bulk copy locals into self.attr? |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
71 self.galaxy_name = galaxy_name |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
72 # http://stackoverflow.com/a/1408860 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
73 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
74 super(RequestParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
75 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
76 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
77 return isinstance(child, AppendParam) and self.galaxy_name == "URL" |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
78 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
79 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
80 class AppendParam(XMLParam): |
36 | 81 name = "append_param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
82 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
83 def __init__(self, separator="&", first_separator="?", join="=", **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
84 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
85 super(AppendParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
86 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
87 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
88 return isinstance(child, AppendParamValue) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
89 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
90 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
91 class AppendParamValue(XMLParam): |
36 | 92 name = "value" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
93 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
94 def __init__(self, name="_export", missing="1", **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
95 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
96 super(AppendParamValue, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
97 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
98 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
99 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
100 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
101 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
102 class EdamOperations(XMLParam): |
36 | 103 name = "edam_operations" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
104 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
105 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
106 return issubclass(type(child), EdamOperation) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
107 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
108 def has_operation(self, edam_operation): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
109 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
110 Check the presence of a given edam_operation. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
111 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
112 :type edam_operation: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
113 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
114 for operation in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
115 if operation.node.text == edam_operation: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
116 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
117 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
118 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
119 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
120 class EdamOperation(XMLParam): |
36 | 121 name = "edam_operation" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
122 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
123 def __init__(self, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
124 super(EdamOperation, self).__init__() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
125 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
126 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
127 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
128 class EdamTopics(XMLParam): |
36 | 129 name = "edam_topics" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
130 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
131 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
132 return issubclass(type(child), EdamTopic) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
133 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
134 def has_topic(self, edam_topic): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
135 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
136 Check the presence of a given edam_topic. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
137 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
138 :type edam_topic: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
139 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
140 for topic in self.children: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
141 if topic.node.text == edam_topic: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
142 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
143 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
144 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
145 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
146 class EdamTopic(XMLParam): |
36 | 147 name = "edam_topic" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
148 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
149 def __init__(self, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
150 super(EdamTopic, self).__init__() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
151 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
152 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
153 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
154 class Requirements(XMLParam): |
36 | 155 name = "requirements" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
156 # This bodes to be an issue -__- |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
157 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
158 def acceptable_child(self, child): |
38 | 159 return issubclass(type(child), Requirement) or issubclass(type(child), Container) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
160 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
161 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
162 class Requirement(XMLParam): |
36 | 163 name = "requirement" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
164 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
165 def __init__(self, type, value, version=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
166 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
167 passed_kwargs = {} |
36 | 168 passed_kwargs["version"] = params["version"] |
169 passed_kwargs["type"] = params["type"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
170 super(Requirement, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
171 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
172 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
173 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
174 class Container(XMLParam): |
36 | 175 name = "container" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
176 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
177 def __init__(self, type, value, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
178 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
179 passed_kwargs = {} |
36 | 180 passed_kwargs["type"] = params["type"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
181 super(Container, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
182 self.node.text = str(value) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
183 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
184 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
185 class Configfiles(XMLParam): |
36 | 186 name = "configfiles" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
187 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
188 def acceptable_child(self, child): |
38 | 189 return issubclass(type(child), Configfile) or issubclass(type(child), ConfigfileDefaultInputs) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
190 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
191 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
192 class Configfile(XMLParam): |
36 | 193 name = "configfile" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
194 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
195 def __init__(self, name, text, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
196 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
197 passed_kwargs = {} |
36 | 198 passed_kwargs["name"] = params["name"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
199 super(Configfile, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
200 self.node.text = etree.CDATA(str(text)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
201 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
202 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
203 class ConfigfileDefaultInputs(XMLParam): |
36 | 204 name = "inputs" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
205 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
206 def __init__(self, name, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
207 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
208 passed_kwargs = {} |
36 | 209 passed_kwargs["name"] = params["name"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
210 super(ConfigfileDefaultInputs, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
211 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
212 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
213 class Inputs(XMLParam): |
36 | 214 name = "inputs" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
215 # This bodes to be an issue -__- |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
216 |
38 | 217 def __init__(self, action=None, check_value=None, method=None, target=None, nginx_upload=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
218 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
219 super(Inputs, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
220 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
221 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
222 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
223 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
224 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
225 class InputParameter(XMLParam): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
226 def __init__(self, name, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
227 # TODO: look at |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
228 self.mako_identifier = name |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
229 # We use kwargs instead of the usual locals(), so manually copy the |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
230 # name to kwargs |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
231 if name is not None: |
36 | 232 kwargs["name"] = name |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
233 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
234 # Handle positional parameters |
36 | 235 if "positional" in kwargs and kwargs["positional"]: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
236 self.positional = True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
237 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
238 self.positional = False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
239 |
36 | 240 if "num_dashes" in kwargs: |
241 self.num_dashes = kwargs["num_dashes"] | |
242 del kwargs["num_dashes"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
243 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
244 self.num_dashes = 0 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
245 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
246 self.space_between_arg = " " |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
247 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
248 # Not sure about this :( |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
249 # https://wiki.galaxyproject.org/Tools/BestPractices#Parameter_help |
36 | 250 if "label" in kwargs: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
251 # TODO: replace with positional attribute |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
252 if len(self.flag()) > 0: |
36 | 253 if kwargs["label"] is None: |
38 | 254 kwargs["label"] = "Author did not provide help for this parameter... " |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
255 if not self.positional: |
36 | 256 kwargs["argument"] = self.flag() |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
257 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
258 super(InputParameter, self).__init__(**kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
259 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
260 def command_line(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
261 before = self.command_line_before() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
262 cli = self.command_line_actual() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
263 after = self.command_line_after() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
264 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
265 complete = [x for x in (before, cli, after) if x is not None] |
36 | 266 return "\n".join(complete) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
267 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
268 def command_line_before(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
269 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
270 return self.command_line_before_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
271 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
272 return None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
273 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
274 def command_line_after(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
275 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
276 return self.command_line_after_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
277 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
278 return None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
279 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
280 def command_line_actual(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
281 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
282 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
283 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
284 if self.positional: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
285 return self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
286 else: |
38 | 287 return "%s%s%s" % (self.flag(), self.space_between_arg, self.mako_name()) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
288 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
289 def mako_name(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
290 # TODO: enhance logic to check up parents for things like |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
291 # repeat>condotion>param |
36 | 292 return "$" + self.mako_identifier |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
293 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
294 def flag(self): |
36 | 295 flag = "-" * self.num_dashes |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
296 return flag + self.mako_identifier |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
297 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
298 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
299 class Section(InputParameter): |
36 | 300 name = "section" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
301 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
302 def __init__(self, name, title, expanded=None, help=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
303 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
304 super(Section, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
305 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
306 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
307 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
308 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
309 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
310 class Repeat(InputParameter): |
36 | 311 name = "repeat" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
312 |
36 | 313 def __init__(self, name, title, min=None, max=None, default=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
314 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
315 # Allow overriding |
36 | 316 self.command_line_before_override = "#for $i in $%s:" % name |
317 self.command_line_after_override = "#end for" | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
318 # self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
319 super(Repeat, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
320 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
321 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
322 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
323 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
324 def command_line_actual(self): |
36 | 325 if hasattr(self, "command_line_override"): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
326 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
327 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
328 return "%s" % self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
329 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
330 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
331 class Conditional(InputParameter): |
36 | 332 name = "conditional" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
333 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
334 def __init__(self, name, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
335 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
336 super(Conditional, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
337 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
338 def acceptable_child(self, child): |
38 | 339 return issubclass(type(child), InputParameter) and not isinstance(child, Conditional) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
340 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
341 def validate(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
342 # Find a way to check if one of the kids is a WHEN |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
343 pass |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
344 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
345 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
346 class When(InputParameter): |
36 | 347 name = "when" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
348 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
349 def __init__(self, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
350 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
351 super(When, self).__init__(None, **params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
352 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
353 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
354 return issubclass(type(child), InputParameter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
355 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
356 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
357 class Param(InputParameter): |
36 | 358 name = "param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
359 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
360 # This...isn't really valid as-is, and shouldn't be used. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
361 def __init__(self, name, optional=None, label=None, help=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
362 params = Util.clean_kwargs(locals().copy()) |
36 | 363 params["type"] = self.type |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
364 super(Param, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
365 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
366 if type(self) == Param: |
38 | 367 raise Exception("Param class is not an actual parameter type, use a subclass of Param") |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
368 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
369 def acceptable_child(self, child): |
38 | 370 return issubclass(type(child, InputParameter) or isinstance(child), ValidatorParam) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
371 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
372 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
373 class TextParam(Param): |
36 | 374 type = "text" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
375 |
38 | 376 def __init__(self, name, optional=None, label=None, help=None, value=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
377 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
378 super(TextParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
379 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
380 def command_line_actual(self): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
381 try: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
382 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
383 except Exception: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
384 if self.positional: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
385 return self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
386 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
387 return f"{self.flag}{self.space_between_arg}'{self.mako_name()}'" |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
388 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
389 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
390 class _NumericParam(Param): |
38 | 391 def __init__(self, name, value, optional=None, label=None, help=None, min=None, max=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
392 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
393 super(_NumericParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
394 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
395 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
396 class IntegerParam(_NumericParam): |
36 | 397 type = "integer" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
398 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
399 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
400 class FloatParam(_NumericParam): |
36 | 401 type = "float" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
402 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
403 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
404 class BooleanParam(Param): |
36 | 405 type = "boolean" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
406 |
36 | 407 def __init__( |
38 | 408 self, name, optional=None, label=None, help=None, checked=False, truevalue=None, falsevalue=None, **kwargs |
36 | 409 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
410 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
411 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
412 super(BooleanParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
413 if truevalue is None: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
414 # If truevalue and falsevalue are None, then we use "auto", the IUC |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
415 # recommended default. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
416 # |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
417 # truevalue is set to the parameter's value, and falsevalue is not. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
418 # |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
419 # Unfortunately, mako_identifier is set as a result of the super |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
420 # call, which we shouldn't call TWICE, so we'll just hack around this :( |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
421 # params['truevalue'] = '%s%s' % (self.) |
36 | 422 self.node.attrib["truevalue"] = self.flag() |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
423 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
424 if falsevalue is None: |
36 | 425 self.node.attrib["falsevalue"] = "" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
426 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
427 def command_line_actual(self): |
36 | 428 if hasattr(self, "command_line_override"): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
429 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
430 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
431 return "%s" % self.mako_name() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
432 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
433 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
434 class DataParam(Param): |
36 | 435 type = "data" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
436 |
38 | 437 def __init__(self, name, optional=None, label=None, help=None, format=None, multiple=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
438 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
439 super(DataParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
440 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
441 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
442 class SelectParam(Param): |
36 | 443 type = "select" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
444 |
36 | 445 def __init__( |
446 self, | |
447 name, | |
448 optional=None, | |
449 label=None, | |
450 help=None, | |
451 data_ref=None, | |
452 display=None, | |
453 multiple=None, | |
454 options=None, | |
455 default=None, | |
38 | 456 **kwargs |
36 | 457 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
458 params = Util.clean_kwargs(locals().copy()) |
36 | 459 del params["options"] |
460 del params["default"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
461 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
462 super(SelectParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
463 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
464 if options is not None and default is not None: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
465 if default not in options: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
466 raise Exception("Specified a default that isn't in options") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
467 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
468 if options: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
469 for k, v in list(sorted(options.items())): |
36 | 470 selected = k == default |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
471 self.append(SelectOption(k, v, selected=selected)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
472 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
473 def acceptable_child(self, child): |
36 | 474 return issubclass(type(child), SelectOption) or issubclass(type(child), Options) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
475 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
476 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
477 class SelectOption(InputParameter): |
36 | 478 name = "option" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
479 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
480 def __init__(self, value, text, selected=False, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
481 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
482 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
483 passed_kwargs = {} |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
484 if selected: |
36 | 485 passed_kwargs["selected"] = "true" |
486 passed_kwargs["value"] = params["value"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
487 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
488 super(SelectOption, self).__init__(None, **passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
489 self.node.text = str(text) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
490 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
491 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
492 class Options(InputParameter): |
36 | 493 name = "options" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
494 |
38 | 495 def __init__(self, from_dataset=None, from_file=None, from_data_table=None, from_parameter=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
496 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
497 super(Options, self).__init__(None, **params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
498 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
499 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
500 return issubclass(type(child), Column) or issubclass(type(child), Filter) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
501 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
502 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
503 class Column(InputParameter): |
36 | 504 name = "column" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
505 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
506 def __init__(self, name, index, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
507 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
508 super(Column, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
509 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
510 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
511 class Filter(InputParameter): |
36 | 512 name = "filter" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
513 |
36 | 514 def __init__( |
515 self, | |
516 type, | |
517 column=None, | |
518 name=None, | |
519 ref=None, | |
520 key=None, | |
521 multiple=None, | |
522 separator=None, | |
523 keep=None, | |
524 value=None, | |
525 ref_attribute=None, | |
526 index=None, | |
38 | 527 **kwargs |
36 | 528 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
529 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
530 super(Filter, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
531 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
532 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
533 class ValidatorParam(InputParameter): |
36 | 534 name = "validator" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
535 |
36 | 536 def __init__( |
537 self, | |
538 type, | |
539 message=None, | |
540 filename=None, | |
541 metadata_name=None, | |
542 metadata_column=None, | |
543 line_startswith=None, | |
544 min=None, | |
545 max=None, | |
38 | 546 **kwargs |
36 | 547 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
548 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
549 super(ValidatorParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
550 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
551 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
552 class Outputs(XMLParam): |
36 | 553 name = "outputs" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
554 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
555 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
556 return isinstance(child, OutputData) or isinstance(child, OutputCollection) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
557 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
558 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
559 class OutputData(XMLParam): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
560 """Copypasta of InputParameter, needs work |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
561 """ |
36 | 562 |
563 name = "data" | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
564 |
36 | 565 def __init__( |
566 self, | |
567 name, | |
568 format, | |
569 format_source=None, | |
570 metadata_source=None, | |
571 label=None, | |
572 from_work_dir=None, | |
573 hidden=False, | |
38 | 574 **kwargs |
36 | 575 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
576 # TODO: validate format_source&metadata_source against something in the |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
577 # XMLParam children tree. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
578 self.mako_identifier = name |
36 | 579 if "num_dashes" in kwargs: |
580 self.num_dashes = kwargs["num_dashes"] | |
581 del kwargs["num_dashes"] | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
582 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
583 self.num_dashes = 0 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
584 self.space_between_arg = " " |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
585 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
586 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
587 super(OutputData, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
588 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
589 def command_line(self): |
36 | 590 if hasattr(self, "command_line_override"): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
591 return self.command_line_override |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
592 else: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
593 return "%s%s%s" % (self.flag(), self.space_between_arg, self.mako_name()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
594 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
595 def mako_name(self): |
36 | 596 return "$" + self.mako_identifier |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
597 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
598 def flag(self): |
36 | 599 flag = "-" * self.num_dashes |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
600 return flag + self.mako_identifier |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
601 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
602 def acceptable_child(self, child): |
38 | 603 return isinstance(child, OutputFilter) or isinstance(child, ChangeFormat) or isinstance(child, DiscoverDatasets) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
604 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
605 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
606 class OutputFilter(XMLParam): |
36 | 607 name = "filter" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
608 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
609 def __init__(self, text, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
610 params = Util.clean_kwargs(locals().copy()) |
36 | 611 del params["text"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
612 super(OutputFilter, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
613 self.node.text = text |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
614 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
615 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
616 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
617 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
618 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
619 class ChangeFormat(XMLParam): |
36 | 620 name = "change_format" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
621 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
622 def __init__(self, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
623 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
624 super(ChangeFormat, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
625 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
626 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
627 return isinstance(child, ChangeFormatWhen) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
628 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
629 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
630 class ChangeFormatWhen(XMLParam): |
36 | 631 name = "when" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
632 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
633 def __init__(self, input, format, value, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
634 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
635 super(ChangeFormatWhen, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
636 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
637 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
638 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
639 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
640 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
641 class OutputCollection(XMLParam): |
36 | 642 name = "collection" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
643 |
36 | 644 def __init__( |
645 self, | |
646 name, | |
647 type=None, | |
648 label=None, | |
649 format_source=None, | |
650 type_source=None, | |
651 structured_like=None, | |
652 inherit_format=None, | |
38 | 653 **kwargs |
36 | 654 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
655 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
656 super(OutputCollection, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
657 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
658 def acceptable_child(self, child): |
38 | 659 return isinstance(child, OutputData) or isinstance(child, OutputFilter) or isinstance(child, DiscoverDatasets) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
660 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
661 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
662 class DiscoverDatasets(XMLParam): |
36 | 663 name = "discover_datasets" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
664 |
38 | 665 def __init__(self, pattern, directory=None, format=None, ext=None, visible=None, **kwargs): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
666 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
667 super(DiscoverDatasets, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
668 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
669 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
670 class Tests(XMLParam): |
36 | 671 name = "tests" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
672 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
673 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
674 return issubclass(type(child), Test) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
675 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
676 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
677 class Test(XMLParam): |
36 | 678 name = "test" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
679 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
680 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
681 return isinstance(child, TestParam) or isinstance(child, TestOutput) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
682 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
683 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
684 class TestParam(XMLParam): |
36 | 685 name = "param" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
686 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
687 def __init__(self, name, value=None, ftype=None, dbkey=None, **kwargs): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
688 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
689 super(TestParam, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
690 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
691 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
692 class TestOutput(XMLParam): |
36 | 693 name = "output" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
694 |
36 | 695 def __init__( |
696 self, | |
697 name=None, | |
698 file=None, | |
699 ftype=None, | |
700 sort=None, | |
701 value=None, | |
702 md5=None, | |
703 checksum=None, | |
704 compare=None, | |
705 lines_diff=None, | |
706 delta=None, | |
38 | 707 **kwargs |
36 | 708 ): |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
709 params = Util.clean_kwargs(locals().copy()) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
710 super(TestOutput, self).__init__(**params) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
711 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
712 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
713 class Citations(XMLParam): |
36 | 714 name = "citations" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
715 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
716 def acceptable_child(self, child): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
717 return issubclass(type(child), Citation) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
718 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
719 def has_citation(self, type, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
720 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
721 Check the presence of a given citation. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
722 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
723 :type type: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
724 :type value: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
725 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
726 for citation in self.children: |
36 | 727 if citation.node.attrib["type"] == type and citation.node.text == value: |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
728 return True |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
729 return False |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
730 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
731 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
732 class Citation(XMLParam): |
36 | 733 name = "citation" |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
734 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
735 def __init__(self, type, value): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
736 passed_kwargs = {} |
36 | 737 passed_kwargs["type"] = type |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
738 super(Citation, self).__init__(**passed_kwargs) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
739 self.node.text = str(value) |