Commit eb4f9627 authored by Mathieu Giraud's avatar Mathieu Giraud

analysis.py, latex.py: compute and display stats on clusters

parent 9f88df30
......@@ -8,7 +8,8 @@ from defs import *
class Analysis(VidjilJson):
def __init__(self):
def __init__(self, data=None):
self.data = data
self.clones = {}
......@@ -28,6 +29,21 @@ class Analysis(VidjilJson):
lw_clones = set([c.d['id'] for c in lw])
return my_clones.difference(lw_clones)
def cluster_stats(self, point=0):
for cluster in self.d['clusters']:
sizes = []
for c in cluster:
try:
s = self.data[c].d["reads"][point]
sizes += [s]
except AttributeError:
print "!! missing from cluster", c
if sizes:
print "%% cluster: max is %.3f of the sum, len %d" % (float(max(sizes)) / float(sum(sizes)), len(sizes))
def info_of_clone(self, w):
if w.d['id'] in self.clones:
return self.clones[w.d['id']]
......
......@@ -37,14 +37,14 @@ def main():
# TODO: hardcoded for output of links.py
# should be more flexible
ii = 'data.vidjil/' + 'pat-' + i_short +'.analysis'
data_analysis = analysis.Analysis()
data_analysis = analysis.Analysis(data)
data_analysis.load(ii)
data_analysis.cluster_stats()
if str(data_analysis.d['samples']['run_timestamp']) == str(data.d['samples'].d['run_timestamp']):
print("%% timestamps: OK")
else:
print("%% timestamps: XXX", i, data.d['samples'].d['run_timestamp'], "instead of", data_analysis.d['samples']['run_timestamp'])
else:
data_analysis = None
......
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