annotate toolfactory/galaxyxml/tool/parameters/__init__.py @ 35:5d38cb3d9be8 draft

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