annotate tacrev/test-data/Input_text_file_to_be_reversed_sample @ 1:0183cad9d13b draft

planemo upload
author fubar
date Thu, 22 Feb 2024 10:48:01 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1 # see https://github.com/fubar2/toolfactory
0183cad9d13b planemo upload
fubar
parents:
diff changeset
2 #
0183cad9d13b planemo upload
fubar
parents:
diff changeset
3 # copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012
0183cad9d13b planemo upload
fubar
parents:
diff changeset
4 #
0183cad9d13b planemo upload
fubar
parents:
diff changeset
5 # all rights reserved
0183cad9d13b planemo upload
fubar
parents:
diff changeset
6 # Licensed under the LGPL
0183cad9d13b planemo upload
fubar
parents:
diff changeset
7 # suggestions for improvement and bug fixes welcome at
0183cad9d13b planemo upload
fubar
parents:
diff changeset
8 # https://github.com/fubar2/toolfactory
0183cad9d13b planemo upload
fubar
parents:
diff changeset
9 #
0183cad9d13b planemo upload
fubar
parents:
diff changeset
10 # march 2022: Refactored into two tools - generate and test/install
0183cad9d13b planemo upload
fubar
parents:
diff changeset
11 # as part of GTN tutorial development and biocontainer adoption
0183cad9d13b planemo upload
fubar
parents:
diff changeset
12 # The tester runs planemo on a non-tested archive, creates the test outputs
0183cad9d13b planemo upload
fubar
parents:
diff changeset
13 # and returns a new proper tool with test.
0183cad9d13b planemo upload
fubar
parents:
diff changeset
14
0183cad9d13b planemo upload
fubar
parents:
diff changeset
15
0183cad9d13b planemo upload
fubar
parents:
diff changeset
16
0183cad9d13b planemo upload
fubar
parents:
diff changeset
17 import argparse
0183cad9d13b planemo upload
fubar
parents:
diff changeset
18 import copy
0183cad9d13b planemo upload
fubar
parents:
diff changeset
19 import fcntl
0183cad9d13b planemo upload
fubar
parents:
diff changeset
20 import json
0183cad9d13b planemo upload
fubar
parents:
diff changeset
21 import os
0183cad9d13b planemo upload
fubar
parents:
diff changeset
22 import re
0183cad9d13b planemo upload
fubar
parents:
diff changeset
23 import shlex
0183cad9d13b planemo upload
fubar
parents:
diff changeset
24 import shutil
0183cad9d13b planemo upload
fubar
parents:
diff changeset
25 import subprocess
0183cad9d13b planemo upload
fubar
parents:
diff changeset
26 import sys
0183cad9d13b planemo upload
fubar
parents:
diff changeset
27 import tarfile
0183cad9d13b planemo upload
fubar
parents:
diff changeset
28 import tempfile
0183cad9d13b planemo upload
fubar
parents:
diff changeset
29 import time
0183cad9d13b planemo upload
fubar
parents:
diff changeset
30
0183cad9d13b planemo upload
fubar
parents:
diff changeset
31 from bioblend import galaxy
0183cad9d13b planemo upload
fubar
parents:
diff changeset
32
0183cad9d13b planemo upload
fubar
parents:
diff changeset
33 import galaxyxml.tool as gxt
0183cad9d13b planemo upload
fubar
parents:
diff changeset
34 import galaxyxml.tool.parameters as gxtp
0183cad9d13b planemo upload
fubar
parents:
diff changeset
35
0183cad9d13b planemo upload
fubar
parents:
diff changeset
36 import lxml.etree as ET
0183cad9d13b planemo upload
fubar
parents:
diff changeset
37
0183cad9d13b planemo upload
fubar
parents:
diff changeset
38 import yaml
0183cad9d13b planemo upload
fubar
parents:
diff changeset
39
0183cad9d13b planemo upload
fubar
parents:
diff changeset
40 myversion = "V2.4 March 2022"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
41 verbose = True
0183cad9d13b planemo upload
fubar
parents:
diff changeset
42 debug = True
0183cad9d13b planemo upload
fubar
parents:
diff changeset
43 toolFactoryURL = "https://github.com/fubar2/toolfactory"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
44 FAKEEXE = "~~~REMOVE~~~ME~~~"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
45 # need this until a PR/version bump to fix galaxyxml prepending the exe even
0183cad9d13b planemo upload
fubar
parents:
diff changeset
46 # with override.
0183cad9d13b planemo upload
fubar
parents:
diff changeset
47
0183cad9d13b planemo upload
fubar
parents:
diff changeset
48
0183cad9d13b planemo upload
fubar
parents:
diff changeset
49 def timenow():
0183cad9d13b planemo upload
fubar
parents:
diff changeset
50 """return current time as a string"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
51 return time.strftime("%d/%m/%Y %H:%M:%S", time.localtime(time.time()))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
52
0183cad9d13b planemo upload
fubar
parents:
diff changeset
53
0183cad9d13b planemo upload
fubar
parents:
diff changeset
54 cheetah_escape_table = {"$": "\\$", "#": "\\#"}
0183cad9d13b planemo upload
fubar
parents:
diff changeset
55
0183cad9d13b planemo upload
fubar
parents:
diff changeset
56
0183cad9d13b planemo upload
fubar
parents:
diff changeset
57 def cheetah_escape(text):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
58 """Produce entities within text."""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
59 return "".join([cheetah_escape_table.get(c, c) for c in text])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
60
0183cad9d13b planemo upload
fubar
parents:
diff changeset
61
0183cad9d13b planemo upload
fubar
parents:
diff changeset
62 def parse_citations(citations_text):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
63 """"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
64 citations = [c for c in citations_text.split("**ENTRY**") if c.strip()]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
65 citation_tuples = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
66 for citation in citations:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
67 if citation.startswith("doi"):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
68 citation_tuples.append(("doi", citation[len("doi") :].strip()))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
69 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
70 citation_tuples.append(("bibtex", citation[len("bibtex") :].strip()))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
71 return citation_tuples
0183cad9d13b planemo upload
fubar
parents:
diff changeset
72
0183cad9d13b planemo upload
fubar
parents:
diff changeset
73
0183cad9d13b planemo upload
fubar
parents:
diff changeset
74 class Tool_Factory:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
75 """Wrapper for an arbitrary script
0183cad9d13b planemo upload
fubar
parents:
diff changeset
76 uses galaxyxml
0183cad9d13b planemo upload
fubar
parents:
diff changeset
77
0183cad9d13b planemo upload
fubar
parents:
diff changeset
78 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
79
0183cad9d13b planemo upload
fubar
parents:
diff changeset
80 def __init__(self, args=None): # noqa
0183cad9d13b planemo upload
fubar
parents:
diff changeset
81 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
82 prepare command line cl for running the tool here
0183cad9d13b planemo upload
fubar
parents:
diff changeset
83 and prepare elements needed for galaxyxml tool generation
0183cad9d13b planemo upload
fubar
parents:
diff changeset
84 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
85 self.local_tools = os.path.join(args.galaxy_root,'local_tools')
0183cad9d13b planemo upload
fubar
parents:
diff changeset
86 self.ourcwd = os.getcwd()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
87 self.collections = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
88 if len(args.collection) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
89 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
90 self.collections = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
91 json.loads(x) for x in args.collection if len(x.strip()) > 1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
92 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
93 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
94 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
95 f"--collections parameter {str(args.collection)} is malformed - should be a dictionary"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
96 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
97 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
98 self.infiles = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
99 json.loads(x) for x in args.input_files if len(x.strip()) > 1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
100 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
101 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
102 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
103 f"--input_files parameter {str(args.input_files)} is malformed - should be a dictionary"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
104 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
105 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
106 self.outfiles = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
107 json.loads(x) for x in args.output_files if len(x.strip()) > 1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
108 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
109 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
110 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
111 f"--output_files parameter {args.output_files} is malformed - should be a dictionary"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
112 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
113 assert (len(self.outfiles) + len(self.collections)) > 0, 'No outfiles or output collections specified. The Galaxy job runner will fail without an output of some sort'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
114 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
115 self.addpar = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
116 json.loads(x) for x in args.additional_parameters if len(x.strip()) > 1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
117 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
118 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
119 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
120 f"--additional_parameters {args.additional_parameters} is malformed - should be a dictionary"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
121 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
122 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
123 self.selpar = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
124 json.loads(x) for x in args.selecttext_parameters if len(x.strip()) > 1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
125 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
126 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
127 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
128 f"--selecttext_parameters {args.selecttext_parameters} is malformed - should be a dictionary"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
129 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
130 self.args = args
0183cad9d13b planemo upload
fubar
parents:
diff changeset
131 self.cleanuppar()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
132 self.lastxclredirect = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
133 self.xmlcl = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
134 self.is_positional = self.args.parampass == "positional"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
135 if self.args.sysexe:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
136 if " " in self.args.sysexe:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
137 self.executeme = shlex.split(self.args.sysexe)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
138 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
139 self.executeme = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
140 self.args.sysexe,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
141 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
142 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
143 if self.args.packages:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
144 self.executeme = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
145 self.args.packages.split(",")[0].split(":")[0].strip(),
0183cad9d13b planemo upload
fubar
parents:
diff changeset
146 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
147 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
148 self.executeme = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
149 aXCL = self.xmlcl.append
0183cad9d13b planemo upload
fubar
parents:
diff changeset
150 assert args.parampass in [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
151 "0",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
152 "argparse",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
153 "positional",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
154 ], 'args.parampass must be "0","positional" or "argparse"'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
155 self.tool_name = re.sub("[^a-zA-Z0-9_]+", "", args.tool_name)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
156 self.tool_id = self.tool_name
0183cad9d13b planemo upload
fubar
parents:
diff changeset
157 self.newtool = gxt.Tool(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
158 self.tool_name,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
159 self.tool_id,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
160 self.args.tool_version,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
161 self.args.tool_desc,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
162 FAKEEXE,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
163 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
164 self.tooloutdir = "./tfout"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
165 self.repdir = "./toolgen"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
166 self.newtarpath = args.untested_tool_out # os.path.join(self.tooloutdir, "%s_not_tested_toolshed.gz" % self.tool_name)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
167 self.testdir = os.path.join(self.tooloutdir, "test-data")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
168 if not os.path.exists(self.tooloutdir):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
169 os.mkdir(self.tooloutdir)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
170 if not os.path.exists(self.testdir):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
171 os.mkdir(self.testdir)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
172 if not os.path.exists(self.repdir):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
173 os.mkdir(self.repdir)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
174 self.tlog = os.path.join(self.repdir,'%s_TF_run_log.txt' % self.tool_name)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
175 self.tinputs = gxtp.Inputs()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
176 self.toutputs = gxtp.Outputs()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
177 self.testparam = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
178 if self.args.script_path:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
179 self.prepScript()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
180 if self.args.command_override:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
181 scos = open(self.args.command_override, "r").readlines()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
182 self.command_override = [x.rstrip() for x in scos]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
183 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
184 self.command_override = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
185 if self.args.test_override:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
186 stos = open(self.args.test_override, "r").readlines()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
187 self.test_override = [x.rstrip() for x in stos]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
188 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
189 self.test_override = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
190 if self.args.script_path:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
191 for ex in self.executeme:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
192 aXCL(ex)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
193 aXCL("$runme")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
194 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
195 for ex in self.executeme:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
196 aXCL(ex)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
197
0183cad9d13b planemo upload
fubar
parents:
diff changeset
198 if self.args.parampass == "0":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
199 self.clsimple()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
200 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
201 if self.args.parampass == "positional":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
202 self.prepclpos()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
203 self.clpositional()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
204 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
205 self.prepargp()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
206 self.clargparse()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
207
0183cad9d13b planemo upload
fubar
parents:
diff changeset
208 def clsimple(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
209 """no parameters or repeats - uses < and > for i/o"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
210 aXCL = self.xmlcl.append
0183cad9d13b planemo upload
fubar
parents:
diff changeset
211 if len(self.infiles) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
212 aXCL("<")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
213 aXCL("$%s" % self.infiles[0]["infilename"])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
214 if len(self.outfiles) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
215 aXCL(">")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
216 aXCL("$%s" % self.outfiles[0]["name"])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
217 if self.args.cl_user_suffix: # DIY CL end
0183cad9d13b planemo upload
fubar
parents:
diff changeset
218 clp = shlex.split(self.args.cl_user_suffix)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
219 for c in clp:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
220 aXCL(c)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
221
0183cad9d13b planemo upload
fubar
parents:
diff changeset
222 def prepargp(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
223 xclsuffix = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
224 for i, p in enumerate(self.infiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
225 nam = p["infilename"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
226 if p["origCL"].strip().upper() == "STDIN":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
227 xappendme = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
228 nam,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
229 nam,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
230 "< $%s" % nam,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
231 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
232 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
233 rep = p["repeat"] == "1"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
234 over = ""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
235 if rep:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
236 over = f'#for $rep in $R_{nam}:\n--{nam} "$rep.{nam}"\n#end for'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
237 xappendme = [p["CL"], "$%s" % p["CL"], over]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
238 xclsuffix.append(xappendme)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
239 for i, p in enumerate(self.outfiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
240 if p["origCL"].strip().upper() == "STDOUT":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
241 self.lastxclredirect = [">", "$%s" % p["name"]]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
242 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
243 xclsuffix.append([p["name"], "$%s" % p["name"], ""])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
244 for p in self.addpar:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
245 nam = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
246 rep = p["repeat"] == "1"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
247 if rep:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
248 over = f'#for $rep in $R_{nam}:\n--{nam} "$rep.{nam}"\n#end for'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
249 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
250 over = p["override"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
251 xclsuffix.append([p["CL"], '"$%s"' % nam, over])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
252 for p in self.selpar:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
253 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
254 self.xclsuffix = xclsuffix
0183cad9d13b planemo upload
fubar
parents:
diff changeset
255
0183cad9d13b planemo upload
fubar
parents:
diff changeset
256 def prepclpos(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
257 xclsuffix = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
258 for i, p in enumerate(self.infiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
259 if p["origCL"].strip().upper() == "STDIN":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
260 xappendme = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
261 "999",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
262 p["infilename"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
263 "< $%s" % p["infilename"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
264 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
265 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
266 xappendme = [p["CL"], "$%s" % p["infilename"], ""]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
267 xclsuffix.append(xappendme)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
268 for i, p in enumerate(self.outfiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
269 if p["origCL"].strip().upper() == "STDOUT":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
270 self.lastxclredirect = [">", "$%s" % p["name"]]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
271 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
272 xclsuffix.append([p["CL"], "$%s" % p["name"], ""])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
273 for p in self.addpar:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
274 nam = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
275 rep = p["repeat"] == "1" # repeats make NO sense
0183cad9d13b planemo upload
fubar
parents:
diff changeset
276 if rep:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
277 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
278 f"### warning. Repeats for {nam} ignored - not permitted in positional parameter command lines!"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
279 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
280 over = p["override"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
281 xclsuffix.append([p["CL"], '"$%s"' % nam, over])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
282 for p in self.selpar:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
283 xclsuffix.append([p["CL"], '"$%s"' % p["name"], p["override"]])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
284 xclsuffix.sort()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
285 self.xclsuffix = xclsuffix
0183cad9d13b planemo upload
fubar
parents:
diff changeset
286
0183cad9d13b planemo upload
fubar
parents:
diff changeset
287 def prepScript(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
288 rx = open(self.args.script_path, "r").readlines()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
289 rx = [x.rstrip() for x in rx]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
290 rxcheck = [x.strip() for x in rx if x.strip() > ""]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
291 assert len(rxcheck) > 0, "Supplied script is empty. Cannot run"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
292 self.script = "\n".join(rx)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
293 fhandle, self.sfile = tempfile.mkstemp(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
294 prefix=self.tool_name, suffix="_%s" % (self.executeme[0])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
295 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
296 tscript = open(self.sfile, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
297 tscript.write(self.script)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
298 tscript.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
299 self.spacedScript = [f" {x}" for x in rx if x.strip() > ""]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
300 rx.insert(0, "#raw")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
301 rx.append("#end raw")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
302 self.escapedScript = rx
0183cad9d13b planemo upload
fubar
parents:
diff changeset
303 art = "%s.%s" % (self.tool_name, self.executeme[0])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
304 artifact = open(art, "wb")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
305 artifact.write(bytes(self.script, "utf8"))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
306 artifact.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
307
0183cad9d13b planemo upload
fubar
parents:
diff changeset
308 def cleanuppar(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
309 """ positional parameters are complicated by their numeric ordinal"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
310 if self.args.parampass == "positional":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
311 for i, p in enumerate(self.infiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
312 assert (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
313 p["CL"].isdigit() or p["CL"].strip().upper() == "STDIN"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
314 ), "Positional parameters must be ordinal integers - got %s for %s" % (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
315 p["CL"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
316 p["label"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
317 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
318 for i, p in enumerate(self.outfiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
319 assert (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
320 p["CL"].isdigit() or p["CL"].strip().upper() == "STDOUT"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
321 ), "Positional parameters must be ordinal integers - got %s for %s" % (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
322 p["CL"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
323 p["name"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
324 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
325 for i, p in enumerate(self.addpar):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
326 assert p[
0183cad9d13b planemo upload
fubar
parents:
diff changeset
327 "CL"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
328 ].isdigit(), "Positional parameters must be ordinal integers - got %s for %s" % (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
329 p["CL"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
330 p["name"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
331 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
332 for i, p in enumerate(self.infiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
333 infp = copy.copy(p)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
334 infp["origCL"] = infp["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
335 if self.args.parampass in ["positional", "0"]:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
336 infp["infilename"] = infp["label"].replace(" ", "_")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
337 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
338 infp["infilename"] = infp["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
339 self.infiles[i] = infp
0183cad9d13b planemo upload
fubar
parents:
diff changeset
340 for i, p in enumerate(self.outfiles):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
341 outfp = copy.copy(p)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
342 outfp["origCL"] = outfp["CL"] # keep copy
0183cad9d13b planemo upload
fubar
parents:
diff changeset
343 self.outfiles[i] = outfp
0183cad9d13b planemo upload
fubar
parents:
diff changeset
344 for i, p in enumerate(self.addpar):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
345 addp = copy.copy(p)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
346 addp["origCL"] = addp["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
347 self.addpar[i] = addp
0183cad9d13b planemo upload
fubar
parents:
diff changeset
348
0183cad9d13b planemo upload
fubar
parents:
diff changeset
349 def clpositional(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
350 # inputs in order then params
0183cad9d13b planemo upload
fubar
parents:
diff changeset
351 aXCL = self.xmlcl.append
0183cad9d13b planemo upload
fubar
parents:
diff changeset
352 for (k, v, koverride) in self.xclsuffix:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
353 aXCL(v)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
354 if self.lastxclredirect:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
355 for cl in self.lastxclredirect:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
356 aXCL(cl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
357 if self.args.cl_user_suffix: # DIY CL end
0183cad9d13b planemo upload
fubar
parents:
diff changeset
358 clp = shlex.split(self.args.cl_user_suffix)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
359 for c in clp:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
360 aXCL(c)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
361
0183cad9d13b planemo upload
fubar
parents:
diff changeset
362 def clargparse(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
363 """argparse style"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
364 aXCL = self.xmlcl.append
0183cad9d13b planemo upload
fubar
parents:
diff changeset
365 # inputs then params in argparse named form
0183cad9d13b planemo upload
fubar
parents:
diff changeset
366
0183cad9d13b planemo upload
fubar
parents:
diff changeset
367 for (k, v, koverride) in self.xclsuffix:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
368 if koverride > "":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
369 k = koverride
0183cad9d13b planemo upload
fubar
parents:
diff changeset
370 aXCL(k)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
371 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
372 if len(k.strip()) == 1:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
373 k = "-%s" % k
0183cad9d13b planemo upload
fubar
parents:
diff changeset
374 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
375 k = "--%s" % k
0183cad9d13b planemo upload
fubar
parents:
diff changeset
376 aXCL(k)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
377 aXCL(v)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
378 if self.lastxclredirect:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
379 for cl in self.lastxclredirect:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
380 aXCL(cl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
381 if self.args.cl_user_suffix: # DIY CL end
0183cad9d13b planemo upload
fubar
parents:
diff changeset
382 clp = shlex.split(self.args.cl_user_suffix)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
383 for c in clp:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
384 aXCL(c)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
385
0183cad9d13b planemo upload
fubar
parents:
diff changeset
386 def getNdash(self, newname):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
387 if self.is_positional:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
388 ndash = 0
0183cad9d13b planemo upload
fubar
parents:
diff changeset
389 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
390 ndash = 2
0183cad9d13b planemo upload
fubar
parents:
diff changeset
391 if len(newname) < 2:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
392 ndash = 1
0183cad9d13b planemo upload
fubar
parents:
diff changeset
393 return ndash
0183cad9d13b planemo upload
fubar
parents:
diff changeset
394
0183cad9d13b planemo upload
fubar
parents:
diff changeset
395 def doXMLparam(self): # noqa
0183cad9d13b planemo upload
fubar
parents:
diff changeset
396 """Add all needed elements to tool"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
397 for p in self.outfiles:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
398 newname = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
399 newfmt = p["format"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
400 newcl = p["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
401 test = p["test"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
402 oldcl = p["origCL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
403 test = test.strip()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
404 ndash = self.getNdash(newcl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
405 aparm = gxtp.OutputData(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
406 name=newname, format=newfmt, num_dashes=ndash, label=newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
407 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
408 aparm.positional = self.is_positional
0183cad9d13b planemo upload
fubar
parents:
diff changeset
409 if self.is_positional:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
410 if oldcl.upper() == "STDOUT":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
411 aparm.positional = 9999999
0183cad9d13b planemo upload
fubar
parents:
diff changeset
412 aparm.command_line_override = "> $%s" % newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
413 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
414 aparm.positional = int(oldcl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
415 aparm.command_line_override = "$%s" % newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
416 self.toutputs.append(aparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
417 ld = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
418 if test.strip() > "":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
419 if test.strip().startswith("diff"):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
420 c = "diff"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
421 ld = 0
0183cad9d13b planemo upload
fubar
parents:
diff changeset
422 if test.split(":")[1].isdigit:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
423 ld = int(test.split(":")[1])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
424 tp = gxtp.TestOutput(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
425 name=newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
426 value="%s_sample" % newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
427 compare=c,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
428 lines_diff=ld,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
429 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
430 elif test.startswith("sim_size"):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
431 c = "sim_size"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
432 tn = test.split(":")[1].strip()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
433 if tn > "":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
434 if "." in tn:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
435 delta = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
436 delta_frac = min(1.0, float(tn))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
437 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
438 delta = int(tn)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
439 delta_frac = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
440 tp = gxtp.TestOutput(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
441 name=newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
442 value="%s_sample" % newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
443 compare=c,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
444 delta=delta,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
445 delta_frac=delta_frac,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
446 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
447 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
448 c = test
0183cad9d13b planemo upload
fubar
parents:
diff changeset
449 tp = gxtp.TestOutput(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
450 name=newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
451 value="%s_sample" % newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
452 compare=c,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
453 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
454 self.testparam.append(tp)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
455 for p in self.infiles:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
456 newname = p["infilename"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
457 newfmt = p["format"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
458 ndash = self.getNdash(newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
459 reps = p.get("repeat", "0") == "1"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
460 if not len(p["label"]) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
461 alab = p["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
462 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
463 alab = p["label"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
464 aninput = gxtp.DataParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
465 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
466 optional=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
467 label=alab,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
468 help=p["help"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
469 format=newfmt,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
470 multiple=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
471 num_dashes=ndash,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
472 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
473 aninput.positional = self.is_positional
0183cad9d13b planemo upload
fubar
parents:
diff changeset
474 if self.is_positional:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
475 if p["origCL"].upper() == "STDIN":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
476 aninput.positional = 9999998
0183cad9d13b planemo upload
fubar
parents:
diff changeset
477 aninput.command_line_override = "< $%s" % newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
478 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
479 aninput.positional = int(p["origCL"])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
480 aninput.command_line_override = "$%s" % newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
481 if reps:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
482 repe = gxtp.Repeat(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
483 name=f"R_{newname}", title=f"Add as many {alab} as needed"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
484 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
485 repe.append(aninput)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
486 self.tinputs.append(repe)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
487 tparm = gxtp.TestRepeat(name=f"R_{newname}")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
488 tparm2 = gxtp.TestParam(newname, value="%s_sample" % newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
489 tparm.append(tparm2)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
490 self.testparam.append(tparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
491 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
492 self.tinputs.append(aninput)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
493 tparm = gxtp.TestParam(newname, value="%s_sample" % newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
494 self.testparam.append(tparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
495 for p in self.addpar:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
496 newname = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
497 newval = p["value"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
498 newlabel = p["label"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
499 newhelp = p["help"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
500 newtype = p["type"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
501 newcl = p["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
502 oldcl = p["origCL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
503 reps = p["repeat"] == "1"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
504 if not len(newlabel) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
505 newlabel = newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
506 ndash = self.getNdash(newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
507 if newtype == "text":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
508 aparm = gxtp.TextParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
509 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
510 label=newlabel,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
511 help=newhelp,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
512 value=newval,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
513 num_dashes=ndash,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
514 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
515 elif newtype == "integer":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
516 aparm = gxtp.IntegerParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
517 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
518 label=newlabel,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
519 help=newhelp,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
520 value=newval,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
521 num_dashes=ndash,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
522 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
523 elif newtype == "float":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
524 aparm = gxtp.FloatParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
525 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
526 label=newlabel,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
527 help=newhelp,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
528 value=newval,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
529 num_dashes=ndash,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
530 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
531 elif newtype == "boolean":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
532 aparm = gxtp.BooleanParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
533 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
534 label=newlabel,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
535 help=newhelp,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
536 value=newval,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
537 num_dashes=ndash,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
538 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
539 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
540 raise ValueError(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
541 'Unrecognised parameter type "%s" for\
0183cad9d13b planemo upload
fubar
parents:
diff changeset
542 additional parameter %s in makeXML'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
543 % (newtype, newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
544 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
545 aparm.positional = self.is_positional
0183cad9d13b planemo upload
fubar
parents:
diff changeset
546 if self.is_positional:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
547 aparm.positional = int(oldcl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
548 if reps:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
549 repe = gxtp.Repeat(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
550 name=f"R_{newname}", title=f"Add as many {newlabel} as needed"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
551 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
552 repe.append(aparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
553 self.tinputs.append(repe)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
554 tparm = gxtp.TestRepeat(name=f"R_{newname}")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
555 tparm2 = gxtp.TestParam(newname, value=newval)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
556 tparm.append(tparm2)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
557 self.testparam.append(tparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
558 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
559 self.tinputs.append(aparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
560 tparm = gxtp.TestParam(newname, value=newval)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
561 self.testparam.append(tparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
562 for p in self.selpar:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
563 newname = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
564 newval = p["value"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
565 newlabel = p["label"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
566 newhelp = p["help"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
567 newtype = p["type"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
568 newcl = p["CL"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
569 if not len(newlabel) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
570 newlabel = newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
571 ndash = self.getNdash(newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
572 if newtype == "selecttext":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
573 newtext = p["texts"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
574 aparm = gxtp.SelectParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
575 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
576 label=newlabel,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
577 help=newhelp,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
578 num_dashes=ndash,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
579 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
580 for i in range(len(newval)):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
581 anopt = gxtp.SelectOption(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
582 value=newval[i],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
583 text=newtext[i],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
584 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
585 aparm.append(anopt)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
586 aparm.positional = self.is_positional
0183cad9d13b planemo upload
fubar
parents:
diff changeset
587 if self.is_positional:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
588 aparm.positional = int(newcl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
589 self.tinputs.append(aparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
590 tparm = gxtp.TestParam(newname, value=newval)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
591 self.testparam.append(tparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
592 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
593 raise ValueError(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
594 'Unrecognised parameter type "%s" for\
0183cad9d13b planemo upload
fubar
parents:
diff changeset
595 selecttext parameter %s in makeXML'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
596 % (newtype, newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
597 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
598 for p in self.collections:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
599 newkind = p["kind"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
600 newname = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
601 newlabel = p["label"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
602 newdisc = p["discover"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
603 collect = gxtp.OutputCollection(newname, label=newlabel, type=newkind)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
604 disc = gxtp.DiscoverDatasets(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
605 pattern=newdisc, directory=f"{newname}", visible="false"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
606 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
607 collect.append(disc)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
608 self.toutputs.append(collect)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
609 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
610 tparm = gxtp.TestOutputCollection(newname) # broken until PR merged.
0183cad9d13b planemo upload
fubar
parents:
diff changeset
611 self.testparam.append(tparm)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
612 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
613 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
614 "#### WARNING: Galaxyxml version does not have the PR merged yet - tests for collections must be over-ridden until then!"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
615 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
616
0183cad9d13b planemo upload
fubar
parents:
diff changeset
617 def doNoXMLparam(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
618 """filter style package - stdin to stdout"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
619 if len(self.infiles) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
620 alab = self.infiles[0]["label"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
621 if len(alab) == 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
622 alab = self.infiles[0]["infilename"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
623 max1s = (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
624 "Maximum one input if parampass is 0 but multiple input files supplied - %s"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
625 % str(self.infiles)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
626 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
627 assert len(self.infiles) == 1, max1s
0183cad9d13b planemo upload
fubar
parents:
diff changeset
628 newname = self.infiles[0]["infilename"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
629 aninput = gxtp.DataParam(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
630 newname,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
631 optional=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
632 label=alab,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
633 help=self.infiles[0]["help"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
634 format=self.infiles[0]["format"],
0183cad9d13b planemo upload
fubar
parents:
diff changeset
635 multiple=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
636 num_dashes=0,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
637 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
638 aninput.command_line_override = "< $%s" % newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
639 aninput.positional = True
0183cad9d13b planemo upload
fubar
parents:
diff changeset
640 self.tinputs.append(aninput)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
641 tp = gxtp.TestParam(name=newname, value="%s_sample" % newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
642 self.testparam.append(tp)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
643 if len(self.outfiles) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
644 newname = self.outfiles[0]["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
645 newfmt = self.outfiles[0]["format"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
646 anout = gxtp.OutputData(newname, format=newfmt, num_dashes=0)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
647 anout.command_line_override = "> $%s" % newname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
648 anout.positional = self.is_positional
0183cad9d13b planemo upload
fubar
parents:
diff changeset
649 self.toutputs.append(anout)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
650 tp = gxtp.TestOutput(name=newname, value="%s_sample" % newname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
651 self.testparam.append(tp)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
652
0183cad9d13b planemo upload
fubar
parents:
diff changeset
653 def makeXML(self): # noqa
0183cad9d13b planemo upload
fubar
parents:
diff changeset
654 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
655 Create a Galaxy xml tool wrapper for the new script
0183cad9d13b planemo upload
fubar
parents:
diff changeset
656 Uses galaxyhtml
0183cad9d13b planemo upload
fubar
parents:
diff changeset
657 Hmmm. How to get the command line into correct order...
0183cad9d13b planemo upload
fubar
parents:
diff changeset
658 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
659 if self.command_override:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
660 self.newtool.command_override = self.command_override # config file
0183cad9d13b planemo upload
fubar
parents:
diff changeset
661 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
662 self.newtool.command_override = self.xmlcl
0183cad9d13b planemo upload
fubar
parents:
diff changeset
663 cite = gxtp.Citations()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
664 acite = gxtp.Citation(type="doi", value="10.1093/bioinformatics/bts573")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
665 cite.append(acite)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
666 self.newtool.citations = cite
0183cad9d13b planemo upload
fubar
parents:
diff changeset
667 safertext = ""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
668 if self.args.help_text:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
669 helptext = open(self.args.help_text, "r").readlines()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
670 safertext = "\n".join([cheetah_escape(x) for x in helptext])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
671 if len(safertext.strip()) == 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
672 safertext = (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
673 "Ask the tool author (%s) to rebuild with help text please\n"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
674 % (self.args.user_email)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
675 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
676 if self.args.script_path:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
677 if len(safertext) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
678 safertext = safertext + "\n\n------\n" # transition allowed!
0183cad9d13b planemo upload
fubar
parents:
diff changeset
679 scr = [x for x in self.spacedScript if x.strip() > ""]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
680 scr.insert(0, "\n\nScript::\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
681 if len(scr) > 300:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
682 scr = (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
683 scr[:100]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
684 + [" >300 lines - stuff deleted", " ......"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
685 + scr[-100:]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
686 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
687 scr.append("\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
688 safertext = safertext + "\n".join(scr)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
689 self.newtool.help = safertext
0183cad9d13b planemo upload
fubar
parents:
diff changeset
690 self.newtool.version_command = f'echo "{self.args.tool_version}"'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
691 std = gxtp.Stdios()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
692 std1 = gxtp.Stdio()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
693 std.append(std1)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
694 self.newtool.stdios = std
0183cad9d13b planemo upload
fubar
parents:
diff changeset
695 requirements = gxtp.Requirements()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
696 self.condaenv = []
0183cad9d13b planemo upload
fubar
parents:
diff changeset
697 if self.args.packages:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
698 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
699 for d in self.args.packages.split(","):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
700 ver = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
701 packg = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
702 d = d.replace("==", ":")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
703 d = d.replace("=", ":")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
704 if ":" in d:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
705 packg, ver = d.split(":")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
706 ver = ver.strip()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
707 packg = packg.strip()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
708 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
709 packg = d.strip()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
710 ver = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
711 if ver == "":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
712 ver = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
713 if packg:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
714 requirements.append(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
715 gxtp.Requirement("package", packg.strip(), ver)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
716 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
717 self.condaenv.append(d)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
718 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
719 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
720 "### malformed packages string supplied - cannot parse =",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
721 self.args.packages,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
722 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
723 sys.exit(2)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
724 self.newtool.requirements = requirements
0183cad9d13b planemo upload
fubar
parents:
diff changeset
725 if self.args.parampass == "0":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
726 self.doNoXMLparam()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
727 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
728 self.doXMLparam()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
729 self.newtool.outputs = self.toutputs
0183cad9d13b planemo upload
fubar
parents:
diff changeset
730 self.newtool.inputs = self.tinputs
0183cad9d13b planemo upload
fubar
parents:
diff changeset
731 if self.args.script_path:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
732 configfiles = gxtp.Configfiles()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
733 configfiles.append(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
734 gxtp.Configfile(name="runme", text="\n".join(self.escapedScript))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
735 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
736 self.newtool.configfiles = configfiles
0183cad9d13b planemo upload
fubar
parents:
diff changeset
737 tests = gxtp.Tests()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
738 test_a = gxtp.Test()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
739 for tp in self.testparam:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
740 test_a.append(tp)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
741 tests.append(test_a)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
742 self.newtool.tests = tests
0183cad9d13b planemo upload
fubar
parents:
diff changeset
743 self.newtool.add_comment(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
744 "Created by %s at %s using the Galaxy Tool Factory."
0183cad9d13b planemo upload
fubar
parents:
diff changeset
745 % (self.args.user_email, timenow())
0183cad9d13b planemo upload
fubar
parents:
diff changeset
746 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
747 self.newtool.add_comment("Source in git at: %s" % (toolFactoryURL))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
748 exml0 = self.newtool.export()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
749 exml = exml0.replace(FAKEEXE, "") # temporary work around until PR accepted
0183cad9d13b planemo upload
fubar
parents:
diff changeset
750 if (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
751 self.test_override
0183cad9d13b planemo upload
fubar
parents:
diff changeset
752 ): # cannot do this inside galaxyxml as it expects lxml objects for tests
0183cad9d13b planemo upload
fubar
parents:
diff changeset
753 part1 = exml.split("<tests>")[0]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
754 part2 = exml.split("</tests>")[1]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
755 fixed = "%s\n%s\n%s" % (part1, "\n".join(self.test_override), part2)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
756 exml = fixed
0183cad9d13b planemo upload
fubar
parents:
diff changeset
757 with open("%s.xml" % self.tool_name, "w") as xf:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
758 xf.write(exml)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
759 xf.write("\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
760 # galaxy history item
0183cad9d13b planemo upload
fubar
parents:
diff changeset
761
0183cad9d13b planemo upload
fubar
parents:
diff changeset
762 def writeShedyml(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
763 """for planemo"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
764 yuser = self.args.user_email.split("@")[0]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
765 yfname = os.path.join(self.tooloutdir, ".shed.yml")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
766 yamlf = open(yfname, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
767 odict = {
0183cad9d13b planemo upload
fubar
parents:
diff changeset
768 "name": self.tool_name,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
769 "owner": yuser,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
770 "type": "unrestricted",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
771 "description": self.args.tool_desc,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
772 "synopsis": self.args.tool_desc,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
773 "category": "TF Generated Tools",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
774 }
0183cad9d13b planemo upload
fubar
parents:
diff changeset
775 yaml.dump(odict, yamlf, allow_unicode=True)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
776 yamlf.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
777
0183cad9d13b planemo upload
fubar
parents:
diff changeset
778 def makeTool(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
779 """write xmls and input samples into place"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
780 if self.args.parampass == 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
781 self.doNoXMLparam()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
782 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
783 self.makeXML()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
784 if self.args.script_path:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
785 stname = os.path.join(self.tooloutdir, self.sfile)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
786 if not os.path.exists(stname):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
787 shutil.copyfile(self.sfile, stname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
788 xreal = "%s.xml" % self.tool_name
0183cad9d13b planemo upload
fubar
parents:
diff changeset
789 xout = os.path.join(self.tooloutdir, xreal)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
790 shutil.copyfile(xreal, xout)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
791 xout = os.path.join(self.repdir, xreal)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
792 shutil.copyfile(xreal, xout)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
793 for p in self.infiles:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
794 pth = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
795 dest = os.path.join(self.testdir, "%s_sample" % p["infilename"])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
796 shutil.copyfile(pth, dest)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
797 dest = os.path.join(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
798 self.repdir, "%s_sample.%s" % (p["infilename"], p["format"])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
799 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
800 shutil.copyfile(pth, dest)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
801 dest = os.path.join(self.local_tools, self.tool_name)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
802 shutil.copytree(self.tooloutdir,dest, dirs_exist_ok=True)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
803
0183cad9d13b planemo upload
fubar
parents:
diff changeset
804 def makeToolTar(self, report_fail=False):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
805 """move outputs into test-data and prepare the tarball"""
0183cad9d13b planemo upload
fubar
parents:
diff changeset
806 excludeme = "_planemo_test_report.html"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
807
0183cad9d13b planemo upload
fubar
parents:
diff changeset
808 def exclude_function(tarinfo):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
809 filename = tarinfo.name
0183cad9d13b planemo upload
fubar
parents:
diff changeset
810 return None if filename.endswith(excludeme) else tarinfo
0183cad9d13b planemo upload
fubar
parents:
diff changeset
811
0183cad9d13b planemo upload
fubar
parents:
diff changeset
812 for p in self.outfiles:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
813 oname = p["name"]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
814 tdest = os.path.join(self.testdir, "%s_sample" % oname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
815 src = os.path.join(self.testdir, oname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
816 if not os.path.isfile(tdest):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
817 if os.path.isfile(src):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
818 shutil.copyfile(src, tdest)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
819 dest = os.path.join(self.repdir, "%s.sample.%s" % (oname,p['format']))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
820 shutil.copyfile(src, dest)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
821 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
822 if report_fail:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
823 print(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
824 "###Tool may have failed - output file %s not found in testdir after planemo run %s."
0183cad9d13b planemo upload
fubar
parents:
diff changeset
825 % (tdest, self.testdir)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
826 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
827 tf = tarfile.open(self.newtarpath, "w:gz")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
828 tf.add(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
829 name=self.tooloutdir,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
830 arcname=self.tool_name,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
831 filter=exclude_function,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
832 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
833 shutil.copy(self.newtarpath, os.path.join(self.tooloutdir, f"{self.tool_name}_untested_toolshed.gz"))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
834 tf.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
835
0183cad9d13b planemo upload
fubar
parents:
diff changeset
836
0183cad9d13b planemo upload
fubar
parents:
diff changeset
837 def planemo_test_update(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
838 """planemo is a requirement so is available for testing
0183cad9d13b planemo upload
fubar
parents:
diff changeset
839 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
840 xreal = "%s.xml" % self.tool_name
0183cad9d13b planemo upload
fubar
parents:
diff changeset
841 tool_test_path = os.path.join(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
842 self.repdir, f"{self.tool_name}_planemo_test_report.html"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
843 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
844 if os.path.exists(self.tlog):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
845 tout = open(self.tlog, "a")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
846 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
847 tout = open(self.tlog, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
848 cll = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
849 "planemo",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
850 "test",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
851 "--conda_auto_init",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
852 "--biocontainers",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
853 "--test_data",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
854 os.path.abspath(self.testdir),
0183cad9d13b planemo upload
fubar
parents:
diff changeset
855 "--test_output",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
856 os.path.abspath(tool_test_path),
0183cad9d13b planemo upload
fubar
parents:
diff changeset
857 "--galaxy_root",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
858 self.args.galaxy_root,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
859 "--update_test_data",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
860 os.path.abspath(xreal),
0183cad9d13b planemo upload
fubar
parents:
diff changeset
861 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
862 p = subprocess.run(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
863 cll,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
864 shell=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
865 cwd=self.tooloutdir,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
866 stderr=tout,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
867 stdout=tout,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
868 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
869 tout.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
870 return p.returncode
0183cad9d13b planemo upload
fubar
parents:
diff changeset
871
0183cad9d13b planemo upload
fubar
parents:
diff changeset
872
0183cad9d13b planemo upload
fubar
parents:
diff changeset
873 def update_toolconf(self ):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
874
0183cad9d13b planemo upload
fubar
parents:
diff changeset
875 def sortchildrenby(parent, attr):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
876 parent[:] = sorted(parent, key=lambda child: child.get(attr))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
877
0183cad9d13b planemo upload
fubar
parents:
diff changeset
878 tcpath = os.path.join(self.args.galaxy_root,'config/local_tool_conf.xml')
0183cad9d13b planemo upload
fubar
parents:
diff changeset
879 xmlfile = os.path.join(self.local_tools, self.tool_name, '%s.xml' % self.tool_name)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
880 parser = ET.XMLParser(remove_blank_text=True)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
881 tree = ET.parse(tcpath, parser)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
882 root = tree.getroot()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
883 hasTF = False
0183cad9d13b planemo upload
fubar
parents:
diff changeset
884 e = root.findall("section")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
885 if len(e) > 0:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
886 hasTF = True
0183cad9d13b planemo upload
fubar
parents:
diff changeset
887 TFsection = e[0]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
888 if not hasTF:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
889 TFsection = ET.Element("section", {"id":"localtools", "name":"Local Tools"})
0183cad9d13b planemo upload
fubar
parents:
diff changeset
890 root.insert(0, TFsection) # at the top!
0183cad9d13b planemo upload
fubar
parents:
diff changeset
891 our_tools = TFsection.findall("tool")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
892 conf_tools = [x.attrib["file"] for x in our_tools]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
893 if xmlfile not in conf_tools: # new
0183cad9d13b planemo upload
fubar
parents:
diff changeset
894 ET.SubElement(TFsection, "tool", {"file": xmlfile})
0183cad9d13b planemo upload
fubar
parents:
diff changeset
895 sortchildrenby(TFsection,"file")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
896 tree.write(tcpath, pretty_print=True)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
897
0183cad9d13b planemo upload
fubar
parents:
diff changeset
898
0183cad9d13b planemo upload
fubar
parents:
diff changeset
899
0183cad9d13b planemo upload
fubar
parents:
diff changeset
900
0183cad9d13b planemo upload
fubar
parents:
diff changeset
901
0183cad9d13b planemo upload
fubar
parents:
diff changeset
902
0183cad9d13b planemo upload
fubar
parents:
diff changeset
903 def shedLoad(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
904 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
905 use bioblend to create new repository
0183cad9d13b planemo upload
fubar
parents:
diff changeset
906 or update existing
0183cad9d13b planemo upload
fubar
parents:
diff changeset
907
0183cad9d13b planemo upload
fubar
parents:
diff changeset
908 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
909 if os.path.exists(self.tlog):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
910 sto = open(self.tlog, "a")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
911 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
912 sto = open(self.tlog, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
913
0183cad9d13b planemo upload
fubar
parents:
diff changeset
914 ts = toolshed.ToolShedInstance(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
915 url=self.args.toolshed_url,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
916 key=self.args.toolshed_api_key,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
917 verify=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
918 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
919 repos = ts.repositories.get_repositories()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
920 rnames = [x.get("name", "?") for x in repos]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
921 rids = [x.get("id", "?") for x in repos]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
922 tfcat = "ToolFactory generated tools"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
923 if self.tool_name not in rnames:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
924 tscat = ts.categories.get_categories()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
925 cnames = [x.get("name", "?").strip() for x in tscat]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
926 cids = [x.get("id", "?") for x in tscat]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
927 catID = None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
928 if tfcat.strip() in cnames:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
929 ci = cnames.index(tfcat)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
930 catID = cids[ci]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
931 res = ts.repositories.create_repository(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
932 name=self.args.tool_name,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
933 synopsis="Synopsis:%s" % self.args.tool_desc,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
934 description=self.args.tool_desc,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
935 type="unrestricted",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
936 remote_repository_url=self.args.toolshed_url,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
937 homepage_url=None,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
938 category_ids=catID,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
939 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
940 tid = res.get("id", None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
941 sto.write(f"#create_repository {self.args.tool_name} tid={tid} res={res}\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
942 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
943 i = rnames.index(self.tool_name)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
944 tid = rids[i]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
945 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
946 res = ts.repositories.update_repository(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
947 id=tid, tar_ball_path=self.newtarpath, commit_message=None
0183cad9d13b planemo upload
fubar
parents:
diff changeset
948 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
949 sto.write(f"#update res id {id} ={res}\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
950 except ConnectionError:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
951 sto.write(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
952 "####### Is the toolshed running and the API key correct? Bioblend shed upload failed\n"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
953 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
954 sto.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
955
0183cad9d13b planemo upload
fubar
parents:
diff changeset
956 def eph_galaxy_load(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
957 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
958 use ephemeris to load the new tool from the local toolshed after planemo uploads it
0183cad9d13b planemo upload
fubar
parents:
diff changeset
959 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
960 if os.path.exists(self.tlog):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
961 tout = open(self.tlog, "a")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
962 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
963 tout = open(self.tlog, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
964 cll = [
0183cad9d13b planemo upload
fubar
parents:
diff changeset
965 "shed-tools",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
966 "install",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
967 "-g",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
968 self.args.galaxy_url,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
969 "--latest",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
970 "-a",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
971 self.args.galaxy_api_key,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
972 "--name",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
973 self.tool_name,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
974 "--owner",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
975 "fubar",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
976 "--toolshed",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
977 self.args.toolshed_url,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
978 "--section_label",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
979 "ToolFactory",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
980 ]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
981 tout.write("running\n%s\n" % " ".join(cll))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
982 subp = subprocess.run(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
983 cll,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
984 env=self.ourenv,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
985 cwd=self.ourcwd,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
986 shell=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
987 stderr=tout,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
988 stdout=tout,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
989 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
990 tout.write(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
991 "installed %s - got retcode %d\n" % (self.tool_name, subp.returncode)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
992 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
993 tout.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
994 return subp.returncode
0183cad9d13b planemo upload
fubar
parents:
diff changeset
995
0183cad9d13b planemo upload
fubar
parents:
diff changeset
996 def planemo_biodocker_test(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
997 """planemo currently leaks dependencies if used in the same container and gets unhappy after a
0183cad9d13b planemo upload
fubar
parents:
diff changeset
998 first successful run. https://github.com/galaxyproject/planemo/issues/1078#issuecomment-731476930
0183cad9d13b planemo upload
fubar
parents:
diff changeset
999
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1000 Docker biocontainer has planemo with caches filled to save repeated downloads
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1001
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1002
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1003 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1004
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1005 def prun(container, tout, cl, user="biodocker"):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1006 rlog = container.exec_run(cl, user=user)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1007 slogl = str(rlog).split("\\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1008 slog = "\n".join(slogl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1009 tout.write(f"## got rlog {slog} from {cl}\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1010
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1011 if os.path.exists(self.tlog):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1012 tout = open(self.tlog, "a")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1013 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1014 tout = open(self.tlog, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1015 planemoimage = "quay.io/fubar2/planemo-biocontainer"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1016 xreal = "%s.xml" % self.tool_name
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1017 repname = f"{self.tool_name}_planemo_test_report.html"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1018 ptestrep_path = os.path.join(self.repdir, repname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1019 client = docker.from_env()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1020 tvol = client.volumes.create()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1021 tvolname = tvol.name
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1022 destdir = "/toolfactory/ptest"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1023 imrep = os.path.join(destdir, repname)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1024 # need to keep the container running so keep it open with sleep
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1025 # will stop and destroy it when we are done
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1026 container = client.containers.run(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1027 planemoimage,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1028 "sleep 120m",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1029 detach=True,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1030 user="biodocker",
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1031 volumes={f"{tvolname}": {"bind": "/toolfactory", "mode": "rw"}},
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1032 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1033 cl = f"mkdir -p {destdir}"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1034 prun(container, tout, cl, user="root")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1035 # that's how hard it is to get root on a biodocker container :(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1036 cl = f"rm -rf {destdir}/*"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1037 prun(container, tout, cl, user="root")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1038 ptestpath = os.path.join(destdir, "tfout", xreal)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1039 self.copy_to_container(self.tooloutdir, destdir, container)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1040 cl = "chown -R biodocker /toolfactory"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1041 prun(container, tout, cl, user="root")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1042 _ = container.exec_run(f"ls -la {destdir}")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1043 ptestcl = f"planemo test --test_output {imrep} --update_test_data --no_cleanup --test_data {destdir}/tfout/test-data --galaxy_root /home/biodocker/galaxy-central {ptestpath}"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1044 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1045 _ = container.exec_run(ptestcl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1046 # fails because test outputs missing but updates the test-data directory
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1047 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1048 e = sys.exc_info()[0]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1049 tout.write(f"#### error: {e} from {ptestcl}\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1050 cl = f"planemo test --test_output {imrep} --no_cleanup --test_data {destdir}/tfout/test-data --galaxy_root /home/biodocker/galaxy-central {ptestpath}"
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1051 try:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1052 prun(container, tout, cl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1053 except Exception:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1054 e = sys.exc_info()[0]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1055 tout.write(f"#### error: {e} from {ptestcl}\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1056 testouts = tempfile.mkdtemp(suffix=None, prefix="tftemp", dir=".")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1057 self.copy_from_container(destdir, testouts, container)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1058 src = os.path.join(testouts, "ptest")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1059 if os.path.isdir(src):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1060 shutil.copytree(src, ".", dirs_exist_ok=True)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1061 src = repname
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1062 if os.path.isfile(repname):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1063 shutil.copyfile(src, ptestrep_path)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1064 else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1065 tout.write(f"No output from run to shutil.copytree in {src}\n")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1066 tout.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1067 container.stop()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1068 container.remove()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1069 tvol.remove()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1070 shutil.rmtree(testouts) # leave for debugging
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1071
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1072
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1073 # def run(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1074 # """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1075 # scripts must be small enough not to fill the pipe!
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1076 # """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1077 # if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1078 # retval = self.runBash()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1079 # else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1080 # if self.opts.output_dir:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1081 # ste = open(self.elog,'w')
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1082 # sto = open(self.tlog,'w')
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1083 # sto.write('## Toolfactory generated command line = %s\n' % ' '.join(self.cl))
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1084 # sto.flush()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1085 # p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=ste,stdin=subprocess.PIPE,cwd=self.opts.output_dir)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1086 # else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1087 # p = subprocess.Popen(self.cl,shell=False,stdin=subprocess.PIPE)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1088 # p.stdin.write(self.script)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1089 # p.stdin.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1090 # retval = p.wait()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1091 # if self.opts.output_dir:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1092 # sto.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1093 # ste.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1094 # err = open(self.elog,'r').read()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1095 # if retval <> 0 and err: # problem
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1096 # print >> sys.stderr, '## error code %d returned with:\n%s' % (retval,err)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1097 # if self.opts.make_HTML:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1098 # self.makeHtml()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1099 # return retval
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1100
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1101 # def runBash(self):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1102 # """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1103 # cannot use - for bash so use self.sfile
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1104 # """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1105 # if self.opts.output_dir:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1106 # s = '## Toolfactory generated command line = %s\n' % ' '.join(self.cl)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1107 # sto = open(self.tlog,'w')
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1108 # sto.write(s)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1109 # sto.flush()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1110 # p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=sto,cwd=self.opts.output_dir)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1111 # else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1112 # p = subprocess.Popen(self.cl,shell=False)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1113 # retval = p.wait()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1114 # if self.opts.output_dir:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1115 # sto.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1116 # if self.opts.make_HTML:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1117 # self.makeHtml()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1118 # return retval
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1119
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1120 # def make_conda_env(self, dep_list):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1121 # """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1122 # (venv) galaxy@ross-newgrt:/evol/galaxy$ mulled-hash bioblend=0.17.0,galaxyxml=0.4.14
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1123 # mulled-v2-37438395e15c3d0bed4e02d66d5b05ca3d18b389:1d0b008b65909163243b3fdddd9aa20605f8a005
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1124
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1125 # conda create -n myenv python=3.9 scipy=0.17.3 astroid babel
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1126
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1127
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1128 # """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1129 # dep_list.sort()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1130 # self.env_name = '-'.join(dep_list)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1131 # for e in self.xmlcl +
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1132
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1133 # for e in self.xclsuffix:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1134 # # xappendme = ["999", p["infilename"], "< $%s" % p["infilename"]]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1135 # else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1136 # xappendme = [p["CL"], "$%s" % p["infilename"], ""]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1137 # xclsuffix.append(xappendme)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1138 # if os.path.exists(self.tlog):
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1139 # tout = open(self.tlog, "a")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1140 # else:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1141 # tout = open(self.tlog, "w")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1142 # cli = ["conda", "create", "-n", self.env_name, ' '.join(dep_list)]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1143 # p = subprocess.run(
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1144 # cll,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1145 # shell=False,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1146 # cwd=self.tooloutdir,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1147 # stderr=tout,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1148 # stdout=tout,
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1149 # )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1150 # cli = ["conda", "activate", self.env_name, " && "]
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1151 # cli.append(run_cmd)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1152 # tout.close()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1153
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1154 def main():
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1155 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1156 This is a Galaxy wrapper.
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1157 It expects to be called by a special purpose tool.xml
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1158
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1159 """
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1160 parser = argparse.ArgumentParser()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1161 a = parser.add_argument
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1162 a("--script_path", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1163 a("--history_test", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1164 a("--cl_user_suffix", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1165 a("--sysexe", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1166 a("--packages", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1167 a("--tool_name", default="newtool")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1168 a("--tool_dir", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1169 a("--input_files", default=[], action="append")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1170 a("--output_files", default=[], action="append")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1171 a("--user_email", default="Unknown")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1172 a("--bad_user", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1173 a("--help_text", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1174 a("--tool_desc", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1175 a("--tool_version", default="0.01")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1176 a("--citations", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1177 a("--command_override", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1178 a("--test_override", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1179 a("--additional_parameters", action="append", default=[])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1180 a("--selecttext_parameters", action="append", default=[])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1181 a("--edit_additional_parameters", action="store_true", default=False)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1182 a("--parampass", default="positional")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1183 a("--tfout", default="./tfout")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1184 a("--galaxy_root", default="/galaxy-central")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1185 a("--galaxy_venv", default="/galaxy_venv")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1186 a("--collection", action="append", default=[])
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1187 a("--include_tests", default=False, action="store_true")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1188 a("--install_flag", action = "store_true", default=False)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1189 a("--admin_only", default=True, action="store_true")
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1190 a("--untested_tool_out", default=None)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1191 a("--local_tools", default="tools") # relative to $__root_dir__
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1192 a("--tool_conf_path", default="config/tool_conf.xml") # relative to $__root_dir__
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1193 args = parser.parse_args()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1194 if args.admin_only:
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1195 assert not args.bad_user, (
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1196 'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy \
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1197 admin adds %s to "admin_users" in the galaxy.yml Galaxy configuration file'
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1198 % (args.bad_user, args.bad_user)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1199 )
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1200 assert args.tool_name, "## This ToolFactory cannot build a tool without a tool name. Please supply one."
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1201 tf = Tool_Factory(args)
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1202 tf.writeShedyml()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1203 tf.makeTool()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1204 tf.planemo_test_update()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1205 tf.makeToolTar()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1206 tf.update_toolconf()
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1207
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1208
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1209 if __name__ == "__main__":
0183cad9d13b planemo upload
fubar
parents:
diff changeset
1210 main()