# HG changeset patch # User malex # Date 1322863647 18000 # Node ID 9ce35d2d9937e3bc9e6ab81cb11509066eb5896f # Parent 4025ba8b84d603ee4114fb64a7f8cb8176c9fed5 Uploaded the wrapper diff -r 4025ba8b84d6 -r 9ce35d2d9937 garli_wrapper.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/garli_wrapper.py Fri Dec 02 17:07:27 2011 -0500 @@ -0,0 +1,48 @@ +#!/usr/bin/env python + +""" +Runs Garli-2.0 on a sequence file. +For use with Garli version 2.0 + +usage: garli_wrapper.py config_file best_tree all_trees run_log screen_log out_conf +""" +import os, shutil, subprocess, sys + +def stop_err(msg): + sys.stderr.write("%s\n" % msg) + sys.exit() + +def __main__(): + usage = "usage: %prog input conf btree balltree runlog scrlog outconf" + conf = sys.argv[1] + balltree = 'garli.best.all.tre' + btree = 'garli.best.tre' + runlog = 'garli.log00.log' + scrlog = 'garli.screen.log' + cmd = [] + cmd.append('Garli-2.0') + cmd.append(os.path.basename(conf)) + try: + proc = subprocess.Popen(args=cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) + except Exception, err: + sys.stderr.write("Error invoking command: \n%s\n\n%s\n" % (cmd, err)) + sys.exit(1) + stdout, stderr = proc.communicate() + return_code = proc.returncode + if return_code: + sys.stdout.write(stdout) + sys.stderr.write(stderr) + sys.stderr.write("Return error code %i from command:\n" % return_code) + sys.stderr.write("%s\n" % cmd) + else: + sys.stdout.write(stdout) + sys.stdout.write(stderr) + try: + shutil.copyfile(os.path.basename(conf), 'garli.conf') + if not os.path.exists(balltree): + bat = open(balltree,'w') + bat.write('Only a single tree was found, so this file does not have any output') + bat.close() + except Exception, err: + sys.stderr.write("Error copying output files: \n%s\n" % err) +if __name__=="__main__": __main__()