#!/usr/bin/env python import birchenv import birchscript import os import os.path import subprocess import sys #Version 5/23/08 # Run primer3 using the input file created by primer3.csh #Synopsis: primer3run.csh infile """ ensure that there are enough command line arguments to parse """ if len(sys.argv) < 2: print("Usage: primer3run.py INFILE"); exit(); #Convert arguments to variables INFILE = sys.argv[1] NAME = os.path.splitext(INFILE)[0] PID = os.getpid() #process id os.nice(10) subprocess.call(['primer3', '-format_output'], stdin=open(INFILE, 'r'), stdout=open(NAME + '.out', 'w')) os.nice(0) os.remove(NAME) # 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. birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, NAME + '.out']], [NAME + '.out'], True) birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, NAME + '.for']], [NAME + '.for'], True) birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, NAME + '.rev']], [NAME + '.rev'], True) if os.path.exists(NAME + '.int'): birchscript.Cleanrun([[birchenv.GDE_TEXTEDIT, NAME + '.int']], [NAME + '.int'], True) # Delete temporary files files = os.listdir("myfolder") for f in files: if not os.path.isdir(f) and str("." + PID) in f: os.remove(f) os.remove(NAME + '.in')