annotate test_script_path.py @ 2:900854ec76e6 draft default tip

Uploaded
author nanette
date Tue, 20 Aug 2013 08:36:47 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
900854ec76e6 Uploaded
nanette
parents:
diff changeset
1 """
900854ec76e6 Uploaded
nanette
parents:
diff changeset
2 @summary: GO enrichment analysis (hotspots)
900854ec76e6 Uploaded
nanette
parents:
diff changeset
3 @author: nanette.coetzer@gmail.com
900854ec76e6 Uploaded
nanette
parents:
diff changeset
4 @version 5
900854ec76e6 Uploaded
nanette
parents:
diff changeset
5
900854ec76e6 Uploaded
nanette
parents:
diff changeset
6 """
900854ec76e6 Uploaded
nanette
parents:
diff changeset
7 import optparse, sys
900854ec76e6 Uploaded
nanette
parents:
diff changeset
8 import subprocess
900854ec76e6 Uploaded
nanette
parents:
diff changeset
9 import tempfile
900854ec76e6 Uploaded
nanette
parents:
diff changeset
10 import os, re
900854ec76e6 Uploaded
nanette
parents:
diff changeset
11
900854ec76e6 Uploaded
nanette
parents:
diff changeset
12 def stop_err( msg ):
900854ec76e6 Uploaded
nanette
parents:
diff changeset
13 sys.stderr.write( "%s\n" % msg )
900854ec76e6 Uploaded
nanette
parents:
diff changeset
14 sys.exit()
900854ec76e6 Uploaded
nanette
parents:
diff changeset
15
900854ec76e6 Uploaded
nanette
parents:
diff changeset
16 def __main__():
900854ec76e6 Uploaded
nanette
parents:
diff changeset
17 #Parse Command Line
900854ec76e6 Uploaded
nanette
parents:
diff changeset
18 parser = optparse.OptionParser()
900854ec76e6 Uploaded
nanette
parents:
diff changeset
19 parser.add_option("-i", "--input1", default=None, dest="input1",
900854ec76e6 Uploaded
nanette
parents:
diff changeset
20 help="genes")
900854ec76e6 Uploaded
nanette
parents:
diff changeset
21 parser.add_option("-o", "--output1", default=None, dest="output1",
900854ec76e6 Uploaded
nanette
parents:
diff changeset
22 help="star genes")
900854ec76e6 Uploaded
nanette
parents:
diff changeset
23
900854ec76e6 Uploaded
nanette
parents:
diff changeset
24 (options, args) = parser.parse_args()
900854ec76e6 Uploaded
nanette
parents:
diff changeset
25
900854ec76e6 Uploaded
nanette
parents:
diff changeset
26 try:
900854ec76e6 Uploaded
nanette
parents:
diff changeset
27 open(options.input1, "r").close()
900854ec76e6 Uploaded
nanette
parents:
diff changeset
28 except TypeError, e:
900854ec76e6 Uploaded
nanette
parents:
diff changeset
29 stop_err("You need to supply the Gene Universe file:\n" + str(e))
900854ec76e6 Uploaded
nanette
parents:
diff changeset
30 except IOError, e:
900854ec76e6 Uploaded
nanette
parents:
diff changeset
31 stop_err("Can not open the Gene Universe file:\n" + str(e))
900854ec76e6 Uploaded
nanette
parents:
diff changeset
32
900854ec76e6 Uploaded
nanette
parents:
diff changeset
33
900854ec76e6 Uploaded
nanette
parents:
diff changeset
34 ##########################################################
900854ec76e6 Uploaded
nanette
parents:
diff changeset
35
900854ec76e6 Uploaded
nanette
parents:
diff changeset
36 infile = open(options.input1,"r")
900854ec76e6 Uploaded
nanette
parents:
diff changeset
37 inlist = []
900854ec76e6 Uploaded
nanette
parents:
diff changeset
38 for line in infile:
900854ec76e6 Uploaded
nanette
parents:
diff changeset
39 inlist.append(line.strip())
900854ec76e6 Uploaded
nanette
parents:
diff changeset
40 infile.close()
900854ec76e6 Uploaded
nanette
parents:
diff changeset
41 outfile = open(options.output1,"w")
900854ec76e6 Uploaded
nanette
parents:
diff changeset
42 for l in inlist:
900854ec76e6 Uploaded
nanette
parents:
diff changeset
43 outfile.write("* "+str(l)+"\n")
900854ec76e6 Uploaded
nanette
parents:
diff changeset
44 outfile.close()
900854ec76e6 Uploaded
nanette
parents:
diff changeset
45
900854ec76e6 Uploaded
nanette
parents:
diff changeset
46 ##############################################
900854ec76e6 Uploaded
nanette
parents:
diff changeset
47
900854ec76e6 Uploaded
nanette
parents:
diff changeset
48 if __name__=="__main__":
900854ec76e6 Uploaded
nanette
parents:
diff changeset
49 __main__()