Mercurial > repos > fubar > tool_factory_2
comparison rgToolFactory2.py @ 14:3635f4518c4d draft
Uploaded
author | fubar |
---|---|
date | Tue, 20 Jan 2015 19:03:18 -0500 |
parents | 00777b83aaca |
children | dd6cf2ddaac7 |
comparison
equal
deleted
inserted
replaced
13:00777b83aaca | 14:3635f4518c4d |
---|---|
8 # suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home | 8 # suggestions for improvement and bug fixes welcome at https://bitbucket.org/fubar/galaxytoolfactory/wiki/Home |
9 # | 9 # |
10 # January 2015 | 10 # January 2015 |
11 # in the process of building a complex tool | 11 # in the process of building a complex tool |
12 # added ability to choose one of the current toolshed package_r or package_perl or package_python dependencies and source that package | 12 # added ability to choose one of the current toolshed package_r or package_perl or package_python dependencies and source that package |
13 # need to add that package to tool_dependencies | 13 # add that package to tool_dependencies |
14 # Note that once the generated tool is loaded, it will have that package's env.sh loaded automagically so there is no | |
15 # --envshpath in the parameters for the generated tool and it uses the system one which will be first on the adjusted path. | |
14 # | 16 # |
15 # sept 2014 added additional params from | 17 # sept 2014 added additional params from |
16 # https://bitbucket.org/mvdbeek/dockertoolfactory/src/d4863bcf7b521532c7e8c61b6333840ba5393f73/DockerToolFactory.py?at=default | 18 # https://bitbucket.org/mvdbeek/dockertoolfactory/src/d4863bcf7b521532c7e8c61b6333840ba5393f73/DockerToolFactory.py?at=default |
17 # passing them is complex | 19 # passing them is complex |
18 # and they are restricted to NOT contain commas or double quotes to ensure that they can be safely passed together on | 20 # and they are restricted to NOT contain commas or double quotes to ensure that they can be safely passed together on |
192 <repository name="%(interpreter_pack)s" owner="%(interpreter_owner)s" prior_installation_required="True" /> | 194 <repository name="%(interpreter_pack)s" owner="%(interpreter_owner)s" prior_installation_required="True" /> |
193 </package> | 195 </package> |
194 | 196 |
195 <readme> | 197 <readme> |
196 %(readme)s | 198 %(readme)s |
199 This file was autogenerated by the Galaxy Tool Factory 2 | |
197 </readme> | 200 </readme> |
198 </tool_dependency> | 201 </tool_dependency> |
199 """ | 202 """ |
200 | 203 |
201 self.toolhtmldepskel = """<?xml version="1.0"?> | 204 self.toolhtmldepskel = """<?xml version="1.0"?> |
206 <package name="graphicsmagick" version="1.3.18"> | 209 <package name="graphicsmagick" version="1.3.18"> |
207 <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" /> | 210 <repository name="package_graphicsmagick_1_3" owner="iuc" prior_installation_required="True" /> |
208 </package> | 211 </package> |
209 <readme> | 212 <readme> |
210 %(readme)s | 213 %(readme)s |
214 This file was autogenerated by the Galaxy Tool Factory 2 | |
211 </readme> | 215 </readme> |
212 </tool_dependency> | 216 </tool_dependency> |
213 """ | 217 """ |
214 | 218 |
215 self.emptytoolhtmldepskel = """<?xml version="1.0"?> | 219 self.emptytoolhtmldepskel = """<?xml version="1.0"?> |
216 <tool_dependency> | 220 <tool_dependency> |
217 <readme> | 221 <readme> |
218 %(readme)s | 222 %(readme)s |
223 This file was autogenerated by the Galaxy Tool Factory 2 | |
219 </readme> | 224 </readme> |
220 </tool_dependency> | 225 </tool_dependency> |
221 """ | 226 """ |
222 | 227 |
223 self.protorequirements = """<requirements> | 228 self.protorequirements = """<requirements> |
293 </tests> | 298 </tests> |
294 <help> | 299 <help> |
295 | 300 |
296 %(help)s | 301 %(help)s |
297 | 302 |
303 This tool was autogenerated from a user provided script using the Galaxy Tool Factory 2 | |
304 https://toolshed.g2.bx.psu.edu/view/fubar/tool_factory_2 | |
298 </help> | 305 </help> |
299 <citations> | 306 <citations> |
300 %(citations)s | 307 %(citations)s |
301 <citation type="doi">10.1093/bioinformatics/bts573</citation> | 308 <citation type="doi">10.1093/bioinformatics/bts573</citation> |
302 </citations> | 309 </citations> |
425 self.interp_owner = None | 432 self.interp_owner = None |
426 self.interp_pack = None | 433 self.interp_pack = None |
427 self.interp_revision = None | 434 self.interp_revision = None |
428 self.interp_version = None | 435 self.interp_version = None |
429 if opts.envshpath <> 'system': # need to parse out details for our tool_dependency | 436 if opts.envshpath <> 'system': # need to parse out details for our tool_dependency |
430 try: | 437 try: # fragile - depends on common naming convention as at jan 2015 = package_[interp]_v0_v1_v2... = version v0.v1.v2.. is in play |
438 | |
431 packdetails = opts.envshpath.split(os.path.sep)[-4:-1] # eg ['fubar', 'package_r_3_1_1', '63cdb9b2234c'] | 439 packdetails = opts.envshpath.split(os.path.sep)[-4:-1] # eg ['fubar', 'package_r_3_1_1', '63cdb9b2234c'] |
432 self.interpreter_owner = packdetails[0] | 440 self.interpreter_owner = packdetails[0] |
433 self.interpreter_pack = packdetails[1] | 441 self.interpreter_pack = packdetails[1] |
434 self.interpreter_name = packdetails[1].split('_')[1].upper() | 442 self.interpreter_name = packdetails[1].split('_')[1].upper() |
435 self.interpreter_revision = packdetails[2] | 443 self.interpreter_revision = packdetails[2] |
436 self.interpreter_version = '.'.join(self.interpreter_pack.split('_')[2:]) | 444 self.interpreter_version = '.'.join(packdetails[1].split('_')[2:]) |
437 # hope our naming convention as at jan 2015 = package_[interp]_v0_v1_v2... = version v0.v1.v2.. is in play | |
438 except: | 445 except: |
439 pass | 446 pass |
440 self.outFormats = opts.output_format | 447 self.outFormats = opts.output_format |
441 self.inputFormats = opts.input_formats | 448 self.inputFormats = opts.input_formats |
442 self.test1Output = '%s_test1_output.xls' % self.toolname | 449 self.test1Output = '%s_test1_output.xls' % self.toolname |
615 if self.opts.help_text: | 622 if self.opts.help_text: |
616 hlp = open(self.opts.help_text,'r').read() | 623 hlp = open(self.opts.help_text,'r').read() |
617 else: | 624 else: |
618 hlp = 'Please ask the tool author for help as none was supplied at tool generation\n' | 625 hlp = 'Please ask the tool author for help as none was supplied at tool generation\n' |
619 readme_dict = {'readme':hlp,'interpreter':self.opts.interpreter,'interpreter_version':self.interpreter_version,'interpreter_name':self.interpreter_name, | 626 readme_dict = {'readme':hlp,'interpreter':self.opts.interpreter,'interpreter_version':self.interpreter_version,'interpreter_name':self.interpreter_name, |
620 'interpreter_owner':self.interpreter_owner} | 627 'interpreter_owner':self.interpreter_owner,'interpreter_pack':self.interpreter_pack} |
621 if self.opts.include_dependencies == "yes": | 628 if self.opts.include_dependencies == "yes": |
622 if self.opts.envshpath == 'system': | 629 if self.opts.envshpath == 'system': |
623 tooldepcontent = self.toolhtmldepskel % readme_dict | 630 tooldepcontent = self.toolhtmldepskel % readme_dict |
624 else: | 631 else: |
625 tooldepcontent = self.toolhtmldepinterpskel % readme_dict | 632 tooldepcontent = self.toolhtmldepinterpskel % readme_dict |
627 tooldepcontent = self.emptytoolhtmldepskel % readme_dictls -l | 634 tooldepcontent = self.emptytoolhtmldepskel % readme_dictls -l |
628 depf = open(os.path.join(tdir,'tool_dependencies.xml'),'w') | 635 depf = open(os.path.join(tdir,'tool_dependencies.xml'),'w') |
629 depf.write(tooldepcontent) | 636 depf.write(tooldepcontent) |
630 depf.write('\n') | 637 depf.write('\n') |
631 depf.close() | 638 depf.close() |
632 if self.opts.input_tab: # no reproducible test otherwise? TODO: maybe.. | 639 testdir = os.path.join(tdir,'test-data') |
633 testdir = os.path.join(tdir,'test-data') | 640 os.mkdir(testdir) # make tests directory |
634 os.mkdir(testdir) # make tests directory | 641 for i,intab in enumerate(self.opts.input_tab): |
635 for i,intab in enumerate(self.opts.input_tab): | 642 si = self.opts.input_tab[i] |
636 si = self.opts.input_tab[i] | 643 if si.find(',') <> -1: |
637 if si.find(',') <> -1: | 644 s = si.split(',')[0] |
638 s = si.split(',')[0] | 645 si = s |
639 si = s | 646 dest = os.path.join(testdir,os.path.basename(si)) |
640 dest = os.path.join(testdir,os.path.basename(si)) | 647 if si <> dest: |
641 if si <> dest: | 648 shutil.copyfile(si,dest) |
642 shutil.copyfile(si,dest) | 649 if self.opts.output_tab: |
643 if self.opts.output_tab: | 650 shutil.copyfile(self.opts.output_tab,os.path.join(testdir,self.test1Output)) |
644 shutil.copyfile(self.opts.output_tab,os.path.join(testdir,self.test1Output)) | 651 if self.opts.make_HTML: |
645 if self.opts.make_HTML: | 652 shutil.copyfile(self.opts.output_html,os.path.join(testdir,self.test1HTML)) |
646 shutil.copyfile(self.opts.output_html,os.path.join(testdir,self.test1HTML)) | 653 if self.opts.output_dir: |
647 if self.opts.output_dir: | 654 shutil.copyfile(self.tlog,os.path.join(testdir,'test1_out.log')) |
648 shutil.copyfile(self.tlog,os.path.join(testdir,'test1_out.log')) | |
649 outpif = '%s.py' % self.toolname # new name | 655 outpif = '%s.py' % self.toolname # new name |
650 outpiname = os.path.join(tdir,outpif) # path for the tool tarball | 656 outpiname = os.path.join(tdir,outpif) # path for the tool tarball |
651 pyin = os.path.basename(self.pyfile) # our name - we rewrite ourselves (TM) | 657 pyin = os.path.basename(self.pyfile) # our name - we rewrite ourselves (TM) |
652 notes = ['# %s - a self annotated version of %s generated by running %s\n' % (outpiname,pyin,pyin),] | 658 notes = ['# %s - a self annotated version of %s generated by running %s\n' % (outpiname,pyin,pyin),] |
653 notes.append('# to make a new Galaxy tool called %s\n' % self.toolname) | 659 notes.append('# to make a new Galaxy tool called %s\n' % self.toolname) |