Mercurial > repos > fubar > toolfactory
annotate fubar-galaxytoolfactory-58871556de57/rgToolFactory.py @ 6:cb4937b0c21d draft
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
author | fubar |
---|---|
date | Sun, 24 Feb 2013 17:15:29 -0500 |
parents | |
children |
rev | line source |
---|---|
6
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
1 # rgToolFactory.py |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
2 # see https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
3 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
4 # copyright ross lazarus (ross stop lazarus at gmail stop com) May 2012 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
5 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
6 # all rights reserved |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
7 # Licensed under the LGPL |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
8 # suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
9 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
10 # January 2013 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
11 # problem pointed out by Carlos Borroto |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
12 # added escaping for <>$ - thought I did that ages ago... |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
13 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
14 # August 11 2012 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
15 # changed to use shell=False and cl as a sequence |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
16 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
17 # This is a Galaxy tool factory for simple scripts in python, R or whatever ails ye. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
18 # It also serves as the wrapper for the new tool. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
19 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
20 # you paste and run your script |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
21 # Only works for simple scripts that read one input from the history. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
22 # Optionally can write one new history dataset, |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
23 # and optionally collect any number of outputs into links on an autogenerated HTML page. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
24 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
25 # DO NOT install on a public or important site - please. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
26 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
27 # installed generated tools are fine if the script is safe. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
28 # They just run normally and their user cannot do anything unusually insecure |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
29 # but please, practice safe toolshed. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
30 # Read the fucking code before you install any tool |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
31 # especially this one |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
32 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
33 # After you get the script working on some test data, you can |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
34 # optionally generate a toolshed compatible gzip file |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
35 # containing your script safely wrapped as an ordinary Galaxy script in your local toolshed for |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
36 # safe and largely automated installation in a production Galaxy. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
37 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
38 # If you opt for an HTML output, you get all the script outputs arranged |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
39 # as a single Html history item - all output files are linked, thumbnails for all the pdfs. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
40 # Ugly but really inexpensive. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
41 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
42 # Patches appreciated please. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
43 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
44 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
45 # long route to June 2012 product |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
46 # Behold the awesome power of Galaxy and the toolshed with the tool factory to bind them |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
47 # derived from an integrated script model |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
48 # called rgBaseScriptWrapper.py |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
49 # Note to the unwary: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
50 # This tool allows arbitrary scripting on your Galaxy as the Galaxy user |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
51 # There is nothing stopping a malicious user doing whatever they choose |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
52 # Extremely dangerous!! |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
53 # Totally insecure. So, trusted users only |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
54 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
55 # preferred model is a developer using their throw away workstation instance - ie a private site. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
56 # no real risk. The universe_wsgi.ini admin_users string is checked - only admin users are permitted to run this tool. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
57 # |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
58 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
59 import sys |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
60 import shutil |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
61 import subprocess |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
62 import os |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
63 import time |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
64 import tempfile |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
65 import optparse |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
66 import tarfile |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
67 import re |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
68 import shutil |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
69 import math |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
70 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
71 progname = os.path.split(sys.argv[0])[1] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
72 myversion = 'V000.2 June 2012' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
73 verbose = False |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
74 debug = False |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
75 toolFactoryURL = 'https://bitbucket.org/fubar/galaxytoolfactory' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
76 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
77 def timenow(): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
78 """return current time as a string |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
79 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
80 return time.strftime('%d/%m/%Y %H:%M:%S', time.localtime(time.time())) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
81 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
82 cheetah_escape_table = { |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
83 "$": "\$" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
84 } |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
85 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
86 cheetah_unescape_table = { |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
87 "\$": "$" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
88 } |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
89 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
90 def html_escape(t): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
91 """Unescape \$ first in case already done |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
92 cheetah barfs if any $ without \ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
93 xml parsing is controlled with <![CDATA[...]]> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
94 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
95 text = t |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
96 for k in cheetah_unescape_table.keys(): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
97 text = text.replace(k,cheetah_unescape_table[k]) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
98 for k in cheetah_escape_table.keys(): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
99 text = text.replace(k,cheetah_escape_table[k]) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
100 return text |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
101 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
102 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
103 class ScriptRunner: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
104 """class is a wrapper for an arbitrary script |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
105 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
106 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
107 def __init__(self,opts=None,treatbashSpecial=True): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
108 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
109 cleanup inputs, setup some outputs |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
110 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
111 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
112 self.treatbashSpecial = treatbashSpecial |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
113 if opts.output_dir: # simplify for the tool tarball |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
114 os.chdir(opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
115 self.thumbformat = 'jpg' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
116 self.opts = opts |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
117 self.toolname = re.sub('[^a-zA-Z0-9_]+', '', opts.tool_name) # a sanitizer now does this but.. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
118 self.toolid = self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
119 self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
120 self.pyfile = self.myname # crude but efficient - the cruft won't hurt much |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
121 self.xmlfile = '%s.xml' % self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
122 s = open(self.opts.script_path,'r').readlines() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
123 s = [x.rstrip() for x in s] # remove pesky dos line endings if needed |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
124 self.script = '\n'.join(s) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
125 fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
126 tscript = open(self.sfile,'w') # use self.sfile as script source for Popen |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
127 tscript.write(self.script) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
128 tscript.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
129 self.escapedS = [html_escape(x) for x in s] # for restructured text in help |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
130 self.escapedScript = '\n'.join(self.escapedS) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
131 self.indentedScript = '\n'.join([' %s' % x for x in s]) # for restructured text in help |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
132 if opts.output_dir: # may not want these complexities |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
133 self.tlog = os.path.join(opts.output_dir,"%s_runner.log" % self.toolname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
134 art = '%s.%s' % (self.toolname,opts.interpreter) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
135 artpath = os.path.join(self.opts.output_dir,art) # need full path |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
136 artifact = open(artpath,'w') # use self.sfile as script source for Popen |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
137 artifact.write(self.script) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
138 artifact.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
139 self.cl = [] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
140 self.html = [] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
141 a = self.cl.append |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
142 a(opts.interpreter) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
143 if self.treatbashSpecial and opts.interpreter in ['bash','sh']: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
144 a(self.sfile) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
145 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
146 a('-') # stdin |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
147 a(opts.input_tab) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
148 a(opts.output_tab) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
149 self.outFormats = 'tabular' # TODO make this an option at tool generation time |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
150 self.inputFormats = 'tabular' # TODO make this an option at tool generation time |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
151 self.test1Input = '%s_test1_input.xls' % self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
152 self.test1Output = '%s_test1_output.xls' % self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
153 self.test1HTML = '%s_test1_output.html' % self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
154 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
155 def makeXML(self): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
156 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
157 Create a Galaxy xml tool wrapper for the new script as a string to write out |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
158 fixme - use templating or something less fugly than this example of what we produce |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
159 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
160 <tool id="reverse" name="reverse" version="0.01"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
161 <description>a tabular file</description> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
162 <command interpreter="python"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
163 reverse.py --script_path "$runMe" --interpreter "python" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
164 --tool_name "reverse" --input_tab "$input1" --output_tab "$tab_file" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
165 </command> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
166 <inputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
167 <param name="input1" type="data" format="tabular" label="Select a suitable input file from your history"/><param name="job_name" type="text" label="Supply a name for the outputs to remind you what they contain" value="reverse"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
168 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
169 </inputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
170 <outputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
171 <data format="tabular" name="tab_file" label="${job_name}"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
172 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
173 </outputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
174 <help> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
175 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
176 **What it Does** |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
177 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
178 Reverse the columns in a tabular file |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
179 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
180 </help> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
181 <configfiles> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
182 <configfile name="runMe"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
183 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
184 # reverse order of columns in a tabular file |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
185 import sys |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
186 inp = sys.argv[1] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
187 outp = sys.argv[2] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
188 i = open(inp,'r') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
189 o = open(outp,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
190 for row in i: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
191 rs = row.rstrip().split('\t') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
192 rs.reverse() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
193 o.write('\t'.join(rs)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
194 o.write('\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
195 i.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
196 o.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
197 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
198 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
199 </configfile> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
200 </configfiles> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
201 </tool> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
202 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
203 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
204 newXML="""<tool id="%(toolid)s" name="%(toolname)s" version="%(tool_version)s"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
205 %(tooldesc)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
206 %(command)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
207 <inputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
208 %(inputs)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
209 </inputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
210 <outputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
211 %(outputs)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
212 </outputs> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
213 <configfiles> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
214 <configfile name="runMe"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
215 <![CDATA[ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
216 %(script)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
217 ]]> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
218 </configfile> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
219 </configfiles> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
220 %(tooltests)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
221 <help> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
222 <![CDATA[ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
223 %(help)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
224 ]]> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
225 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
226 </help> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
227 </tool>""" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
228 # needs a dict with toolname, toolid, interpreter, scriptname, command, inputs as a multi line string ready to write, outputs ditto, help ditto |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
229 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
230 newCommand="""<command interpreter="python"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
231 %(toolname)s.py --script_path "$runMe" --interpreter "%(interpreter)s" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
232 --tool_name "%(toolname)s" %(command_inputs)s %(command_outputs)s |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
233 </command>""" # may NOT be an input or htmlout |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
234 tooltestsTabOnly = """<tests><test> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
235 <param name="input1" value="%(test1Input)s" ftype="tabular"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
236 <param name="job_name" value="test1"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
237 <param name="runMe" value="$runMe"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
238 <output name="tab_file" file="%(test1Output)s" ftype="tabular"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
239 </test></tests>""" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
240 tooltestsHTMLOnly = """<tests><test> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
241 <param name="input1" value="%(test1Input)s" ftype="tabular"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
242 <param name="job_name" value="test1"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
243 <param name="runMe" value="$runMe"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
244 <output name="html_file" file="%(test1HTML)s" ftype="html" lines_diff="5"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
245 </test></tests>""" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
246 tooltestsBoth = """<tests><test> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
247 <param name="input1" value="%(test1Input)s" ftype="tabular"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
248 <param name="job_name" value="test1"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
249 <param name="runMe" value="$runMe"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
250 <output name="tab_file" file="%(test1Output)s" ftype="tabular" /> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
251 <output name="html_file" file="%(test1HTML)s" ftype="html" lines_diff="10"/> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
252 </test></tests>""" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
253 xdict = {} |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
254 xdict['tool_version'] = self.opts.tool_version |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
255 xdict['test1Input'] = self.test1Input |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
256 xdict['test1HTML'] = self.test1HTML |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
257 xdict['test1Output'] = self.test1Output |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
258 if self.opts.make_HTML and self.opts.output_tab <> 'None': |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
259 xdict['tooltests'] = tooltestsBoth % xdict |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
260 elif self.opts.make_HTML: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
261 xdict['tooltests'] = tooltestsHTMLOnly % xdict |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
262 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
263 xdict['tooltests'] = tooltestsTabOnly % xdict |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
264 xdict['script'] = self.escapedScript |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
265 # configfile is least painful way to embed script to avoid external dependencies |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
266 # but requires escaping of <, > and $ to avoid Mako parsing |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
267 if self.opts.help_text: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
268 xdict['help'] = open(self.opts.help_text,'r').read() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
269 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
270 xdict['help'] = 'Please ask the tool author for help as none was supplied at tool generation\n' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
271 coda = ['**Script**','Pressing execute will run the following code over your input file and generate some outputs in your history::\n'] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
272 coda.append(self.indentedScript) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
273 coda.append('\n\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
274 coda.append('**Attribution** This Galaxy tool was created by %s at %s\nusing the Galaxy Tool Factory.' % (self.opts.user_email,timenow())) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
275 coda.append('See %s for details of that project' % (toolFactoryURL)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
276 coda.append('Please cite: Creating re-usable tools from scripts: The Galaxy Tool Factory. Ross Lazarus; Antony Kaspi; Mark Ziemann; The Galaxy Team. ') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
277 coda.append('Bioinformatics 2012; doi: 10.1093/bioinformatics/bts573') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
278 xdict['help'] = '%s\n\n%s\n\n' % (xdict['help'],'\n'.join(coda)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
279 if self.opts.tool_desc: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
280 xdict['tooldesc'] = '<description>%s</description>' % self.opts.tool_desc |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
281 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
282 xdict['tooldesc'] = '' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
283 xdict['command_outputs'] = '' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
284 xdict['outputs'] = '' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
285 if self.opts.input_tab <> 'None': |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
286 xdict['command_inputs'] = '--input_tab "$input1" ' # the space may matter a lot if we append something |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
287 xdict['inputs'] = '<param name="input1" type="data" format="%s" label="Select a suitable input file from your history"/> \n' % self.inputFormats |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
288 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
289 xdict['command_inputs'] = '' # assume no input - eg a random data generator |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
290 xdict['inputs'] = '' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
291 xdict['inputs'] += '<param name="job_name" type="text" label="Supply a name for the outputs to remind you what they contain" value="%s"/> \n' % self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
292 xdict['toolname'] = self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
293 xdict['toolid'] = self.toolid |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
294 xdict['interpreter'] = self.opts.interpreter |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
295 xdict['scriptname'] = self.sfile |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
296 if self.opts.make_HTML: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
297 xdict['command_outputs'] += ' --output_dir "$html_file.files_path" --output_html "$html_file" --make_HTML "yes" ' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
298 xdict['outputs'] += ' <data format="html" name="html_file" label="${job_name}.html"/>\n' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
299 if self.opts.output_tab <> 'None': |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
300 xdict['command_outputs'] += ' --output_tab "$tab_file"' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
301 xdict['outputs'] += ' <data format="%s" name="tab_file" label="${job_name}"/>\n' % self.outFormats |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
302 xdict['command'] = newCommand % xdict |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
303 xmls = newXML % xdict |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
304 xf = open(self.xmlfile,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
305 xf.write(xmls) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
306 xf.write('\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
307 xf.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
308 # ready for the tarball |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
309 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
310 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
311 def makeTooltar(self): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
312 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
313 a tool is a gz tarball with eg |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
314 /toolname/tool.xml /toolname/tool.py /toolname/test-data/test1_in.foo ... |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
315 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
316 retval = self.run() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
317 if retval: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
318 print >> sys.stderr,'## Run failed. Cannot build yet. Please fix and retry' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
319 sys.exit(1) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
320 self.makeXML() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
321 tdir = self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
322 os.mkdir(tdir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
323 if self.opts.input_tab <> 'None': # no reproducible test otherwise? TODO: maybe.. |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
324 testdir = os.path.join(tdir,'test-data') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
325 os.mkdir(testdir) # make tests directory |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
326 shutil.copyfile(self.opts.input_tab,os.path.join(testdir,self.test1Input)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
327 if self.opts.output_tab <> 'None': |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
328 shutil.copyfile(self.opts.output_tab,os.path.join(testdir,self.test1Output)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
329 if self.opts.make_HTML: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
330 shutil.copyfile(self.opts.output_html,os.path.join(testdir,self.test1HTML)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
331 if self.opts.output_dir: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
332 shutil.copyfile(self.tlog,os.path.join(testdir,'test1_out.log')) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
333 op = '%s.py' % self.toolname # new name |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
334 outpiname = os.path.join(tdir,op) # path for the tool tarball |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
335 pyin = os.path.basename(self.pyfile) # our name - we rewrite ourselves (TM) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
336 notes = ['# %s - a self annotated version of %s generated by running %s\n' % (op,pyin,pyin),] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
337 notes.append('# to make a new Galaxy tool called %s\n' % self.toolname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
338 notes.append('# User %s at %s\n' % (self.opts.user_email,timenow())) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
339 pi = open(self.pyfile,'r').readlines() # our code becomes new tool wrapper (!) - first Galaxy worm |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
340 notes += pi |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
341 outpi = open(outpiname,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
342 outpi.write(''.join(notes)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
343 outpi.write('\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
344 outpi.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
345 stname = os.path.join(tdir,self.sfile) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
346 if not os.path.exists(stname): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
347 shutil.copyfile(self.sfile, stname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
348 xtname = os.path.join(tdir,self.xmlfile) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
349 if not os.path.exists(xtname): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
350 shutil.copyfile(self.xmlfile,xtname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
351 tarpath = "%s.gz" % self.toolname |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
352 tar = tarfile.open(tarpath, "w:gz") |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
353 tar.add(tdir,arcname=self.toolname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
354 tar.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
355 shutil.copyfile(tarpath,self.opts.new_tool) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
356 shutil.rmtree(tdir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
357 ## TODO: replace with optional direct upload to local toolshed? |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
358 return retval |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
359 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
360 def compressPDF(self,inpdf=None,thumbformat='png'): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
361 """need absolute path to pdf |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
362 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
363 assert os.path.isfile(inpdf), "## Input %s supplied to %s compressPDF not found" % (inpdf,self.myName) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
364 hf,hlog = tempfile.mkstemp(suffix="%s.log" % self.toolname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
365 sto = open(hlog,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
366 outpdf = '%s_compressed' % inpdf |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
367 cl = ["gs", "-sDEVICE=pdfwrite", "-dNOPAUSE", "-dBATCH", "-sOutputFile=%s" % outpdf,inpdf] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
368 x = subprocess.Popen(cl,stdout=sto,stderr=sto,cwd=self.opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
369 retval1 = x.wait() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
370 if retval1 == 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
371 os.unlink(inpdf) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
372 shutil.move(outpdf,inpdf) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
373 outpng = '%s.%s' % (os.path.splitext(inpdf)[0],thumbformat) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
374 cl2 = ['convert', inpdf, outpng] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
375 x = subprocess.Popen(cl2,stdout=sto,stderr=sto,cwd=self.opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
376 retval2 = x.wait() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
377 sto.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
378 retval = retval1 or retval2 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
379 return retval |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
380 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
381 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
382 def getfSize(self,fpath,outpath): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
383 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
384 format a nice file size string |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
385 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
386 size = '' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
387 fp = os.path.join(outpath,fpath) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
388 if os.path.isfile(fp): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
389 size = '0 B' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
390 n = float(os.path.getsize(fp)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
391 if n > 2**20: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
392 size = '%1.1f MB' % (n/2**20) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
393 elif n > 2**10: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
394 size = '%1.1f KB)' % (n/2**10) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
395 elif n > 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
396 size = '%d B' % (int(n)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
397 return size |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
398 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
399 def makeHtml(self): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
400 """ Create an HTML file content to list all the artifacts found in the output_dir |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
401 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
402 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
403 galhtmlprefix = """<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
404 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
405 <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
406 <meta name="generator" content="Galaxy %s tool output - see http://g2.trac.bx.psu.edu/" /> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
407 <title></title> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
408 <link rel="stylesheet" href="/static/style/base.css" type="text/css" /> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
409 </head> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
410 <body> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
411 <div class="toolFormBody"> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
412 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
413 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/>""" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
414 galhtmlpostfix = """</div></body></html>\n""" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
415 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
416 flist = os.listdir(self.opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
417 flist = [x for x in flist if x <> 'Rplots.pdf'] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
418 flist.sort() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
419 html = [] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
420 html.append(galhtmlprefix % progname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
421 html.append('<div class="infomessage">Galaxy Tool "%s" run at %s</div><br/>' % (self.toolname,timenow())) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
422 fhtml = [] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
423 if len(flist) > 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
424 pdflist = [] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
425 npdf = len([x for x in flist if os.path.splitext(x)[-1].lower() == '.pdf']) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
426 nacross = 1 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
427 if npdf > 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
428 nacross = int(round(math.log(npdf,2))) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
429 nacross = max(1,nacross) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
430 width = min(400,int(1200/nacross)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
431 for rownum,fname in enumerate(flist): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
432 dname,e = os.path.splitext(fname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
433 sfsize = self.getfSize(fname,self.opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
434 if e.lower() == '.pdf' : # compress and make a thumbnail |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
435 thumb = '%s.%s' % (dname,self.thumbformat) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
436 pdff = os.path.join(self.opts.output_dir,fname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
437 retval = self.compressPDF(inpdf=pdff,thumbformat=self.thumbformat) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
438 if retval == 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
439 pdflist.append((fname,thumb)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
440 if (rownum+1) % 2 == 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
441 fhtml.append('<tr class="odd_row"><td><a href="%s">%s</a></td><td>%s</td></tr>' % (fname,fname,sfsize)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
442 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
443 fhtml.append('<tr><td><a href="%s">%s</a></td><td>%s</td></tr>' % (fname,fname,sfsize)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
444 ntogo = nacross # counter for table row padding with empty cells |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
445 if len(pdflist) > 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
446 html.append('<div><table class="simple" cellpadding="2" cellspacing="2">\n<tr>') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
447 for i,paths in enumerate(pdflist): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
448 fname,thumb = paths |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
449 s= """<td><a href="%s"><img src="%s" title="Click to download a PDF of %s" hspace="5" width="%d" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
450 alt="Image called %s"/></a></td>\n""" % (fname,thumb,fname,width,fname) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
451 if ((i+1) % nacross == 0): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
452 s += '</tr>\n' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
453 ntogo = 0 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
454 if i < (npdf - 1): # more to come |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
455 s += '<tr>' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
456 ntogo = nacross |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
457 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
458 ntogo -= 1 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
459 html.append(s) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
460 if html[-1].strip().endswith('</tr>'): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
461 html.append('</table></div>\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
462 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
463 if ntogo > 0: # pad |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
464 html.append('<td> </td>'*ntogo) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
465 html.append('</tr></table></div>\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
466 if len(fhtml) > 0: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
467 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') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
468 fhtml.append('</table></div><br/>') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
469 html += fhtml # add all non-pdf files to the end of the display |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
470 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
471 html.append('<div class="warningmessagelarge">### Error - %s returned no files - please confirm that parameters are sane</div>' % self.opts.interpreter) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
472 rlog = open(self.tlog,'r').readlines() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
473 rlog = [x for x in rlog if x.strip() > ''] |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
474 if len(rlog) > 1: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
475 html.append('<div class="toolFormTitle">%s log</div><pre>\n' % self.opts.interpreter) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
476 html += rlog |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
477 html.append('</pre>\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
478 html.append(galhtmlattr % (self.toolname)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
479 html.append(galhtmlpostfix) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
480 htmlf = file(self.opts.output_html,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
481 htmlf.write('\n'.join(html)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
482 htmlf.write('\n') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
483 htmlf.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
484 self.html = html |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
485 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
486 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
487 def run(self): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
488 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
489 scripts must be small enough not to fill the pipe! |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
490 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
491 if self.treatbashSpecial and self.opts.interpreter in ['bash','sh']: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
492 retval = self.runBash() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
493 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
494 if self.opts.output_dir: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
495 sto = open(self.tlog,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
496 sto.write('## Toolfactory generated command line = %s\n' % ' '.join(self.cl)) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
497 sto.flush() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
498 p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=sto,stdin=subprocess.PIPE,cwd=self.opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
499 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
500 p = subprocess.Popen(self.cl,shell=False,stdin=subprocess.PIPE) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
501 p.stdin.write(self.script) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
502 p.stdin.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
503 retval = p.wait() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
504 if self.opts.output_dir: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
505 sto.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
506 if self.opts.make_HTML: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
507 self.makeHtml() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
508 return retval |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
509 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
510 def runBash(self): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
511 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
512 cannot use - for bash so use self.sfile |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
513 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
514 if self.opts.output_dir: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
515 s = '## Toolfactory generated command line = %s\n' % ' '.join(self.cl) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
516 sto = open(self.tlog,'w') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
517 sto.write(s) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
518 sto.flush() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
519 p = subprocess.Popen(self.cl,shell=False,stdout=sto,stderr=sto,cwd=self.opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
520 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
521 p = subprocess.Popen(self.cl,shell=False) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
522 retval = p.wait() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
523 if self.opts.output_dir: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
524 sto.close() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
525 if self.opts.make_HTML: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
526 self.makeHtml() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
527 return retval |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
528 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
529 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
530 def main(): |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
531 u = """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
532 This is a Galaxy wrapper. It expects to be called by a special purpose tool.xml as: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
533 <command interpreter="python">rgBaseScriptWrapper.py --script_path "$scriptPath" --tool_name "foo" --interpreter "Rscript" |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
534 </command> |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
535 """ |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
536 op = optparse.OptionParser() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
537 a = op.add_option |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
538 a('--script_path',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
539 a('--tool_name',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
540 a('--interpreter',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
541 a('--output_dir',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
542 a('--output_html',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
543 a('--input_tab',default="None") |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
544 a('--output_tab',default="None") |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
545 a('--user_email',default='Unknown') |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
546 a('--bad_user',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
547 a('--make_Tool',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
548 a('--make_HTML',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
549 a('--help_text',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
550 a('--tool_desc',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
551 a('--new_tool',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
552 a('--tool_version',default=None) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
553 opts, args = op.parse_args() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
554 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) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
555 assert opts.tool_name,'## Tool Factory expects a tool name - eg --tool_name=DESeq' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
556 assert opts.interpreter,'## Tool Factory wrapper expects an interpreter - eg --interpreter=Rscript' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
557 assert os.path.isfile(opts.script_path),'## Tool Factory wrapper expects a script path - eg --script_path=foo.R' |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
558 if opts.output_dir: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
559 try: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
560 os.makedirs(opts.output_dir) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
561 except: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
562 pass |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
563 r = ScriptRunner(opts) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
564 if opts.make_Tool: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
565 retcode = r.makeTooltar() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
566 else: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
567 retcode = r.run() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
568 os.unlink(r.sfile) |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
569 if retcode: |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
570 sys.exit(retcode) # indicate failure to job runner |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
571 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
572 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
573 if __name__ == "__main__": |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
574 main() |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
575 |
cb4937b0c21d
This fixes a problem reported by Carlos with perl scripts - now use CDATA segments to protect that horrible syntax from Cheetah - seems to work properly now.
fubar
parents:
diff
changeset
|
576 |