Mercurial > repos > sanbi-uwc > build_ctb_gene
diff build_ctb_gene.py @ 14:4caf3e2d10e8 draft
planemo upload for repository https://github.com/SANBI-SA/tools-sanbi-uwc.git commit 63871d62b7acd851ff2d50dc08520c17bdf834f6
author | sanbi-uwc |
---|---|
date | Wed, 18 May 2016 04:49:51 -0400 |
parents | 3ef417806df9 |
children | e6d850bb9fb6 |
line wrap: on
line diff
--- a/build_ctb_gene.py Tue May 17 07:34:13 2016 -0400 +++ b/build_ctb_gene.py Wed May 18 04:49:51 2016 -0400 @@ -6,6 +6,7 @@ import glob import shlex import shutil +import datetime from subprocess import check_call, CalledProcessError import logging @@ -14,31 +15,26 @@ 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 + # 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 = "build_ctb_gene goterms ${}".format(input_file) cmdline_str = "touch /tmp/foo.bar" - build_ctb = False cmdline_str = self.newSplit(cmdline_str) + build_ctb_run = True try: check_call(cmdline_str) - #build_ctb = True + build_ctb_run = False 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 + print("Error running the build_ctb_gene goterms", file=sys.stderr) + if build_ctb_run: + self.copy_output_file_to_dataset() def newSplit(self, value): lex = shlex.shlex(value) @@ -56,14 +52,9 @@ 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') @@ -76,15 +67,18 @@ 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") + except (OSError, ValueError), e: + print("Error exporting the NEO4J db environmental values", e) # 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 ctb_gene_runner.build_ctb_gene(): + print("Building a new DB, current time: %s" % str(datetime.date.today())) + print("Noe4j Database Name: http://%s:%s@%s:%s/db/data/" % (args.username, args.password, args.url, args.port)) + print("GFF File - Input: %s" % str(args.input_file)) -if __name__ == "__main__": main() \ No newline at end of file +if __name__ == "__main__": main()