Mercurial > repos > nanette > nanettetest2
comparison test_script_path.py @ 0:a96725b3ee9d draft default tip
Uploaded
| author | nanette |
|---|---|
| date | Wed, 21 Aug 2013 04:23:05 -0400 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a96725b3ee9d |
|---|---|
| 1 """ | |
| 2 @summary: GO enrichment analysis (hotspots) | |
| 3 @author: nanette.coetzer@gmail.com | |
| 4 @version 5 | |
| 5 | |
| 6 """ | |
| 7 import optparse, sys | |
| 8 import subprocess | |
| 9 import tempfile | |
| 10 import os, re | |
| 11 | |
| 12 def stop_err( msg ): | |
| 13 sys.stderr.write( "%s\n" % msg ) | |
| 14 sys.exit() | |
| 15 | |
| 16 def __main__(): | |
| 17 #Parse Command Line | |
| 18 parser = optparse.OptionParser() | |
| 19 parser.add_option("-i", "--input1", default=None, dest="input1", | |
| 20 help="genes") | |
| 21 parser.add_option("-o", "--output1", default=None, dest="output1", | |
| 22 help="star genes") | |
| 23 parser.add_option("-m", "--myflag", default=None, dest="myflag", | |
| 24 help="star genes") | |
| 25 (options, args) = parser.parse_args() | |
| 26 | |
| 27 try: | |
| 28 open(options.input1, "r").close() | |
| 29 except TypeError, e: | |
| 30 stop_err("You need to supply the Gene Universe file:\n" + str(e)) | |
| 31 except IOError, e: | |
| 32 stop_err("Can not open the Gene Universe file:\n" + str(e)) | |
| 33 | |
| 34 | |
| 35 ########################################################## | |
| 36 | |
| 37 infile = open(options.input1,"r") | |
| 38 inlist = [] | |
| 39 for line in infile: | |
| 40 inlist.append(line.strip()) | |
| 41 infile.close() | |
| 42 outfile = open(options.output1,"w") | |
| 43 for l in inlist: | |
| 44 outfile.write("* "+str(l)+"\n") | |
| 45 outfile.write(options.myflag + "\n") | |
| 46 outfile.close() | |
| 47 | |
| 48 ############################################## | |
| 49 | |
| 50 if __name__=="__main__": | |
| 51 __main__() |
