Commit c8846155 authored by mercierc's avatar mercierc

obi stats: various fixes and improvements

parent cb533818
......@@ -154,7 +154,7 @@ def run(config):
else :
taxo = None
statistics = set(config['stats']['minimum']) | set(config['stats']['maximum']) | set(config['stats']['mean'])
statistics = set(config['stats']['minimum']) | set(config['stats']['maximum']) | set(config['stats']['mean']) | set(config['stats']['var']) | set(config['stats']['sd'])
total = 0
catcount={}
totcount={}
......@@ -195,7 +195,7 @@ def run(config):
except KeyError:
totcount[category]=totcount.get(category,0)+1
for var in statistics:
if var in line:
if var in line and line[var] is not None:
v = line[var]
if var not in values:
values[var]={}
......@@ -238,14 +238,34 @@ def run(config):
else:
sdvar= "%s"
hcat = "\t".join([pcat % x for x in config['stats']['categories']]) + \
"\t".join([minvar % x for x in config['stats']['minimum']]) + \
"\t".join([maxvar % x for x in config['stats']['maximum']]) + \
"\t".join([meanvar % x for x in config['stats']['mean']]) + \
"\t".join([varvar % x for x in config['stats']['var']]) + \
"\t".join([sdvar % x for x in config['stats']['sd']]) + \
"count\t" + \
"total"
hcat = ""
for x in config['stats']['categories']:
hcat += pcat % x
hcat += "\t"
for x in config['stats']['minimum']:
hcat += minvar % x
hcat += "\t"
for x in config['stats']['maximum']:
hcat += maxvar % x
hcat += "\t"
for x in config['stats']['mean']:
hcat += meanvar % x
hcat += "\t"
for x in config['stats']['var']:
hcat += varvar % x
hcat += "\t"
for x in config['stats']['sd']:
hcat += sdvar % x
hcat += "\t"
hcat += "count\ttotal"
print(hcat)
sorted_stats = sorted(catcount.items(), key = lambda kv:(totcount[kv[0]]), reverse=True)
for i in range(len(sorted_stats)):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment