Repository 'tool_factory_2'
hg clone https://toolshed.g2.bx.psu.edu/repos/fubar/tool_factory_2

Changeset 10:8de2b7571d98 (2015-01-15)
Previous changeset 9:ce5ec1d989fd (2015-01-14) Next changeset 11:000bb4888c81 (2015-01-15)
Commit message:
Uploaded
modified:
rgToolFactory2.py
b
diff -r ce5ec1d989fd -r 8de2b7571d98 rgToolFactory2.py
--- a/rgToolFactory2.py Wed Jan 14 19:17:11 2015 -0500
+++ b/rgToolFactory2.py Thu Jan 15 07:35:06 2015 -0500
[
b'@@ -7,6 +7,11 @@\n # Licensed under the LGPL\n # suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home\n #\n+# January 2015\n+# in the process of building a complex tool\n+# added ability to choose one of the current toolshed package_r or package_perl or package_python dependencies and source that package\n+# need to add that package to tool_dependencies\n+#\n # sept 2014 added additional params from\n # https://bitbucket.org/mvdbeek/dockertoolfactory/src/d4863bcf7b521532c7e8c61b6333840ba5393f73/DockerToolFactory.py?at=default\n # passing them is complex\n@@ -107,32 +112,6 @@\n \n # if we do html we need these dependencies specified in a tool_dependencies.xml file and referred to in the generated\n # tool xml\n-toolhtmldepskel = """<?xml version="1.0"?>\n-<tool_dependency>\n-    <package name="ghostscript" version="9.10">\n-        <repository name="package_ghostscript_9_10" owner="devteam" prior_installation_required="True" />\n-    </package>\n-    <package name="graphicsmagick" version="1.3.18">\n-        <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" />\n-    </package>\n-        <readme>\n-           %s\n-       </readme>\n-</tool_dependency>\n-"""\n-\n-emptytoolhtmldepskel = """<?xml version="1.0"?>\n-<tool_dependency>\n-        <readme>\n-           %s\n-       </readme>\n-</tool_dependency>\n-"""\n-\n-protorequirements = """<requirements>\n-      <requirement type="package" version="9.10">ghostscript</requirement>\n-      <requirement type="package" version="1.3.18">graphicsmagick</requirement>\n-  </requirements>"""\n \n def timenow():\n     """return current time as a string\n@@ -188,13 +167,141 @@\n     \n class ScriptRunner:\n     """class is a wrapper for an arbitrary script\n+    note funky templating. this should all be done proper.\n+    Problem is, this kludge developed quite naturally and seems to work ok with\n+    little overhead...\n+    \n     """\n \n+\n     def __init__(self,opts=None,treatbashSpecial=True):\n         """\n         cleanup inputs, setup some outputs\n         \n         """\n+        \n+        self.toolhtmldepinterpskel = """<?xml version="1.0"?>\n+        <tool_dependency>\n+            <package name="ghostscript" version="9.10">\n+                <repository name="package_ghostscript_9_10" owner="devteam" prior_installation_required="True" />\n+            </package>\n+            <package name="graphicsmagick" version="1.3.18">\n+                <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" />\n+            </package>\n+             <package name="%(interpreter)s" version="%(interpreter_version)s">\n+                <repository name="%(interpreter_name)s" owner="%(interpreter_owner)s" prior_installation_required="True" />\n+            </package>\n+           \n+                <readme>\n+                   %(readme)s\n+               </readme>\n+        </tool_dependency>\n+        """\n+        \n+        self.toolhtmldepskel = """<?xml version="1.0"?>\n+        <tool_dependency>\n+            <package name="ghostscript" version="9.10">\n+                <repository name="package_ghostscript_9_10" owner="devteam" prior_installation_required="True" />\n+            </package>\n+            <package name="graphicsmagick" version="1.3.18">\n+                <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" />\n+            </package>\n+                <readme>\n+                   %(readme)s\n+               </readme>\n+        </tool_dependency>\n+        """\n+\n+        self.emptytoolhtmldepskel = """<?xml version="1.0"?>\n+        <tool_dependency>\n+                <readme>\n+                   %(readme)s\n+               </readme>\n+        </tool_dependency>\n+        """\n+\n+        self.protorequirements = """<requirements>\n+              <requirement type="package" version="9.10">ghostscript</requirement>\n+              <requirement type="package" version="1.3.18">graphicsmagick</requ'..b'form with default value set to original value\n                 xdict[\'additionalInputs\'] = \'\\n\'.join([\'<param name="%s" value="%s" label="%s" help="%s" type="%s"/>\' % \\\n                 (x.split(\',\')[0],html_escape(x.split(\',\')[1]),html_escape(x.split(\',\')[2]),html_escape(x.split(\',\')[3]), x.split(\',\')[4]) for x in self.opts.additional_parameters])\n-            xdict[\'additionalParams\'] = \'\\n\'.join([\'<param name="%s" value="%s" />\' % (x.split(\',\')[0],html_escape(x.split(\',\')[1])) for x in self.opts.additional_parameters])\n+        xdict[\'additionalParams\'] = \'\\n\'.join([\'<param name="%s" value="%s" />\' % (x.split(\',\')[0],html_escape(x.split(\',\')[1])) for x in self.opts.additional_parameters])\n+        xdict[\'interpreter_owner\'] = self.interpreter_owner\n+        xdict[\'interpreter_version\'] = self.interpreter_version\n+        xdict[\'interpreter_name\'] = self.interpreter_pack\n         xdict[\'requirements\'] = \'\'\n-        if self.opts.make_HTML:\n-            if self.opts.include_dependencies == "yes":\n-                xdict[\'requirements\'] = protorequirements\n+        if self.opts.include_dependencies == "yes":\n+            if self.opts.envshpath <> \'system\':\n+                xdict[\'requirements\'] = self.protorequirements_interpreter % xdict       \n+            else:    \n+                xdict[\'requirements\'] = self.protorequirements\n         xdict[\'tool_version\'] = self.opts.tool_version\n         xdict[\'test1HTML\'] = self.test1HTML\n         xdict[\'test1Output\'] = self.test1Output\n         xdict[\'test1Inputs\'] = self.test1Inputs\n         if self.opts.make_HTML and self.opts.output_tab:\n-            xdict[\'tooltests\'] = tooltestsBoth % xdict\n+            xdict[\'tooltests\'] = self.tooltestsBoth % xdict\n         elif self.opts.make_HTML:\n-            xdict[\'tooltests\'] = tooltestsHTMLOnly % xdict\n+            xdict[\'tooltests\'] = self.tooltestsHTMLOnly % xdict\n         else:\n-            xdict[\'tooltests\'] = tooltestsTabOnly % xdict\n+            xdict[\'tooltests\'] = self.tooltestsTabOnly % xdict\n         xdict[\'script\'] = self.escapedScript \n         # configfile is least painful way to embed script to avoid external dependencies\n         # but requires escaping of <, > and $ to avoid Mako parsing\n@@ -520,7 +579,7 @@\n         if self.opts.output_tab:\n             xdict[\'command_outputs\'] += \' --output_tab "$output1"\'\n             xdict[\'outputs\'] += \' <data format="%s" name="output1" label="${job_name}"/>\\n\' % self.outFormats\n-        xdict[\'command\'] = newCommand % xdict\n+        xdict[\'command\'] = self.newCommand % xdict\n         if self.opts.citations:\n             citationstext = open(self.opts.citations,\'r\').read()\n             citation_tuples = parse_citations(citationstext)\n@@ -531,7 +590,7 @@\n             xdict[\'citations\'] = citations_xml\n         else:\n             xdict[\'citations\'] = ""\n-        xmls = newXML % xdict\n+        xmls = self.newXML % xdict\n         xf = open(self.xmlfile,\'w\')\n         xf.write(xmls)\n         xf.write(\'\\n\')\n@@ -555,10 +614,15 @@\n             hlp = open(self.opts.help_text,\'r\').read()\n         else:\n             hlp = \'Please ask the tool author for help as none was supplied at tool generation\\n\'\n+        readme_dict = {\'readme\':hlp,\'interpreter\':self.opts.interpreter,\'interpreter_version\':self.interpreter_version,\'interpreter_name\':self.interpreter_pack,\n+        \'interpreter_owner\':self.interpreter_owner}\n         if self.opts.include_dependencies == "yes":\n-            tooldepcontent = toolhtmldepskel  % hlp\n+            if self.opts.envshpath == \'system\':\n+                tooldepcontent = self.toolhtmldepskel % readme_dict\n+            else:\n+                tooldepcontent = self.toolhtmldepinterpskel % readme_dict\n         else:\n-            tooldepcontent = emptytoolhtmldepskel  % hlp\n+            tooldepcontent = self.emptytoolhtmldepskel  % readme_dictls -l\n         depf = open(os.path.join(tdir,\'tool_dependencies.xml\'),\'w\')\n         depf.write(tooldepcontent)\n         depf.write(\'\\n\')\n'