#!/usr/bin/env python import birchenv import birchscript import os import os.path import shutil import sys #Version 8/27/07 # Launch viewers for phylogenetic tree data or send output to files # For use by programs that generate tree output eg. GDE, tGDE, mGDE # #Synopsis: gde.treeoutput.csh [-e|-d|-f] outtree outfile outname #Convert arguments to variables WHATTODO = sys.argv[1] OUTTREE = sys.argv[2] OUTFILE = sys.argv[3] OUTNAME = sys.argv[4] JOBID = os.getpid() # Special code for text editors used by GDE and scripts called by GDE # Nedit crashes in some Linux systems due to libraries set in BIRCHLIBS. # nedit_wrapper unsets LD_LIBRARY_PATH before calling nedit. # gedit opens all files in a single window. gedit_wrapper.sh forces # gedit to open each file in different window. # choose_edit_wrapper.sh returns the name of the wrapper to use # for each editor, or just returns GDE_TEXTEDIT if there is no # wrapper. if WHATTODO == '-f': shutil.move(OUTFILE, OUTNAME + '.outfile') shutil.move(OUTTREE, OUTNAME + '.treefile') if os.path.exists(OUTTREE + '.alltrees'): shutil.move(OUTTREE + '.alltrees', OUTTREE + '.alltrees.treefile') else: birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, OUTFILE]], [OUTFILE], True) if WHATTODO == '-d': # output to tree editor birchscript.Cleanrun([['atv', OUTTREE]], [], True) elif WHATTODO == '-d': birchscript.Cleanrun([['drawtree.csh', OUTTREE, 'yes', 'f', '0', '360', 'IE', '360', 'reg', os.path.join(birchenv.BIRCH_DAT, 'Phylip', 'font1'), '0.333', 'l', JOBID + '.plotfile'], [birchenv.GDE_PSVIEW, JOBID + '.plotfile']], [JOBID + '.plotfile'], True) birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, OUTTREE]], [], True) birchscript.Cleanrun([['python', os.path.join(birchenv.BIRCH, 'script', 'tree2flat.py'), OUTTREE, JOBID + '.flat'], ['tgde', JOBID + '.flat']], [OUTTREE, JOBID + '.flat'], True) if os.path.exists(OUTTREE + '.alltrees'): birchscript.Cleanrun([['python', os.path.join(birchenv.BIRCH, 'script', 'tree2flat.py'), OUTTREE + '.alltrees', JOBID + '.alltrees.flat'], ['tgde', JOBID + '.alltrees.flat']], [OUTTREE, JOBID + + '.alltrees.flat'], True) birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, OUTTREE + '.alltrees']], [OUTTREE + '.alltrees'], True)