changeset 4:de4889098f45 default tip

Allow whitespace in gene name and fix missing creation of output section.
author mvdbeek
date Wed, 14 Jan 2015 17:19:16 +0100
parents 477eac6c4cea
children
files DockerToolFactory.py DockerToolFactory.xml Dockerfile
diffstat 3 files changed, 691 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/DockerToolFactory.py	Wed Dec 03 01:47:58 2014 +0100
+++ b/DockerToolFactory.py	Wed Jan 14 17:19:16 2015 +0100
@@ -154,24 +154,25 @@
         self.image_tag = image_tag
         os.chdir(abspath(opts.output_dir))
         self.thumbformat = 'png'
-        self.toolname = re.sub('[^a-zA-Z0-9_]+', '', opts.tool_name) # a sanitizer now does this but..
+        self.toolname_sanitized = re.sub('[^a-zA-Z0-9_]+', '_', opts.tool_name) # a sanitizer now does this but..
+        self.toolname = opts.tool_name
         self.toolid = self.toolname
         self.myname = sys.argv[0] # get our name because we write ourselves out as a tool later
         self.pyfile = self.myname # crude but efficient - the cruft won't hurt much
-        self.xmlfile = '%s.xml' % self.toolname
+        self.xmlfile = '%s.xml' % self.toolname_sanitized
         s = open(self.opts.script_path,'r').readlines()
         s = [x.rstrip() for x in s] # remove pesky dos line endings if needed
         self.script = '\n'.join(s)
-        fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname,suffix=".%s" % (opts.interpreter))
+        fhandle,self.sfile = tempfile.mkstemp(prefix=self.toolname_sanitized,suffix=".%s" % (opts.interpreter))
         tscript = open(self.sfile,'w') # use self.sfile as script source for Popen
         tscript.write(self.script)
         tscript.close()
         self.indentedScript = '\n'.join([' %s' % html_escape(x) for x in s]) # for restructured text in help
         self.escapedScript = '\n'.join([html_escape(x) for x in s])
-        self.elog = os.path.join(self.opts.output_dir,"%s_error.log" % self.toolname)
+        self.elog = os.path.join(self.opts.output_dir,"%s_error.log" % self.toolname_sanitized)
         if opts.output_dir: # may not want these complexities
-            self.tlog = os.path.join(self.opts.output_dir,"%s_runner.log" % self.toolname)
-            art = '%s.%s' % (self.toolname,opts.interpreter)
+            self.tlog = os.path.join(self.opts.output_dir,"%s_runner.log" % self.toolname_sanitized)
+            art = '%s.%s' % (self.toolname_sanitized,opts.interpreter)
             artpath = os.path.join(self.opts.output_dir,art) # need full path
             artifact = open(artpath,'w') # use self.sfile as script source for Popen
             artifact.write(self.script)
@@ -187,7 +188,7 @@
 	for input in opts.input_tab:
 	  a(input) 
         if opts.output_tab == 'None': #If tool generates only HTML, set output name to toolname
-            a(str(self.toolname)+'.out')
+            a(str(self.toolname_sanitized)+'.out')
         a(opts.output_tab)
 	for param in opts.additional_parameters:
           param, value=param.split(',')
@@ -196,9 +197,9 @@
         #print self.cl
         self.outFormats = opts.output_format
         self.inputFormats = [formats for formats in opts.input_formats]
-        self.test1Input = '%s_test1_input.xls' % self.toolname
-        self.test1Output = '%s_test1_output.xls' % self.toolname
-        self.test1HTML = '%s_test1_output.html' % self.toolname
+        self.test1Input = '%s_test1_input.xls' % self.toolname_sanitized
+        self.test1Output = '%s_test1_output.xls' % self.toolname_sanitized
+        self.test1HTML = '%s_test1_output.html' % self.toolname_sanitized
 
     def makeXML(self):
         """
@@ -274,10 +275,10 @@
 %(help)s
 
 </help>
-</tool>""" # needs a dict with toolname, toolid, interpreter, scriptname, command, inputs as a multi line string ready to write, outputs ditto, help ditto
+</tool>""" # needs a dict with toolname, toolname_sanitized, toolid, interpreter, scriptname, command, inputs as a multi line string ready to write, outputs ditto, help ditto
 
         newCommand="""
-        %(toolname)s.py --script_path "$runMe" --interpreter "%(interpreter)s" 
+        %(toolname_sanitized)s.py --script_path "$runMe" --interpreter "%(interpreter)s" 
             --tool_name "%(toolname)s" %(command_inputs)s %(command_outputs)s """
         # may NOT be an input or htmlout - appended later
         tooltestsTabOnly = """
@@ -355,6 +356,7 @@
             xdict['inputs'] = ''
         # I find setting the job name not very logical. can be changed in workflows anyway. 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
         xdict['toolname'] = self.toolname
+        xdict['toolname_sanitized'] = self.toolname_sanitized
         xdict['toolid'] = self.toolid
         xdict['interpreter'] = self.opts.interpreter
         xdict['scriptname'] = self.sfile
@@ -364,7 +366,7 @@
         else:
             xdict['command_outputs'] += ' --output_dir "./"' 
         #print self.opts.output_tab
-        if not self.opts.output_tab:
+        if self.opts.output_tab!="None":
             xdict['command_outputs'] += ' --output_tab "$tab_file"'
             xdict['outputs'] += ' <data format="%s" name="tab_file"/>\n' % self.outFormats
         xdict['command'] = newCommand % xdict
@@ -380,13 +382,13 @@
     def makeTooltar(self):
         """
         a tool is a gz tarball with eg
-        /toolname/tool.xml /toolname/tool.py /toolname/test-data/test1_in.foo ...
+        /toolname_sanitized/tool.xml /toolname_sanitized/tool.py /toolname_sanitized/test-data/test1_in.foo ...
         """
         retval = self.run()
         if retval:
             print >> sys.stderr,'## Run failed. Cannot build yet. Please fix and retry'
             sys.exit(1)
-        tdir = self.toolname
+        tdir = self.toolname_sanitized
         os.mkdir(tdir)
         self.makeXML()
         if self.opts.make_HTML:
@@ -412,7 +414,7 @@
                 shutil.copyfile(self.opts.output_html,os.path.join(testdir,self.test1HTML))
             if self.opts.output_dir:
                 shutil.copyfile(self.tlog,os.path.join(testdir,'test1_out.log'))
-        outpif = '%s.py' % self.toolname # new name
+        outpif = '%s.py' % self.toolname_sanitized # new name
         outpiname = os.path.join(tdir,outpif) # path for the tool tarball
         pyin = os.path.basename(self.pyfile) # our name - we rewrite ourselves (TM)
         notes = ['# %s - a self annotated version of %s generated by running %s\n' % (outpiname,pyin,pyin),]
@@ -430,9 +432,9 @@
         xtname = os.path.join(tdir,self.xmlfile)
         if not os.path.exists(xtname):
             shutil.copyfile(self.xmlfile,xtname)
-        tarpath = "%s.gz" % self.toolname
+        tarpath = "%s.gz" % self.toolname_sanitized
         tar = tarfile.open(tarpath, "w:gz")
-        tar.add(tdir,arcname=self.toolname)
+        tar.add(tdir,arcname=self.toolname_sanitized)
         tar.close()
         shutil.copyfile(tarpath,self.opts.new_tool)
         shutil.rmtree(tdir)
--- a/DockerToolFactory.xml	Wed Dec 03 01:47:58 2014 +0100
+++ b/DockerToolFactory.xml	Wed Jan 14 17:19:16 2015 +0100
@@ -1,4 +1,4 @@
-<tool id="rgTF" name="Docker Tool Factory" version="0.1">
+<tool id="rgTF" name="Docker Tool Factory" version="0.1.1">
   <description>Makes scripts into tools using Docker</description>
    <requirements>
       <requirement type="package" version="9.10">ghostscript</requirement>
@@ -75,7 +75,7 @@
     <param name="tool_name" type="text" value="My dynamic script"   label="New tool ID and title for outputs" size="60"
          help="This will become the toolshed repository name so please choose thoughtfully to avoid namespace clashes with other tool writers">
         <sanitizer invalid_char="">
-            <valid initial="string.letters,string.digits"/>
+            <valid initial="string.printable"/>
         </sanitizer>
     </param>
     <conditional name="makeMode">
--- a/Dockerfile	Wed Dec 03 01:47:58 2014 +0100
+++ b/Dockerfile	Wed Jan 14 17:19:16 2015 +0100
@@ -27,11 +27,679 @@
 
 RUN Rscript -e 'source("http://bioconductor.org/biocLite.R"); biocLite(c("DESeq", "DESeq2", "edgeR", "EDASeq"))'
 RUN Rscript -e 'install.packages(c("latticeExtra", "ggplot2", "reshape", "gridExtra"), dependencies=TRUE, repos="http://cran.us.r-project.org")'
+RUN apt-get install bc
+RUN easy_install intermine
 
 #add galaxy user (could be any username).
 #1001 will be replaced by the actual user id of the system user
 #executing the galaxy tool, so that file write operations are possible.
-RUN adduser galaxy -u 1001
+RUN adduser galaxy -u 1002
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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