Mercurial > repos > fubar > tool_factory_2
annotate toolfactory/galaxyxml/tool/import_xml.py @ 36:ce2b1f8ea68d draft
passes flake8 tests finally :)
author | fubar |
---|---|
date | Mon, 10 Aug 2020 23:24:41 -0400 |
parents | 5d38cb3d9be8 |
children | a30536c100bf |
rev | line source |
---|---|
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
1 import logging |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
2 import xml.etree.ElementTree as ET |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
3 import galaxyxml.tool as gxt |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
4 import galaxyxml.tool.parameters as gxtp |
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 logging.basicConfig(level=logging.INFO) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
7 logger = logging.getLogger(__name__) |
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 GalaxyXmlParser(object): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
11 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
12 Class to import content from an existing Galaxy XML wrapper. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
13 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
14 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
15 def _init_tool(self, xml_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
16 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
17 Init tool from existing xml tool. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
18 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
19 :param xml_root: root of the galaxy xml file. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
20 :type xml_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
21 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
22 version_cmd = None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
23 description = None |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
24 for child in xml_root: |
36 | 25 if child.tag == "description": |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
26 description = child.text |
36 | 27 elif child.tag == "command": |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
28 executable = child.text.split()[0] |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
29 command = child.text |
36 | 30 elif child.tag == "version_command": |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
31 version_cmd = child.text |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
32 |
36 | 33 tool = gxt.Tool( |
34 xml_root.attrib["name"], | |
35 xml_root.attrib["id"], | |
36 xml_root.attrib.get("version", None), | |
37 description, | |
38 executable, | |
39 hidden=xml_root.attrib.get("hidden", False), | |
40 tool_type=xml_root.attrib.get("tool_type", None), | |
41 URL_method=xml_root.attrib.get("URL_method", None), | |
42 workflow_compatible=xml_root.attrib.get("workflow_compatible", True), | |
43 version_command=version_cmd, | |
44 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
45 tool.command = command |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
46 return tool |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
47 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
48 def _load_description(self, tool, desc_root): |
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 <description> is already loaded during initiation. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
53 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
54 :param desc_root: root of <description> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
55 :type desc_root: :class:`xml.etree._Element` |
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 logger.info("<description> is loaded during initiation of the object.") |
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 _load_version_command(self, tool, vers_root): |
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 <version_command> is already loaded during initiation. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
62 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
63 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
64 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
65 :param vers_root: root of <version_command> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
66 :type vers_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
67 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
68 logger.info("<version_command> is loaded during initiation of the object.") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
69 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
70 def _load_stdio(self, tool, stdio_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
71 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
72 So far, <stdio> is automatically generated by galaxyxml. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
75 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
76 :param desc_root: root of <stdio> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
77 :type desc_root: :class:`xml.etree._Element` |
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 logger.info("<stdio> is not loaded but automatically generated by galaxyxml.") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
80 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
81 def _load_command(self, tool, desc_root): |
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 <command> is already loaded during initiation. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
86 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
87 :param desc_root: root of <command> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
88 :type desc_root: :class:`xml.etree._Element` |
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 logger.info("<command> is loaded during initiation of the object.") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
91 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
92 def _load_help(self, tool, help_root): |
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 Load the content of the <help> into the tool. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
97 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
98 :param requirements_root: root of <help> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
99 :type requirements_root: :class:`xml.etree._Element` |
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 tool.help = help_root.text |
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 _load_requirements(self, tool, requirements_root): |
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 Add <requirements> to the tool. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
108 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
109 :param requirements_root: root of <requirements> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
110 :type requirements_root: :class:`xml.etree._Element` |
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 tool.requirements = gxtp.Requirements() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
113 for req in requirements_root: |
36 | 114 req_type = req.attrib["type"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
115 value = req.text |
36 | 116 if req.tag == "requirement": |
117 version = req.attrib.get("version", None) | |
118 tool.requirements.append( | |
119 gxtp.Requirement(req_type, value, version=version) | |
120 ) | |
121 elif req.tag == "container": | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
122 tool.requirements.append(gxtp.Container(req_type, value)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
123 else: |
36 | 124 logger.warning(req.tag + " is not a valid tag for requirements child") |
35
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 _load_edam_topics(self, tool, topics_root): |
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 Add <edam_topics> to the tool. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
129 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
130 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
131 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
132 :param topics_root: root of <edam_topics> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
133 :type topics_root: :class:`xml.etree._Element` |
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 tool.edam_topics = gxtp.EdamTopics() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
136 for edam_topic in topics_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
137 tool.edam_topics.append(gxtp.EdamTopic(edam_topic.text)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
138 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
139 def _load_edam_operations(self, tool, operations_root): |
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 Add <edam_operations> to the tool. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
142 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
143 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
144 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
145 :param operations_root: root of <edam_operations> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
146 :type operations_root: :class:`xml.etree._Element` |
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 tool.edam_operations = gxtp.EdamOperations() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
149 for edam_op in operations_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
150 tool.edam_operations.append(gxtp.EdamOperation(edam_op.text)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
151 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
152 def _load_configfiles(self, tool, configfiles_root): |
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 Add <configfiles> to the tool. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
157 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
158 :param configfiles_root: root of <configfiles> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
159 :type configfiles_root: :class:`xml.etree._Element` |
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 tool.configfiles = gxtp.Configfiles() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
162 for conf in configfiles_root: |
36 | 163 name = conf.attrib["name"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
164 value = conf.text |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
165 tool.configfiles.append(gxtp.Configfile(name, value)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
166 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
167 def _load_citations(self, tool, citations_root): |
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 Add <citations> to the tool. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
170 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
171 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
172 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
173 :param citations_root: root of <citations> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
174 :type citations_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
175 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
176 tool.citations = gxtp.Citations() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
177 for cit in citations_root: |
36 | 178 cit_type = cit.attrib["type"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
179 value = cit.text |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
180 tool.citations.append(gxtp.Citation(cit_type, value)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
181 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
182 def _load_inputs(self, tool, inputs_root): |
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 Add <inputs> to the tool using the :class:`galaxyxml.tool.import_xml.InputsParser` object. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
187 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
188 :param inputs_root: root of <inputs> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
189 :type inputs_root: :class:`xml.etree._Element` |
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 tool.inputs = gxtp.Inputs() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
192 inp_parser = InputsParser() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
193 inp_parser.load_inputs(tool.inputs, inputs_root) |
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 _load_outputs(self, tool, outputs_root): |
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 Add <outputs> to the tool using the :class:`galaxyxml.tool.import_xml.OutputsParser` object. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
198 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
199 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
200 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
201 :param outputs_root: root of <outputs> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
202 :type outputs_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
203 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
204 tool.outputs = gxtp.Outputs() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
205 out_parser = OutputsParser() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
206 out_parser.load_outputs(tool.outputs, outputs_root) |
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 def _load_tests(self, tool, tests_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
209 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
210 Add <tests> to the tool using the :class:`galaxyxml.tool.import_xml.TestsParser` object. |
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 :param tool: Tool object from galaxyxml. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
213 :type tool: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
214 :param tests_root: root of <tests> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
215 :type tests_root: :class:`xml.etree._Element` |
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 tool.tests = gxtp.Tests() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
218 tests_parser = TestsParser() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
219 tests_parser.load_tests(tool.tests, tests_root) |
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 import_xml(self, xml_path): |
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 Load existing xml into the :class:`galaxyxml.tool.Tool` object. |
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 :param xml_path: Path of the XML to be loaded. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
226 :type xml_path: STRING |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
227 :return: XML content in the galaxyxml model. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
228 :rtype: :class:`galaxyxml.tool.Tool` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
229 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
230 xml_root = ET.parse(xml_path).getroot() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
231 tool = self._init_tool(xml_root) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
232 # Now we import each tag's field |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
233 for child in xml_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
234 try: |
36 | 235 getattr(self, "_load_{}".format(child.tag))(tool, child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
236 except AttributeError: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
237 logger.warning(child.tag + " tag is not processed.") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
238 return tool |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
239 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
240 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
241 class InputsParser(object): |
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 Class to parse content of the <inputs> tag from a Galaxy XML wrapper. |
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 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
246 def _load_text_param(self, root, text_param): |
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 Add <param type="text" /> to the root. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
249 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
250 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
251 :param text_param: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
252 :type text_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
253 """ |
36 | 254 root.append( |
255 gxtp.TextParam( | |
256 text_param.attrib["name"], | |
257 optional=text_param.get("optional", None), | |
258 label=text_param.get("label", None), | |
259 help=text_param.get("help", None), | |
260 value=text_param.get("value", None), | |
261 ) | |
262 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
263 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
264 def _load_data_param(self, root, data_param): |
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 Add <param type="data" /> to the root. |
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 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
269 :param data_param: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
270 :type data_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
271 """ |
36 | 272 root.append( |
273 gxtp.DataParam( | |
274 data_param.attrib["name"], | |
275 optional=data_param.attrib.get("optional", None), | |
276 label=data_param.attrib.get("label", None), | |
277 help=data_param.attrib.get("help", None), | |
278 format=data_param.attrib.get("format", None), | |
279 multiple=data_param.attrib.get("multiple", None), | |
280 ) | |
281 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
282 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
283 def _load_boolean_param(self, root, bool_param): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
284 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
285 Add <param type="boolean" /> to the root. |
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 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
288 :param bool_param: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
289 :type bool_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
290 """ |
36 | 291 root.append( |
292 gxtp.BooleanParam( | |
293 bool_param.attrib["name"], | |
294 optional=bool_param.attrib.get("optional", None), | |
295 label=bool_param.attrib.get("label", None), | |
296 help=bool_param.attrib.get("help", None), | |
297 checked=bool_param.attrib.get("checked", False), | |
298 truevalue=bool_param.attrib.get("truevalue", None), | |
299 falsevalue=bool_param.attrib.get("falsevalue", None), | |
300 ) | |
301 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
302 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
303 def _load_integer_param(self, root, int_param): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
304 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
305 Add <param type="integer" /> to the root. |
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 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
308 :param int_param: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
309 :type int_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
310 """ |
36 | 311 root.append( |
312 gxtp.IntegerParam( | |
313 int_param.attrib["name"], | |
314 int_param.attrib.get("value", None), | |
315 optional=int_param.attrib.get("optional", None), | |
316 label=int_param.attrib.get("label", None), | |
317 help=int_param.attrib.get("help", None), | |
318 min=int_param.attrib.get("min", None), | |
319 max=int_param.attrib.get("max", None), | |
320 ) | |
321 ) | |
35
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 _load_float_param(self, root, float_param): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
324 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
325 Add <param type="float" /> to the root. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
326 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
327 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
328 :param float_param: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
329 :type float_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
330 """ |
36 | 331 root.append( |
332 gxtp.FloatParam( | |
333 float_param.attrib["name"], | |
334 float_param.attrib.get("value", None), | |
335 optional=float_param.attrib.get("optional", None), | |
336 label=float_param.attrib.get("label", None), | |
337 help=float_param.attrib.get("help", None), | |
338 min=float_param.attrib.get("min", None), | |
339 max=float_param.attrib.get("max", None), | |
340 ) | |
341 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
342 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
343 def _load_option_select(self, root, option): |
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 Add <option> to the root (usually <param type="select" />). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
346 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
347 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
348 :param option: root of <option> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
349 :type float_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
350 """ |
36 | 351 root.append( |
352 gxtp.SelectOption( | |
353 option.attrib.get("value", None), | |
354 option.text, | |
355 selected=option.attrib.get("selected", False), | |
356 ) | |
357 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
358 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
359 def _load_column_options(self, root, column): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
360 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
361 Add <column> to the root (usually <options>). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
362 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
363 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
364 :param option: root of <column> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
365 :type float_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
366 """ |
36 | 367 root.append(gxtp.Column(column.attrib["name"], column.attrib["index"])) |
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 _load_filter_options(self, root, filter): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
370 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
371 Add <filter> to the root (usually <options>). |
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 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
374 :param option: root of <filter> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
375 :type float_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
376 """ |
36 | 377 root.append( |
378 gxtp.Filter( | |
379 filter.attrib["type"], | |
380 column=filter.attrib.get("column", None), | |
381 name=filter.attrib.get("name", None), | |
382 ref=filter.attrib.get("ref", None), | |
383 key=filter.attrib.get("key", None), | |
384 multiple=filter.attrib.get("multiple", None), | |
385 separator=filter.attrib.get("separator", None), | |
386 keep=filter.attrib.get("keep", None), | |
387 value=filter.attrib.get("value", None), | |
388 ref_attribute=filter.attrib.get("ref_attribute", None), | |
389 index=filter.attrib.get("index", None), | |
390 ) | |
391 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
392 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
393 def _load_options_select(self, root, options): |
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 Add <options> to the root (usually <param type="select" />). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
396 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
397 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
398 :param option: root of <options> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
399 :type float_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
400 """ |
36 | 401 opts = gxtp.Options( |
402 from_dataset=options.attrib.get("from_dataset", None), | |
403 from_file=options.attrib.get("from_file", None), | |
404 from_data_table=options.attrib.get("from_data_table", None), | |
405 from_parameter=options.attrib.get("from_parameter", None), | |
406 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
407 # Deal with child nodes (usually filter and column) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
408 for opt_child in options: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
409 try: |
36 | 410 getattr(self, "_load_{}_options".format(opt_child.tag))(opts, opt_child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
411 except AttributeError: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
412 logger.warning(opt_child.tag + " tag is not processed for <options>.") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
413 root.append(opts) |
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 def _load_select_param(self, root, sel_param): |
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 Add <param type="select" /> to the root. |
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 :param root: root to append the param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
420 :param sel_param: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
421 :type sel_param: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
422 """ |
36 | 423 select_param = gxtp.SelectParam( |
424 sel_param.attrib["name"], | |
425 optional=sel_param.attrib.get("optional", None), | |
426 label=sel_param.attrib.get("label", None), | |
427 help=sel_param.attrib.get("help", None), | |
428 data_ref=sel_param.attrib.get("data_ref", None), | |
429 display=sel_param.attrib.get("display", None), | |
430 multiple=sel_param.attrib.get("multiple", None), | |
431 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
432 # Deal with child nodes (usually option and options) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
433 for sel_child in sel_param: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
434 try: |
36 | 435 getattr(self, "_load_{}_select".format(sel_child.tag))( |
436 select_param, sel_child | |
437 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
438 except AttributeError: |
36 | 439 logger.warning( |
440 sel_child.tag + " tag is not processed for <param type='select'>." | |
441 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
442 root.append(select_param) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
443 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
444 def _load_param(self, root, param_root): |
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 Method to select which type of <param> is being added to the root. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
447 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
448 :param root: root to attach param to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
449 :param param_root: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
450 :type param_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
451 """ |
36 | 452 param_type = param_root.attrib["type"] |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
453 try: |
36 | 454 getattr(self, "_load_{}_param".format(param_type))(root, param_root) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
455 except AttributeError: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
456 logger.warning(param_type + " tag is not processed for <param>.") |
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 def _load_when(self, root, when_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
459 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
460 Add <when> to the root (usually <conditional>). |
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 :param root: root to append when to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
463 :param when_root: root of <when> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
464 :type when_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
465 """ |
36 | 466 when = gxtp.When(when_root.attrib["value"]) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
467 # Deal with child nodes |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
468 self.load_inputs(when, when_root) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
469 root.append(when) |
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 def _load_conditional(self, root, conditional_root): |
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 Add <conditional> to the root. |
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 :param root: root to append conditional to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
476 :param conditional_root: root of <conditional> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
477 :type conditional_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
478 """ |
36 | 479 value_ref_in_group = conditional_root.attrib.get("value_ref_in_group", None) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
480 # Other optional parameters need to be added to conditional object |
36 | 481 conditional = gxtp.Conditional( |
482 conditional_root.attrib["name"], | |
483 value_from=conditional_root.attrib.get("value_from", None), | |
484 value_ref=conditional_root.attrib.get("value_ref", None), | |
485 value_ref_in_group=value_ref_in_group, | |
486 label=conditional_root.attrib.get("label", None), | |
487 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
488 # Deal with child nodes |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
489 self.load_inputs(conditional, conditional_root) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
490 root.append(conditional) |
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 def _load_section(self, root, section_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
493 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
494 Add <section> to the root. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
495 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
496 :param root: root to append conditional to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
497 :param section_root: root of <section> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
498 :type section_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
499 """ |
36 | 500 section = gxtp.Section( |
501 section_root.attrib["name"], | |
502 section_root.attrib["title"], | |
503 expanded=section_root.attrib.get("expanded", None), | |
504 help=section_root.attrib.get("help", None), | |
505 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
506 # Deal with child nodes |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
507 self.load_inputs(section, section_root) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
508 root.append(section) |
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 _load_repeat(self, root, repeat_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
511 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
512 Add <repeat> to the root. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
513 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
514 :param root: root to append repeat to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
515 :param repeat_root: root of <repeat> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
516 :param repeat_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
517 """ |
36 | 518 repeat = gxtp.Repeat( |
519 repeat_root.attrib["name"], | |
520 repeat_root.attrib["title"], | |
521 min=repeat_root.attrib.get("min", None), | |
522 max=repeat_root.attrib.get("max", None), | |
523 default=repeat_root.attrib.get("default", None), | |
524 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
525 # Deal with child nodes |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
526 self.load_inputs(repeat, repeat_root) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
527 root.append(repeat) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
528 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
529 def load_inputs(self, root, inputs_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
530 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
531 Add <inputs.tag> to the root (it can be any tags with children such as |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
532 <inputs>, <repeat>, <section> ...) |
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 :param root: root to attach inputs to (either <inputs> or <when>). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
535 :param inputs_root: root of <inputs> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
536 :type inputs_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
537 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
538 for inp_child in inputs_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
539 try: |
36 | 540 getattr(self, "_load_{}".format(inp_child.tag))(root, inp_child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
541 except AttributeError: |
36 | 542 logger.warning( |
543 inp_child.tag | |
544 + " tag is not processed for <" | |
545 + inputs_root.tag | |
546 + "> tag." | |
547 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
548 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
549 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
550 class OutputsParser(object): |
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 to parse content of the <outputs> tag from a Galaxy XML wrapper. |
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 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
555 def _load_data(self, outputs_root, data_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
556 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
557 Add <data> to <outputs>. |
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 :param outputs_root: <outputs> root to append <data> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
560 :param data_root: root of <data> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
561 :param data_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
562 """ |
36 | 563 data = gxtp.OutputData( |
564 data_root.attrib.get("name", None), | |
565 data_root.attrib.get("format", None), | |
566 format_source=data_root.attrib.get("format_source", None), | |
567 metadata_source=data_root.attrib.get("metadata_source", None), | |
568 label=data_root.attrib.get("label", None), | |
569 from_work_dir=data_root.attrib.get("from_work_dir", None), | |
570 hidden=data_root.attrib.get("hidden", False), | |
571 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
572 # Deal with child nodes |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
573 for data_child in data_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
574 try: |
36 | 575 getattr(self, "_load_{}".format(data_child.tag))(data, data_child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
576 except AttributeError: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
577 logger.warning(data_child.tag + " tag is not processed for <data>.") |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
578 outputs_root.append(data) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
579 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
580 def _load_change_format(self, root, chfmt_root): |
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 Add <change_format> to root (<data>). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
583 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
584 :param root: root to append <change_format> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
585 :param chfm_root: root of <change_format> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
586 :param chfm_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
587 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
588 change_format = gxtp.ChangeFormat() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
589 for chfmt_child in chfmt_root: |
36 | 590 change_format.append( |
591 gxtp.ChangeFormatWhen( | |
592 chfmt_child.attrib["input"], | |
593 chfmt_child.attrib["format"], | |
594 chfmt_child.attrib["value"], | |
595 ) | |
596 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
597 root.append(change_format) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
598 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
599 def _load_collection(self, outputs_root, coll_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
600 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
601 Add <collection> to <outputs>. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
602 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
603 :param outputs_root: <outputs> root to append <collection> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
604 :param coll_root: root of <collection> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
605 :param coll_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
606 """ |
36 | 607 collection = gxtp.OutputCollection( |
608 coll_root.attrib["name"], | |
609 type=coll_root.attrib.get("type", None), | |
610 label=coll_root.attrib.get("label", None), | |
611 format_source=coll_root.attrib.get("format_source", None), | |
612 type_source=coll_root.attrib.get("type_source", None), | |
613 structured_like=coll_root.attrib.get("structured_like", None), | |
614 inherit_format=coll_root.attrib.get("inherit_format", None), | |
615 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
616 # Deal with child nodes |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
617 for coll_child in coll_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
618 try: |
36 | 619 getattr(self, "_load_{}".format(coll_child.tag))(collection, coll_child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
620 except AttributeError: |
36 | 621 logger.warning( |
622 coll_child.tag + " tag is not processed for <collection>." | |
623 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
624 outputs_root.append(collection) |
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 _load_discover_datasets(self, root, disc_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
627 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
628 Add <discover_datasets> to root (<collection>). |
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 :param root: root to append <collection> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
631 :param disc_root: root of <discover_datasets> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
632 :param disc_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
633 """ |
36 | 634 root.append( |
635 gxtp.DiscoverDatasets( | |
636 disc_root.attrib["pattern"], | |
637 directory=disc_root.attrib.get("directory", None), | |
638 format=disc_root.attrib.get("format", None), | |
639 ext=disc_root.attrib.get("ext", None), | |
640 visible=disc_root.attrib.get("visible", None), | |
641 ) | |
642 ) | |
35
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 def _load_filter(self, root, filter_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
645 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
646 Add <filter> to root (<collection> or <data>). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
647 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
648 :param root: root to append <collection> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
649 :param coll_root: root of <filter> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
650 :param coll_root: :class:`xml.etree._Element` |
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 root.append(gxtp.OutputFilter(filter_root.text)) |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
653 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
654 def load_outputs(self, root, outputs_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
655 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
656 Add <outputs> to the root. |
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 :param root: root to attach <outputs> to (<tool>). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
659 :param tests_root: root of <outputs> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
660 :type tests_root: :class:`xml.etree._Element` |
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 for out_child in outputs_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
663 try: |
36 | 664 getattr(self, "_load_{}".format(out_child.tag))(root, out_child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
665 except AttributeError: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
666 logger.warning(out_child.tag + " tag is not processed for <outputs>.") |
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 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
669 class TestsParser(object): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
670 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
671 Class to parse content of the <tests> tag from a Galaxy XML wrapper. |
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 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
674 def _load_param(self, test_root, param_root): |
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 Add <param> to the <test>. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
677 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
678 :param root: <test> root to append <param> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
679 :param repeat_root: root of <param> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
680 :param repeat_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
681 """ |
36 | 682 test_root.append( |
683 gxtp.TestParam( | |
684 param_root.attrib["name"], | |
685 value=param_root.attrib.get("value", None), | |
686 ftype=param_root.attrib.get("ftype", None), | |
687 dbkey=param_root.attrib.get("dbkey", None), | |
688 ) | |
689 ) | |
35
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 def _load_output(self, test_root, output_root): |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
692 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
693 Add <output> to the <test>. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
694 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
695 :param root: <test> root to append <output> to. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
696 :param repeat_root: root of <output> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
697 :param repeat_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
698 """ |
36 | 699 test_root.append( |
700 gxtp.TestOutput( | |
701 name=output_root.attrib.get("name", None), | |
702 file=output_root.attrib.get("file", None), | |
703 ftype=output_root.attrib.get("ftype", None), | |
704 sort=output_root.attrib.get("sort", None), | |
705 value=output_root.attrib.get("value", None), | |
706 md5=output_root.attrib.get("md5", None), | |
707 checksum=output_root.attrib.get("checksum", None), | |
708 compare=output_root.attrib.get("compare", None), | |
709 lines_diff=output_root.attrib.get("lines_diff", None), | |
710 delta=output_root.attrib.get("delta", None), | |
711 ) | |
712 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
713 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
714 def load_tests(self, root, tests_root): |
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 Add <tests> to the root. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
717 |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
718 :param root: root to attach <tests> to (<tool>). |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
719 :param tests_root: root of <tests> tag. |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
720 :type tests_root: :class:`xml.etree._Element` |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
721 """ |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
722 for test_root in tests_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
723 test = gxtp.Test() |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
724 for test_child in test_root: |
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
725 try: |
36 | 726 getattr(self, "_load_{}".format(test_child.tag))(test, test_child) |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
727 except AttributeError: |
36 | 728 logger.warning( |
729 test_child.tag + " tag is not processed within <test>." | |
730 ) | |
35
5d38cb3d9be8
added patched galaxyxml code temporarily until PR accepted
fubar
parents:
diff
changeset
|
731 root.append(test) |