#! /usr/bin/env python """ reroot.py -i -o -g contains just a tree in newick format will contain the rerooted tree comma separated list of taxa in outgroup """ import sys import os import getopt def usage(): sys.exit("usage: " + sys.argv[0] + __doc__) if __name__ == '__main__': print "here in main" fp = os.path.abspath(sys.argv[0]) cipres_bin = os.path.dirname(fp) cipres_root = os.path.dirname(cipres_bin) cipres_cp_jar_path = os.path.join(cipres_root, "lib", "cipres", "cipres-classpath.jar") infile='' outfile='' outgroups='' try: opts, args = getopt.getopt(sys.argv[1:], "i:o:g:") except getopt.GetoptError: usage() for opt, arg in opts: if opt in ("-i"): infile = arg if opt in ("-o"): outfile = arg if opt in ("-g"): outgroups = arg preargs = [ "java", "-ea", "-Dinfile=%s" % infile, "-Doutfile=%s" % outfile, "-Doutgroups=%s" % outgroups ] postargs = [ "-classpath", cipres_cp_jar_path, "org.cipres.util.tree.UTree" ] args = preargs + postargs print args os.execvp("java", args)