forked from vidjil/vidjil
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstats-logs.py
44 lines (30 loc) · 893 Bytes
/
stats-logs.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
'''Statistics on .vidjil.log files'''
import glob
from collections import defaultdict
def sort_except_fixed_order(l, fixed_order=None):
if fixed_order is None:
fixed_order = []
ll = filter(lambda x: x not in fixed_order, l)
return fixed_order + sorted(ll)
GERMLINES = [
'TRA', 'TRB', 'TRG', 'TRD',
'IGH', 'IGK', 'IGL',
'custom'
]
FILES = glob.glob('web2py/out-0*/*.vidjil.log')
print "=== Stats from %d files ===" % len(FILES)
d = defaultdict(int)
for f in FILES:
for l in open(f):
l = l.strip()
if not l:
continue
sep = '->'
if not sep in l:
continue
cause, stats = l.split(sep)
cause = cause.strip()
nb = int(stats.split()[0])
d[cause] += nb
for cause in sort_except_fixed_order(d, GERMLINES):
print " %-25s %12d" % (cause, d[cause])