forked from ShiuLab/GO-term-enrichment
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathparse_enrichment_get_sig.py
executable file
·37 lines (31 loc) · 1 KB
/
parse_enrichment_get_sig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sys, os, math, operator
#Default q
qval= 0.05
for i in range (1,len(sys.argv),2):
if sys.argv[i] == '-in':
fisherfile = sys.argv[i+1] # pqvalue file (output of fishers- .pqvalue)
if sys.argv[i] == '-q':
qval= float(sys.argv[i+1])
fisherfile1= open(fisherfile,'r')
out = str(fisherfile)
oup=open("%s.sig_%.2f" % (out,qval) ,"w" )
oup.write("file\tpathway\tcluster\tpos-pos\tpos-neg\tneg-pos\tneg-neg\tenrich\tpval\tqval\n")
feature_list=[]
#dict_neg={}
for line in fisherfile1:
x = line.strip().split('\t')
a = x[5]
q = float(x[7])
feature = str(x[0])
if feature not in feature_list:
feature_list.append(feature)
if a == '+' and q <= qval:
xstr= "\t".join(x)
oup.write("%s\n" % (xstr))
else:
pass
# dict_pos_sorted = sorted(dict_pos.items(), key=operator.itemgetter(1), reverse=True) #sorts based on values
# for key in dict_pos_sorted:
# data= dict_pos_sorted[key]
# datastr= "\t".join(data)
# oup.write("%s\t%s\n" % (key, datastr))