annotate rgToolFactory2.py @ 11:000bb4888c81 draft

Deleted selected files
author fubar
date Thu, 15 Jan 2015 07:35:21 -0500
parents 8de2b7571d98
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
1 # rgToolFactoryMultIn.py
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
2 # see https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
3 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
4 # copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
5 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
6 # all rights reserved
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
7 # Licensed under the LGPL
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
8 # suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
9 #
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
10 # January 2015
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
11 # in the process of building a complex tool
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
12 # added ability to choose one of the current toolshed package_r or package_perl or package_python dependencies and source that package
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
13 # need to add that package to tool_dependencies
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
14 #
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
15 # sept 2014 added additional params from
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
16 # https://bitbucket.org/mvdbeek/dockertoolfactory/src/d4863bcf7b521532c7e8c61b6333840ba5393f73/DockerToolFactory.py?at=default
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
17 # passing them is complex
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
18 # and they are restricted to NOT contain commas or double quotes to ensure that they can be safely passed together on
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
19 # the toolfactory command line as a comma delimited double quoted string for parsing and passing to the script
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
20 # see examples on this tool form
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
21
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
22 # august 2014
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
23
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
24 # Allows arbitrary number of input files
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
25 # NOTE positional parameters are now passed to script
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
26 # and output (may be "None") is *before* arbitrary number of inputs
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
27 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
28 # march 2014
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
29 # had to remove dependencies because cross toolshed dependencies are not possible - can't pre-specify a toolshed url for graphicsmagick and ghostscript
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
30 # grrrrr - night before a demo
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
31 # added dependencies to a tool_dependencies.xml if html page generated so generated tool is properly portable
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
32 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
33 # added ghostscript and graphicsmagick as dependencies
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
34 # fixed a wierd problem where gs was trying to use the new_files_path from universe (database/tmp) as ./database/tmp
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
35 # errors ensued
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
36 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
37 # august 2013
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
38 # found a problem with GS if $TMP or $TEMP missing - now inject /tmp and warn
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
39 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
40 # july 2013
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
41 # added ability to combine images and individual log files into html output
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
42 # just make sure there's a log file foo.log and it will be output
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
43 # together with all images named like "foo_*.pdf
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
44 # otherwise old format for html
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
45 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
46 # January 2013
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
47 # problem pointed out by Carlos Borroto
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
48 # added escaping for <>$ - thought I did that ages ago...
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
49 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
50 # August 11 2012
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
51 # changed to use shell=False and cl as a sequence
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
52
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
53 # This is a Galaxy tool factory for simple scripts in python, R or whatever ails ye.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
54 # It also serves as the wrapper for the new tool.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
55 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
56 # you paste and run your script
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
57 # Only works for simple scripts that read one input from the history.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
58 # Optionally can write one new history dataset,
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
59 # and optionally collect any number of outputs into links on an autogenerated HTML page.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
60
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
61 # DO NOT install on a public or important site - please.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
62
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
63 # installed generated tools are fine if the script is safe.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
64 # They just run normally and their user cannot do anything unusually insecure
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
65 # but please, practice safe toolshed.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
66 # Read the fucking code before you install any tool
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
67 # especially this one
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
68
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
69 # After you get the script working on some test data, you can
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
70 # optionally generate a toolshed compatible gzip file
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
71 # containing your script safely wrapped as an ordinary Galaxy script in your local toolshed for
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
72 # safe and largely automated installation in a production Galaxy.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
73
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
74 # If you opt for an HTML output, you get all the script outputs arranged
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
75 # as a single Html history item - all output files are linked, thumbnails for all the pdfs.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
76 # Ugly but really inexpensive.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
77 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
78 # Patches appreciated please.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
79 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
80 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
81 # long route to June 2012 product
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
82 # Behold the awesome power of Galaxy and the toolshed with the tool factory to bind them
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
83 # derived from an integrated script model
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
84 # called rgBaseScriptWrapper.py
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
85 # Note to the unwary:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
86 # This tool allows arbitrary scripting on your Galaxy as the Galaxy user
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
87 # There is nothing stopping a malicious user doing whatever they choose
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
88 # Extremely dangerous!!
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
89 # Totally insecure. So, trusted users only
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
90 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
91 # preferred model is a developer using their throw away workstation instance - ie a private site.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
92 # no real risk. The universe_wsgi.ini admin_users string is checked - only admin users are permitted to run this tool.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
93 #
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
94
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
95 import sys
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
96 import shutil
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
97 import subprocess
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
98 import os
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
99 import time
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
100 import tempfile
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
101 import optparse
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
102 import tarfile
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
103 import re
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
104 import shutil
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
105 import math
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
106
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
107 progname = os.path.split(sys.argv[0])[1]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
108 myversion = 'V001.1 March 2014'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
109 verbose = False
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
110 debug = False
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
111 toolFactoryURL = 'https://bitbucket.org/fubar/galaxytoolfactory'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
112
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
113 # if we do html we need these dependencies specified in a tool_dependencies.xml file and referred to in the generated
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
114 # tool xml
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
115
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
116 def timenow():
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
117 """return current time as a string
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
118 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
119 return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time()))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
120
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
121 html_escape_table = {
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
122 "&": "&amp;",
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
123 ">": "&gt;",
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
124 "<": "&lt;",
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
125 "$": "\$"
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
126 }
8
9d58cc32a12d Uploaded
fubar
parents: 7
diff changeset
127
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
128 def html_escape(text):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
129 """Produce entities within text."""
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
130 return "".join(html_escape_table.get(c,c) for c in text)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
131
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
132
61381bad936d Uploaded
fubar
parents: 6
diff changeset
133 def html_unescape(text):
61381bad936d Uploaded
fubar
parents: 6
diff changeset
134 """Revert entities within text."""
8
9d58cc32a12d Uploaded
fubar
parents: 7
diff changeset
135 t = text.replace('&amp;','&').replace('&gt;','>').replace('&lt;','<').replace('\$','$')
9d58cc32a12d Uploaded
fubar
parents: 7
diff changeset
136 return t
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
137
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
138 def cmd_exists(cmd):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
139 return subprocess.call("type " + cmd, shell=True,
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
140 stdout=subprocess.PIPE, stderr=subprocess.PIPE) == 0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
141
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
142 def parse_citations(citations_text):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
143 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
144 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
145 citations = [c for c in citations_text.split("**ENTRY**") if c.strip()]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
146 citation_tuples = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
147 for citation in citations:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
148 if citation.startswith("doi"):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
149 citation_tuples.append( ("doi", citation[len("doi"):].strip() ) )
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
150 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
151 citation_tuples.append( ("bibtex", citation[len("bibtex"):].strip() ) )
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
152 return citation_tuples
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
153
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
154 def shell_source(script):
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
155 """need a way to source a Galaxy tool interpreter env.sh so we can use that dependency
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
156 package
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
157 see http://pythonwise.blogspot.fr/2010/04/sourcing-shell-script.html
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
158 Sometime you want to emulate the action of "source" in bash,
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
159 settings some environment variables. Here is a way to do it.
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
160 Note that we have to finesse the automagic exports using nulls as newlines for env"""
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
161 pipe = subprocess.Popen("env -i ; . %s ; env -0" % script, stdout=subprocess.PIPE, shell=True)
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
162 output = pipe.communicate()[0]
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
163 outl = output.split('\0')
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
164 outl = [x for x in outl if len(x.split("=")) == 2]
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
165 newenv = dict((line.split("=", 1) for line in outl))
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
166 os.environ.update(newenv)
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
167
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
168 class ScriptRunner:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
169 """class is a wrapper for an arbitrary script
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
170 note funky templating. this should all be done proper.
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
171 Problem is, this kludge developed quite naturally and seems to work ok with
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
172 little overhead...
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
173
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
174 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
175
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
176
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
177 def __init__(self,opts=None,treatbashSpecial=True):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
178 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
179 cleanup inputs, setup some outputs
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
180
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
181 """
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
182
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
183 self.toolhtmldepinterpskel = """<?xml version="1.0"?>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
184 <tool_dependency>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
185 <package name="ghostscript" version="9.10">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
186 <repository name="package_ghostscript_9_10" owner="devteam" prior_installation_required="True" />
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
187 </package>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
188 <package name="graphicsmagick" version="1.3.18">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
189 <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" />
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
190 </package>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
191 <package name="%(interpreter)s" version="%(interpreter_version)s">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
192 <repository name="%(interpreter_name)s" owner="%(interpreter_owner)s" prior_installation_required="True" />
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
193 </package>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
194
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
195 <readme>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
196 %(readme)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
197 </readme>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
198 </tool_dependency>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
199 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
200
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
201 self.toolhtmldepskel = """<?xml version="1.0"?>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
202 <tool_dependency>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
203 <package name="ghostscript" version="9.10">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
204 <repository name="package_ghostscript_9_10" owner="devteam" prior_installation_required="True" />
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
205 </package>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
206 <package name="graphicsmagick" version="1.3.18">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
207 <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" />
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
208 </package>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
209 <readme>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
210 %(readme)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
211 </readme>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
212 </tool_dependency>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
213 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
214
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
215 self.emptytoolhtmldepskel = """<?xml version="1.0"?>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
216 <tool_dependency>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
217 <readme>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
218 %(readme)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
219 </readme>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
220 </tool_dependency>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
221 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
222
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
223 self.protorequirements = """<requirements>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
224 <requirement type="package" version="9.10">ghostscript</requirement>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
225 <requirement type="package" version="1.3.18">graphicsmagick</requirement>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
226 </requirements>"""
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
227
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
228 self.protorequirements_interpreter = """<requirements>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
229 <requirement type="package" version="9.10">ghostscript</requirement>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
230 <requirement type="package" version="1.3.18">graphicsmagick</requirement>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
231 <requirement type="package" version="%(interpreter_version)s">%(interpreter_name)s</requirement>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
232 </requirements>"""
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
233
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
234
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
235 self.newCommand="""
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
236 %(toolname)s.py --script_path "$runMe" --interpreter "%(interpreter)s"
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
237 --tool_name "%(toolname)s"
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
238 %(command_inputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
239 %(command_outputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
240 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
241
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
242 self.tooltestsTabOnly = """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
243 <test>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
244 %(test1Inputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
245 <param name="job_name" value="test1"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
246 <param name="runMe" value="$runMe"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
247 <output name="output1="%(test1Output)s" ftype="tabular"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
248 %(additionalParams)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
249 </test>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
250 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
251
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
252 self.tooltestsHTMLOnly = """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
253 <test>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
254 %(test1Inputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
255 <param name="job_name" value="test1"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
256 <param name="runMe" value="$runMe"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
257 %(additionalParams)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
258 <output name="html_file" file="%(test1HTML)s" ftype="html" lines_diff="5"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
259 </test>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
260 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
261
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
262 self.tooltestsBoth = """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
263 <test>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
264 %(test1Inputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
265 <param name="job_name" value="test1"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
266 <param name="runMe" value="$runMe"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
267 %(additionalParams)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
268 <output name="output1" file="%(test1Output)s" ftype="tabular" />
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
269 <output name="html_file" file="%(test1HTML)s" ftype="html" lines_diff="10"/>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
270 </test>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
271 """
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
272
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
273 self.newXML="""<tool id="%(toolid)s" name="%(toolname)s" version="%(tool_version)s">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
274 %(tooldesc)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
275 %(requirements)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
276 <command interpreter="python">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
277 %(command)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
278 </command>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
279 <inputs>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
280 %(inputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
281 %(additionalInputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
282 </inputs>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
283 <outputs>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
284 %(outputs)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
285 </outputs>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
286 <configfiles>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
287 <configfile name="runMe">
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
288 %(script)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
289 </configfile>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
290 </configfiles>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
291 <tests>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
292 %(tooltests)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
293 </tests>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
294 <help>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
295
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
296 %(help)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
297
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
298 </help>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
299 <citations>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
300 %(citations)s
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
301 <citation type="doi">10.1093/bioinformatics/bts573</citation>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
302 </citations>
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
303 </tool>"""
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
304
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
305 self.useGM = cmd_exists('gm')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
306 self.useIM = cmd_exists('convert')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
307 self.useGS = cmd_exists('gs')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
308 self.temp_warned = False # we want only one warning if $TMP not set
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
309 self.treatbashSpecial = treatbashSpecial
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
310 if opts.output_dir: # simplify for the tool tarball
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
311 os.chdir(opts.output_dir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
312 self.thumbformat = 'png'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
313 self.opts = opts
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
314 self.toolname = re.sub('[^a-zA-Z0-9_]+', '', opts.tool_name) # a sanitizer now does this but..
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
315 self.toolid = self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
316 self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
317 self.pyfile = self.myname # crude but efficient - the cruft won't hurt much
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
318 self.xmlfile = '%s.xml' % self.toolname
4
b85a3b92e9f7 Uploaded
fubar
parents: 3
diff changeset
319 rx = open(self.opts.script_path,'r').readlines()
b85a3b92e9f7 Uploaded
fubar
parents: 3
diff changeset
320 rx = [x.rstrip() for x in rx] # remove pesky dos line endings if needed
b85a3b92e9f7 Uploaded
fubar
parents: 3
diff changeset
321 self.script = '\n'.join(rx)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
322 fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
323 tscript = open(self.sfile,'w') # use self.sfile as script source for Popen
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
324 tscript.write(self.script)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
325 tscript.close()
6
81198714ac8e Uploaded
fubar
parents: 5
diff changeset
326 self.indentedScript = " %s" % '\n'.join([' %s' % html_escape(x) for x in rx]) # for restructured text in help
81198714ac8e Uploaded
fubar
parents: 5
diff changeset
327 self.escapedScript = "%s" % '\n'.join([' %s' % html_escape(x) for x in rx])
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
328 self.elog = os.path.join(self.opts.output_dir,"%s_error.log" % self.toolname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
329 if opts.output_dir: # may not want these complexities
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
330 self.tlog = os.path.join(self.opts.output_dir,"%s_runner.log" % self.toolname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
331 art = '%s.%s' % (self.toolname,opts.interpreter)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
332 artpath = os.path.join(self.opts.output_dir,art) # need full path
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
333 artifact = open(artpath,'w') # use self.sfile as script source for Popen
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
334 artifact.write(self.script)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
335 artifact.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
336 self.cl = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
337 self.html = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
338 self.test1Inputs = [] # now a list
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
339 a = self.cl.append
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
340 a(opts.interpreter)
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
341 a(self.sfile)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
342 # if multiple inputs - positional or need to distinguish them with cl params
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
343 if opts.input_tab:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
344 tests = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
345 for i,intab in enumerate(opts.input_tab): # if multiple, make tests
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
346 if intab.find(',') <> -1:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
347 (gpath,uname) = intab.split(',')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
348 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
349 gpath = uname = intab
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
350 tests.append(os.path.basename(gpath))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
351 self.test1Inputs = '<param name="input_tab" value="%s" />' % (','.join(tests))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
352 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
353 self.test1Inputs = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
354 # we always pass path,name pairs in using python optparse append
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
355 # but the command line has to be different
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
356 self.infile_paths = ''
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
357 self.infile_names = ''
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
358 if self.opts.input_tab:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
359 self.infile_paths = ','.join([x.split(',')[0].strip() for x in self.opts.input_tab])
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
360 self.infile_names = ','.join([x.split(',')[1].strip() for x in self.opts.input_tab])
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
361 if self.opts.interpreter == 'python':
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
362 # yes, this is how additional parameters are always passed in python - to the TF itself and to
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
363 # scripts to avoid having unknown parameter names (yes, they can be parsed but...) on the command line
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
364 if self.opts.input_tab:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
365 a('--INPATHS "%s"' % (self.infile_paths))
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
366 a('--INNAMES "%s"' % (self.infile_names))
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
367 if self.opts.output_tab:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
368 a('--OUTPATH "%s"' % self.opts.output_tab)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
369 for p in opts.additional_parameters:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
370 p = p.replace('"','')
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
371 psplit = p.split(',')
61381bad936d Uploaded
fubar
parents: 6
diff changeset
372 param = html_unescape(psplit[0])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
373 value = html_unescape(psplit[1])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
374 a('%s="%s"' % (param,value))
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
375 if (self.opts.interpreter == 'Rscript'):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
376 # pass params on command line
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
377 if self.opts.input_tab:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
378 a('INPATHS="%s"' % self.infile_paths)
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
379 a('INNAMES="%s"' % self.infile_names)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
380 if self.opts.output_tab:
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
381 a('OUTPATH="%s"' % self.opts.output_tab)
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
382 for p in opts.additional_parameters:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
383 p = p.replace('"','')
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
384 psplit = p.split(',')
61381bad936d Uploaded
fubar
parents: 6
diff changeset
385 param = html_unescape(psplit[0])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
386 value = html_unescape(psplit[1])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
387 a('%s="%s"' % (param,value))
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
388 if (self.opts.interpreter == 'perl'):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
389 # pass params on command line
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
390 if self.opts.input_tab:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
391 a('%s' % self.infile_paths)
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
392 a('%s' % self.infile_names)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
393 if self.opts.output_tab:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
394 a('%s' % self.opts.output_tab)
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
395 for p in opts.additional_parameters:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
396 p = p.replace('"','')
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
397 psplit = p.split(',')
61381bad936d Uploaded
fubar
parents: 6
diff changeset
398 param = html_unescape(psplit[0])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
399 value = html_unescape(psplit[1])
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
400 if (value.find(' ') <> -1):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
401 a('%s="%s"' % (param,value))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
402 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
403 a('%s=%s' % (param,value))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
404 if self.opts.interpreter == 'sh' or self.opts.interpreter == 'bash':
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
405 # more is better - now move all params into environment AND drop on to command line.
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
406 self.cl.insert(0,'env')
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
407 if self.opts.input_tab:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
408 self.cl.insert(1,'INPATHS=%s' % (self.infile_paths))
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
409 self.cl.insert(2,'INNAMES=%s' % (self.infile_names))
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
410 if self.opts.output_tab:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
411 self.cl.insert(3,'OUTPATH=%s' % (self.opts.output_tab))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
412 a('OUTPATH=%s' % (self.opts.output_tab))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
413 # sets those environment variables for the script
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
414 # additional params appear in CL - yes, it's confusing
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
415 for i,p in enumerate(opts.additional_parameters):
61381bad936d Uploaded
fubar
parents: 6
diff changeset
416 psplit = p.split(',')
61381bad936d Uploaded
fubar
parents: 6
diff changeset
417 param = html_unescape(psplit[0])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
418 value = html_unescape(psplit[1])
61381bad936d Uploaded
fubar
parents: 6
diff changeset
419 if (value.find(' ') <> -1):
61381bad936d Uploaded
fubar
parents: 6
diff changeset
420 a('%s="%s"' % (param,value))
61381bad936d Uploaded
fubar
parents: 6
diff changeset
421 self.cl.insert(4+i,'%s="%s"' % (param,value))
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
422 else:
7
61381bad936d Uploaded
fubar
parents: 6
diff changeset
423 a('%s=%s' % (param,value))
61381bad936d Uploaded
fubar
parents: 6
diff changeset
424 self.cl.insert(4+i,'%s=%s' % (param,value))
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
425 self.interp_owner = None
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
426 self.interp_pack = None
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
427 self.interp_revision = None
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
428 self.interp_version = None
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
429 if opts.envshpath <> 'system': # need to parse out details for our tool_dependency
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
430 try:
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
431 packdetails = opts.envshpath.split(os.path.sep)[-4:-1] # eg ['fubar', 'package_r_3_1_1', '63cdb9b2234c']
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
432 self.interpreter_owner = packdetails[0]
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
433 self.interpreter_pack = packdetails[1]
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
434 self.interpreter_revision = packdetails[2]
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
435 self.interpreter_version = '.'.join(self.interpreter_pack.split('_')[2:])
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
436 # hope our naming convention as at jan 2015 = package_[interp]_v0_v1_v2... = version v0.v1.v2.. is in play
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
437 except:
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
438 pass
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
439 self.outFormats = opts.output_format
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
440 self.inputFormats = opts.input_formats
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
441 self.test1Output = '%s_test1_output.xls' % self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
442 self.test1HTML = '%s_test1_output.html' % self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
443
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
444 def makeXML(self):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
445 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
446 Create a Galaxy xml tool wrapper for the new script as a string to write out
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
447 fixme - use templating or something less fugly than this example of what we produce
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
448
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
449 <tool id="reverse" name="reverse" version="0.01">
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
450 <description>a tabular file</description>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
451 <command interpreter="python">
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
452 reverse.py --script_path "$runMe" --interpreter "python"
3
d75fd880fce2 Uploaded
fubar
parents: 2
diff changeset
453 --tool_name "reverse" --input_tab "$input1" --output_tab "$output1"
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
454 </command>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
455 <inputs>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
456 <param name="input1" type="data" format="tabular" label="Select one or more input files from your history"/>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
457 <param name="job_name" type="text" label="Supply a name for the outputs to remind you what they contain" value="reverse"/>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
458 </inputs>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
459 <outputs>
3
d75fd880fce2 Uploaded
fubar
parents: 2
diff changeset
460 <data format="tabular" name="output1q" label="${job_name}"/>
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
461
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
462 </outputs>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
463 <help>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
464
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
465 **What it Does**
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
466
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
467 Reverse the columns in a tabular file
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
468
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
469 </help>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
470 <configfiles>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
471 <configfile name="runMe">
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
472
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
473 # reverse order of columns in a tabular file
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
474 import sys
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
475 inp = sys.argv[1]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
476 outp = sys.argv[2]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
477 i = open(inp,'r')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
478 o = open(outp,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
479 for row in i:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
480 rs = row.rstrip().split('\t')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
481 rs.reverse()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
482 o.write('\t'.join(rs))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
483 o.write('\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
484 i.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
485 o.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
486
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
487
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
488 </configfile>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
489 </configfiles>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
490 </tool>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
491
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
492 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
493
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
494 # these templates need a dict with the right keys to match the parameters - outputs, help, code...
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
495
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
496 xdict = {}
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
497 xdict['additionalParams'] = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
498 xdict['additionalInputs'] = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
499 if self.opts.additional_parameters:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
500 if self.opts.edit_additional_parameters: # add to new tool form with default value set to original value
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
501 xdict['additionalInputs'] = '\n'.join(['<param name="%s" value="%s" label="%s" help="%s" type="%s"/>' % \
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
502 (x.split(',')[0],html_escape(x.split(',')[1]),html_escape(x.split(',')[2]),html_escape(x.split(',')[3]), x.split(',')[4]) for x in self.opts.additional_parameters])
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
503 xdict['additionalParams'] = '\n'.join(['<param name="%s" value="%s" />' % (x.split(',')[0],html_escape(x.split(',')[1])) for x in self.opts.additional_parameters])
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
504 xdict['interpreter_owner'] = self.interpreter_owner
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
505 xdict['interpreter_version'] = self.interpreter_version
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
506 xdict['interpreter_name'] = self.interpreter_pack
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
507 xdict['requirements'] = ''
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
508 if self.opts.include_dependencies == "yes":
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
509 if self.opts.envshpath <> 'system':
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
510 xdict['requirements'] = self.protorequirements_interpreter % xdict
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
511 else:
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
512 xdict['requirements'] = self.protorequirements
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
513 xdict['tool_version'] = self.opts.tool_version
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
514 xdict['test1HTML'] = self.test1HTML
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
515 xdict['test1Output'] = self.test1Output
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
516 xdict['test1Inputs'] = self.test1Inputs
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
517 if self.opts.make_HTML and self.opts.output_tab:
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
518 xdict['tooltests'] = self.tooltestsBoth % xdict
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
519 elif self.opts.make_HTML:
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
520 xdict['tooltests'] = self.tooltestsHTMLOnly % xdict
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
521 else:
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
522 xdict['tooltests'] = self.tooltestsTabOnly % xdict
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
523 xdict['script'] = self.escapedScript
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
524 # configfile is least painful way to embed script to avoid external dependencies
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
525 # but requires escaping of <, > and $ to avoid Mako parsing
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
526 if self.opts.help_text:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
527 helptext = open(self.opts.help_text,'r').readlines()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
528 helptext = [html_escape(x) for x in helptext] # must html escape here too - thanks to Marius van den Beek
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
529 xdict['help'] = ''.join([x for x in helptext])
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
530 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
531 xdict['help'] = 'Please ask the tool author (%s) for help as none was supplied at tool generation\n' % (self.opts.user_email)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
532 coda = ['**Script**','Pressing execute will run the following code over your input file and generate some outputs in your history::']
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
533 coda.append('\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
534 coda.append(self.indentedScript)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
535 coda.append('\n**Attribution**\nThis Galaxy tool was created by %s at %s\nusing the Galaxy Tool Factory.\n' % (self.opts.user_email,timenow()))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
536 coda.append('See %s for details of that project' % (toolFactoryURL))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
537 coda.append('Please cite: Creating re-usable tools from scripts: The Galaxy Tool Factory. Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team. ')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
538 coda.append('Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
539 xdict['help'] = '%s\n%s' % (xdict['help'],'\n'.join(coda))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
540 if self.opts.tool_desc:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
541 xdict['tooldesc'] = '<description>%s</description>' % self.opts.tool_desc
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
542 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
543 xdict['tooldesc'] = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
544 xdict['command_outputs'] = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
545 xdict['outputs'] = ''
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
546 if self.opts.input_tab:
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
547 cins = ['\n',]
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
548 cins.append('--input_formats %s' % self.opts.input_formats)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
549 cins.append('#for intab in $input1:')
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
550 cins.append('--input_tab "${intab},${intab.name}"')
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
551 cins.append('#end for\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
552 xdict['command_inputs'] = '\n'.join(cins)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
553 xdict['inputs'] = '''<param name="input_tab" multiple="true" type="data" format="%s" label="Select one or more %s input files from your history"
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
554 help="Multiple inputs may be selected assuming the script can deal with them..."/> \n''' % (self.inputFormats,self.inputFormats)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
555 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
556 xdict['command_inputs'] = '' # assume no input - eg a random data generator
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
557 xdict['inputs'] = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
558 if (len(self.opts.additional_parameters) > 0):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
559 cins = ['\n',]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
560 for params in self.opts.additional_parameters:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
561 psplit = params.split(',') # name,value...
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
562 psplit[3] = html_escape(psplit[3])
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
563 if self.opts.edit_additional_parameters:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
564 psplit[1] = '$%s' % psplit[0] # replace with form value
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
565 else:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
566 psplit[1] = html_escape(psplit[1]) # leave prespecified value
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
567 cins.append('--additional_parameters """%s"""' % ','.join(psplit))
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
568 xdict['command_inputs'] = '%s\n%s' % (xdict['command_inputs'],'\n'.join(cins))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
569 xdict['inputs'] += '<param name="job_name" type="text" size="60" label="Supply a name for the outputs to remind you what they contain" value="%s"/> \n' % self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
570 xdict['toolname'] = self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
571 xdict['toolid'] = self.toolid
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
572 xdict['interpreter'] = self.opts.interpreter
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
573 xdict['scriptname'] = self.sfile
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
574 if self.opts.make_HTML:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
575 xdict['command_outputs'] += ' --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes"'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
576 xdict['outputs'] += ' <data format="html" name="html_file" label="${job_name}.html"/>\n'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
577 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
578 xdict['command_outputs'] += ' --output_dir "./"'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
579 if self.opts.output_tab:
3
d75fd880fce2 Uploaded
fubar
parents: 2
diff changeset
580 xdict['command_outputs'] += ' --output_tab "$output1"'
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
581 xdict['outputs'] += ' <data format="%s" name="output1" label="${job_name}"/>\n' % self.outFormats
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
582 xdict['command'] = self.newCommand % xdict
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
583 if self.opts.citations:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
584 citationstext = open(self.opts.citations,'r').read()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
585 citation_tuples = parse_citations(citationstext)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
586 citations_xml = ""
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
587 for citation_type, citation_content in citation_tuples:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
588 citation_xml = """<citation type="%s">%s</citation>""" % (citation_type, html_escape(citation_content))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
589 citations_xml += citation_xml
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
590 xdict['citations'] = citations_xml
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
591 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
592 xdict['citations'] = ""
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
593 xmls = self.newXML % xdict
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
594 xf = open(self.xmlfile,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
595 xf.write(xmls)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
596 xf.write('\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
597 xf.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
598 # ready for the tarball
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
599
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
600
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
601 def makeTooltar(self):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
602 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
603 a tool is a gz tarball with eg
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
604 /toolname/tool.xml /toolname/tool.py /toolname/test-data/test1_in.foo ...
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
605 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
606 retval = self.run()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
607 if retval:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
608 print >> sys.stderr,'## Run failed. Cannot build yet. Please fix and retry'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
609 sys.exit(1)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
610 tdir = self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
611 os.mkdir(tdir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
612 self.makeXML()
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
613 if self.opts.help_text:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
614 hlp = open(self.opts.help_text,'r').read()
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
615 else:
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
616 hlp = 'Please ask the tool author for help as none was supplied at tool generation\n'
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
617 readme_dict = {'readme':hlp,'interpreter':self.opts.interpreter,'interpreter_version':self.interpreter_version,'interpreter_name':self.interpreter_pack,
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
618 'interpreter_owner':self.interpreter_owner}
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
619 if self.opts.include_dependencies == "yes":
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
620 if self.opts.envshpath == 'system':
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
621 tooldepcontent = self.toolhtmldepskel % readme_dict
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
622 else:
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
623 tooldepcontent = self.toolhtmldepinterpskel % readme_dict
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
624 else:
10
8de2b7571d98 Uploaded
fubar
parents: 9
diff changeset
625 tooldepcontent = self.emptytoolhtmldepskel % readme_dictls -l
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
626 depf = open(os.path.join(tdir,'tool_dependencies.xml'),'w')
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
627 depf.write(tooldepcontent)
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
628 depf.write('\n')
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
629 depf.close()
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
630 if self.opts.input_tab: # no reproducible test otherwise? TODO: maybe..
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
631 testdir = os.path.join(tdir,'test-data')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
632 os.mkdir(testdir) # make tests directory
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
633 for i,intab in enumerate(self.opts.input_tab):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
634 si = self.opts.input_tab[i]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
635 if si.find(',') <> -1:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
636 s = si.split(',')[0]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
637 si = s
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
638 dest = os.path.join(testdir,os.path.basename(si))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
639 if si <> dest:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
640 shutil.copyfile(si,dest)
2
6a3c292412fa Uploaded
fubar
parents: 0
diff changeset
641 if self.opts.output_tab:
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
642 shutil.copyfile(self.opts.output_tab,os.path.join(testdir,self.test1Output))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
643 if self.opts.make_HTML:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
644 shutil.copyfile(self.opts.output_html,os.path.join(testdir,self.test1HTML))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
645 if self.opts.output_dir:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
646 shutil.copyfile(self.tlog,os.path.join(testdir,'test1_out.log'))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
647 outpif = '%s.py' % self.toolname # new name
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
648 outpiname = os.path.join(tdir,outpif) # path for the tool tarball
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
649 pyin = os.path.basename(self.pyfile) # our name - we rewrite ourselves (TM)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
650 notes = ['# %s - a self annotated version of %s generated by running %s\n' % (outpiname,pyin,pyin),]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
651 notes.append('# to make a new Galaxy tool called %s\n' % self.toolname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
652 notes.append('# User %s at %s\n' % (self.opts.user_email,timenow()))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
653 pi = open(self.pyfile,'r').readlines() # our code becomes new tool wrapper (!) - first Galaxy worm
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
654 notes += pi
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
655 outpi = open(outpiname,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
656 outpi.write(''.join(notes))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
657 outpi.write('\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
658 outpi.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
659 stname = os.path.join(tdir,self.sfile)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
660 if not os.path.exists(stname):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
661 shutil.copyfile(self.sfile, stname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
662 xtname = os.path.join(tdir,self.xmlfile)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
663 if not os.path.exists(xtname):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
664 shutil.copyfile(self.xmlfile,xtname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
665 tarpath = "%s.tar.gz" % self.toolname
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
666 tar = tarfile.open(tarpath, "w:gz")
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
667 tar.add(tdir,arcname='%s' % self.toolname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
668 tar.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
669 shutil.copyfile(tarpath,self.opts.new_tool)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
670 shutil.rmtree(tdir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
671 ## TODO: replace with optional direct upload to local toolshed?
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
672 return retval
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
673
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
674
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
675 def compressPDF(self,inpdf=None,thumbformat='png'):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
676 """need absolute path to pdf
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
677 note that GS gets confoozled if no $TMP or $TEMP
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
678 so we set it
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
679 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
680 assert os.path.isfile(inpdf), "## Input %s supplied to %s compressPDF not found" % (inpdf,self.myName)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
681 hlog = os.path.join(self.opts.output_dir,"compress_%s.txt" % os.path.basename(inpdf))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
682 sto = open(hlog,'a')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
683 our_env = os.environ.copy()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
684 our_tmp = our_env.get('TMP',None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
685 if not our_tmp:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
686 our_tmp = our_env.get('TEMP',None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
687 if not (our_tmp and os.path.exists(our_tmp)):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
688 newtmp = os.path.join(self.opts.output_dir,'tmp')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
689 try:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
690 os.mkdir(newtmp)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
691 except:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
692 sto.write('## WARNING - cannot make %s - it may exist or permissions need fixing\n' % newtmp)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
693 our_env['TEMP'] = newtmp
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
694 if not self.temp_warned:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
695 sto.write('## WARNING - no $TMP or $TEMP!!! Please fix - using %s temporarily\n' % newtmp)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
696 self.temp_warned = True
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
697 outpdf = '%s_compressed' % inpdf
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
698 cl = ["gs", "-sDEVICE=pdfwrite", "-dNOPAUSE", "-dUseCIEColor", "-dBATCH","-dPDFSETTINGS=/printer", "-sOutputFile=%s" % outpdf,inpdf]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
699 x = subprocess.Popen(cl,stdout=sto,stderr=sto,cwd=self.opts.output_dir,env=our_env)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
700 retval1 = x.wait()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
701 sto.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
702 if retval1 == 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
703 os.unlink(inpdf)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
704 shutil.move(outpdf,inpdf)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
705 os.unlink(hlog)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
706 hlog = os.path.join(self.opts.output_dir,"thumbnail_%s.txt" % os.path.basename(inpdf))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
707 sto = open(hlog,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
708 outpng = '%s.%s' % (os.path.splitext(inpdf)[0],thumbformat)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
709 if self.useGM:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
710 cl2 = ['gm', 'convert', inpdf, outpng]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
711 else: # assume imagemagick
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
712 cl2 = ['convert', inpdf, outpng]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
713 x = subprocess.Popen(cl2,stdout=sto,stderr=sto,cwd=self.opts.output_dir,env=our_env)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
714 retval2 = x.wait()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
715 sto.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
716 if retval2 == 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
717 os.unlink(hlog)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
718 retval = retval1 or retval2
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
719 return retval
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
720
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
721
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
722 def getfSize(self,fpath,outpath):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
723 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
724 format a nice file size string
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
725 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
726 size = ''
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
727 fp = os.path.join(outpath,fpath)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
728 if os.path.isfile(fp):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
729 size = '0 B'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
730 n = float(os.path.getsize(fp))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
731 if n > 2**20:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
732 size = '%1.1f MB' % (n/2**20)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
733 elif n > 2**10:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
734 size = '%1.1f KB' % (n/2**10)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
735 elif n > 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
736 size = '%d B' % (int(n))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
737 return size
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
738
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
739 def makeHtml(self):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
740 """ Create an HTML file content to list all the artifacts found in the output_dir
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
741 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
742
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
743 galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
744 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
745 <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
746 <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" />
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
747 <title></title>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
748 <link rel="stylesheet" href="/static/style/base.css" type="text/css" />
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
749 </head>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
750 <body>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
751 <div class="toolFormBody">
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
752 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
753 galhtmlattr = """<hr/><div class="infomessage">This tool (%s) was generated by the <a href="https://bitbucket.org/fubar/galaxytoolfactory/overview">Galaxy Tool Factory</a></div><br/>"""
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
754 galhtmlpostfix = """</div></body></html>\n"""
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
755
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
756 flist = os.listdir(self.opts.output_dir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
757 flist = [x for x in flist if x <> 'Rplots.pdf']
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
758 flist.sort()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
759 html = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
760 html.append(galhtmlprefix % progname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
761 html.append('<div class="infomessage">Galaxy Tool "%s" run at %s</div><br/>' % (self.toolname,timenow()))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
762 fhtml = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
763 if len(flist) > 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
764 logfiles = [x for x in flist if x.lower().endswith('.log')] # log file names determine sections
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
765 logfiles.sort()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
766 logfiles = [x for x in logfiles if os.path.abspath(x) <> os.path.abspath(self.tlog)]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
767 logfiles.append(os.path.abspath(self.tlog)) # make it the last one
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
768 pdflist = []
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
769 npdf = len([x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf'])
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
770 for rownum,fname in enumerate(flist):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
771 dname,e = os.path.splitext(fname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
772 sfsize = self.getfSize(fname,self.opts.output_dir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
773 if e.lower() == '.pdf' : # compress and make a thumbnail
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
774 thumb = '%s.%s' % (dname,self.thumbformat)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
775 pdff = os.path.join(self.opts.output_dir,fname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
776 retval = self.compressPDF(inpdf=pdff,thumbformat=self.thumbformat)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
777 if retval == 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
778 pdflist.append((fname,thumb))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
779 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
780 pdflist.append((fname,fname))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
781 if (rownum+1) % 2 == 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
782 fhtml.append('<tr class="odd_row"><td><a href="%s">%s</a></td><td>%s</td></tr>' % (fname,fname,sfsize))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
783 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
784 fhtml.append('<tr><td><a href="%s">%s</a></td><td>%s</td></tr>' % (fname,fname,sfsize))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
785 for logfname in logfiles: # expect at least tlog - if more
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
786 if os.path.abspath(logfname) == os.path.abspath(self.tlog): # handled later
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
787 sectionname = 'All tool run'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
788 if (len(logfiles) > 1):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
789 sectionname = 'Other'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
790 ourpdfs = pdflist
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
791 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
792 realname = os.path.basename(logfname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
793 sectionname = os.path.splitext(realname)[0].split('_')[0] # break in case _ added to log
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
794 ourpdfs = [x for x in pdflist if os.path.basename(x[0]).split('_')[0] == sectionname]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
795 pdflist = [x for x in pdflist if os.path.basename(x[0]).split('_')[0] <> sectionname] # remove
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
796 nacross = 1
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
797 npdf = len(ourpdfs)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
798
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
799 if npdf > 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
800 nacross = math.sqrt(npdf) ## int(round(math.log(npdf,2)))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
801 if int(nacross)**2 != npdf:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
802 nacross += 1
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
803 nacross = int(nacross)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
804 width = min(400,int(1200/nacross))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
805 html.append('<div class="toolFormTitle">%s images and outputs</div>' % sectionname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
806 html.append('(Click on a thumbnail image to download the corresponding original PDF image)<br/>')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
807 ntogo = nacross # counter for table row padding with empty cells
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
808 html.append('<div><table class="simple" cellpadding="2" cellspacing="2">\n<tr>')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
809 for i,paths in enumerate(ourpdfs):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
810 fname,thumb = paths
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
811 s= """<td><a href="%s"><img src="%s" title="Click to download a PDF of %s" hspace="5" width="%d"
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
812 alt="Image called %s"/></a></td>\n""" % (fname,thumb,fname,width,fname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
813 if ((i+1) % nacross == 0):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
814 s += '</tr>\n'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
815 ntogo = 0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
816 if i < (npdf - 1): # more to come
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
817 s += '<tr>'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
818 ntogo = nacross
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
819 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
820 ntogo -= 1
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
821 html.append(s)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
822 if html[-1].strip().endswith('</tr>'):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
823 html.append('</table></div>\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
824 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
825 if ntogo > 0: # pad
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
826 html.append('<td>&nbsp;</td>'*ntogo)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
827 html.append('</tr></table></div>\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
828 logt = open(logfname,'r').readlines()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
829 logtext = [x for x in logt if x.strip() > '']
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
830 html.append('<div class="toolFormTitle">%s log output</div>' % sectionname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
831 if len(logtext) > 1:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
832 html.append('\n<pre>\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
833 html += logtext
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
834 html.append('\n</pre>\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
835 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
836 html.append('%s is empty<br/>' % logfname)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
837 if len(fhtml) > 0:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
838 fhtml.insert(0,'<div><table class="colored" cellpadding="3" cellspacing="3"><tr><th>Output File Name (click to view)</th><th>Size</th></tr>\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
839 fhtml.append('</table></div><br/>')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
840 html.append('<div class="toolFormTitle">All output files available for downloading</div>\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
841 html += fhtml # add all non-pdf files to the end of the display
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
842 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
843 html.append('<div class="warningmessagelarge">### Error - %s returned no files - please confirm that parameters are sane</div>' % self.opts.interpreter)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
844 html.append(galhtmlpostfix)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
845 htmlf = file(self.opts.output_html,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
846 htmlf.write('\n'.join(html))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
847 htmlf.write('\n')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
848 htmlf.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
849 self.html = html
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
850
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
851
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
852
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
853 def run(self):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
854 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
855 scripts must be small enough not to fill the pipe!
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
856 """
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
857 if self.opts.envshpath <> 'system':
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
858 shell_source(self.opts.envshpath)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
859 if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
860 retval = self.runBash()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
861 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
862 if self.opts.output_dir:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
863 ste = open(self.elog,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
864 sto = open(self.tlog,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
865 sto.write('## Toolfactory generated command line = %s\n' % ' '.join(self.cl))
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
866 sto.flush()
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
867 p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=ste,cwd=self.opts.output_dir)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
868 else:
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
869 p = subprocess.Popen(self.cl,shell=False)
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
870 retval = p.wait()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
871 if self.opts.output_dir:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
872 sto.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
873 ste.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
874 err = open(self.elog,'r').readlines()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
875 if retval <> 0 and err: # problem
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
876 print >> sys.stderr,err
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
877 if self.opts.make_HTML:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
878 self.makeHtml()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
879 return retval
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
880
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
881 def runBash(self):
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
882 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
883 cannot use - for bash so use self.sfile
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
884 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
885 if self.opts.output_dir:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
886 s = '## Toolfactory generated command line = %s\n' % ' '.join(self.cl)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
887 sto = open(self.tlog,'w')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
888 sto.write(s)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
889 sto.flush()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
890 p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=sto,cwd=self.opts.output_dir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
891 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
892 p = subprocess.Popen(self.cl,shell=False)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
893 retval = p.wait()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
894 if self.opts.output_dir:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
895 sto.close()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
896 if self.opts.make_HTML:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
897 self.makeHtml()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
898 return retval
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
899
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
900
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
901 def main():
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
902 u = """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
903 This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
904 <command interpreter="python">rgBaseScriptWrapper.py --script_path "$scriptPath" --tool_name "foo" --interpreter "Rscript"
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
905 </command>
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
906 """
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
907 op = optparse.OptionParser()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
908 a = op.add_option
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
909 a('--script_path',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
910 a('--tool_name',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
911 a('--interpreter',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
912 a('--output_dir',default='./')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
913 a('--output_html',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
914 a('--input_tab',default=[], action="append") # these are "galaxypath,metadataname" pairs
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
915 a("--input_formats",default="tabular")
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
916 a('--output_tab',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
917 a('--output_format',default='tabular')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
918 a('--user_email',default='Unknown')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
919 a('--bad_user',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
920 a('--make_Tool',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
921 a('--make_HTML',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
922 a('--help_text',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
923 a('--tool_desc',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
924 a('--new_tool',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
925 a('--tool_version',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
926 a('--include_dependencies',default="yes")
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
927 a('--citations',default=None)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
928 a('--additional_parameters', dest='additional_parameters', action='append', default=[])
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
929 a('--edit_additional_parameters', action="store_true", default=False)
9
ce5ec1d989fd Uploaded
fubar
parents: 8
diff changeset
930 a('--envshpath',default="system")
0
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
931 opts, args = op.parse_args()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
932 assert not opts.bad_user,'UNAUTHORISED: %s is NOT authorized to use this tool until Galaxy admin adds %s to admin_users in universe_wsgi.ini' % (opts.bad_user,opts.bad_user)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
933 assert opts.tool_name,'## Tool Factory expects a tool name - eg --tool_name=DESeq'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
934 assert opts.interpreter,'## Tool Factory wrapper expects an interpreter - eg --interpreter=Rscript'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
935 assert os.path.isfile(opts.script_path),'## Tool Factory wrapper expects a script path - eg --script_path=foo.R'
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
936 if opts.output_dir:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
937 try:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
938 os.makedirs(opts.output_dir)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
939 except:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
940 pass
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
941 opts.input_tab = [x.replace('"','').replace("'",'') for x in opts.input_tab]
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
942 for i,x in enumerate(opts.additional_parameters): # remove quotes we need to deal with spaces in CL params
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
943 opts.additional_parameters[i] = opts.additional_parameters[i].replace('"','')
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
944 r = ScriptRunner(opts)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
945 if opts.make_Tool:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
946 retcode = r.makeTooltar()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
947 else:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
948 retcode = r.run()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
949 os.unlink(r.sfile)
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
950 if retcode:
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
951 sys.exit(retcode) # indicate failure to job runner
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
952
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
953
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
954 if __name__ == "__main__":
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
955 main()
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
956
c34063ab3735 Initial commit of code in iuc github repository
fubar
parents:
diff changeset
957