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