Mercurial > repos > sanbi-uwc > build_ctb_gene
view build_ctb_gene.py @ 13:3ef417806df9 draft
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 3dd4b95732efe95365fc09bfcdfb917c25b2796e
author | sanbi-uwc |
---|---|
date | Tue, 17 May 2016 07:34:13 -0400 |
parents | 7d49ea27d9f6 |
children | 4caf3e2d10e8 |
line wrap: on
line source
#!/usr/bin/env python from __future__ import print_function import argparse import os import sys import glob import shlex import shutil from subprocess import check_call, CalledProcessError import logging log = logging.getLogger(__name__) class BuildCtbRunner(object): def __init__(self, args=None): ''' Initializes an object to run CtbRunner in Galaxy. ''' # Check whether the options are specified and saves them into the object #assert args != None self.args = args def build_ctb_gene(self): #cmdline_str = "build_ctb_gene goterms ${}".format(input_file) #cmdline_str = "build_ctb_gene goterms --help" cmdline_str = "touch /tmp/foo.bar" build_ctb = False cmdline_str = self.newSplit(cmdline_str) try: check_call(cmdline_str) #build_ctb = True except CalledProcessError: print("Error running the build_ctb_gene gotermS", file=sys.stderr) self.copy_output_file_to_dataset() #self.args.outputdir = "<html><body>The Output of the Neo4J DB</body></html>" #return self.args.outputdir def newSplit(self, value): lex = shlex.shlex(value) lex.quotes = '"' lex.whitespace_split = True lex.commenters = '' return list(lex) def copy_output_file_to_dataset(self): ''' Retrieves the output files from the output directory and copies them to the Galaxy output files ''' # retrieve neo4j files to the working gx directory result_file = glob.glob(self.args.mount_point + '/*') for file_name in result_file: shutil.copy(file_name, self.args.outputdir) #with open(result_file[0], 'rb') as fsrc: #with open(self.args.outputdir, 'wb') as fdest: #shutil.copy(fsrc, self.args.outputdir) def main(): parser = argparse.ArgumentParser(description="Tool used to extract data about genes using locus_tags") #parser.add_argument('--outputfile') parser.add_argument('--outputdir') parser.add_argument('--input_file') parser.add_argument('--mount_point') parser.add_argument('--username') parser.add_argument('--password') parser.add_argument('--url') parser.add_argument('--port') args = parser.parse_args() export_cmd = "export NEO4J_REST_URL=http://${args.username}:${args.password}@${args.url}:${args.port}/db/data/" try: os.system(export_cmd) except: log.debug("Error exporting the NEO4J db environmental values") # make the output directory if not os.path.exists(args.outputdir): os.makedirs(args.outputdir) ctb_gene_runner = BuildCtbRunner(args) ctb_gene_runner.build_ctb_gene() if __name__ == "__main__": main()