Mercurial > repos > nanette > nanettetest3
changeset 8:a303f3ffa153 draft default tip
Uploaded
author | nanette |
---|---|
date | Wed, 21 Aug 2013 07:05:54 -0400 |
parents | b41fc3e15949 |
children | |
files | test_script_path.py test_script_path.xml |
diffstat | 2 files changed, 30 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/test_script_path.py Wed Aug 21 05:56:49 2013 -0400 +++ b/test_script_path.py Wed Aug 21 07:05:54 2013 -0400 @@ -20,8 +20,11 @@ help="genes") parser.add_option("-o", "--output1", default=None, dest="output1", help="star genes") + parser.add_option("-p", "--output2", default=None, dest="output2", + help="plot") parser.add_option("-m", "--myflag", default=None, dest="myflag", help="star genes") + (options, args) = parser.parse_args() try: @@ -47,6 +50,31 @@ outfile.write("--- TEST ---" + "\n") outfile.close() + ########################################################## + + # Create temp direcotry + tempdir = tempfile.mkdtemp() + fixdir = options.myflag + + # copy INPUT file to the temp directory + # create R script => save in temp directory + # generate new header + new_script = open(tempdir+"/new_script.r","w") + header = "setwd(\"%s\")" %tempdir + new_script.write(header+"\n") + + # add script body + script = open(fixdir+"/r_plot.r","r") + for line in script: + new_script.write(line.strip()+"\n") + new_script.close() + + # run R script from temp directory + s = "R CMD BATCH %s/new_script.r out.txt" %tempdir + subprocess.call(s, shell=True) + + os.system("mv %s/plot.pdf %s" %(tempdir,options.output2)) + ############################################## if __name__=="__main__":
--- a/test_script_path.xml Wed Aug 21 05:56:49 2013 -0400 +++ b/test_script_path.xml Wed Aug 21 07:05:54 2013 -0400 @@ -5,7 +5,7 @@ <requirement type="set_environment">SCRIPT_PATH</requirement> </requirements> <command interpreter="python"> - test_script_path.py --input1 $input1 --output1 $output1 --myflag \$SCRIPT_PATH + test_script_path.py --input1 $input1 --output1 $output1 --output2 $output2 --myflag \$SCRIPT_PATH </command> <inputs> <param label="Gene Universe file" name="input1" type="data" format="tabular" help="A tabular file with the full set of genes from the study (gene universe)"></param> @@ -13,6 +13,7 @@ </inputs> <outputs> <data format="tabular" name="output1" /> + <data format="pdf" name="output2" /> </outputs> <requirements> </requirements>