-
Notifications
You must be signed in to change notification settings - Fork 9
/
monitorScreenlog.py
48 lines (42 loc) · 1.26 KB
/
monitorScreenlog.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
38
39
40
41
42
43
44
45
46
47
48
import sys, os
import pandas as pd
pd.set_option('precision', 4)
EVAL_JUST_LAST_STEP=False
SKIP_LOWERCASE=True
def main(fname):
pdbsScoresDict={}
nextLineIsGood=False
colNames= None
with open(fname) as f:
for line in f:
# print(line)
if "pdb auc_pair " in line:
colNames= line.split()
nextLineIsGood=True
continue
if nextLineIsGood:
dataLine= line.split()
pdbId= dataLine[0].split(".")[0]
if EVAL_JUST_LAST_STEP and "@" in pdbId:
nextLineIsGood=False
continue
if SKIP_LOWERCASE and pdbId.islower(): continue
nextLineIsGood=False
continue
dataLine= [dataLine[0]]+ [float(elem) for elem in dataLine[1:]]
pdbsScoresDict[dataLine[0]]= dataLine
nextLineIsGood=False
resDf= pd.DataFrame.from_records(list(pdbsScoresDict.values()))
resDf.columns= colNames
resDf.sort_values("pdb", inplace=True)
means= resDf.mean(axis=0)
resDf= resDf.append( resDf.ix[resDf.shape[0]-1,:],ignore_index=True )
resDf.ix[resDf.shape[0]-1,0]= "mean"
resDf.ix[resDf.shape[0]-1, 1:]= means
print(resDf.to_string(index=False))
if __name__=="__main__":
if len(sys.argv)==2:
fname=sys.argv[1]
else:
fname= "screenlog.0"
main(fname)