def peak_calling(clus_obj):
new_cluster = {}<EOL>for cid in clus_obj.clus:<EOL><INDENT>cluster = clus_obj.clus[cid]<EOL>cluster.update()<EOL>logger.debug("<STR_LIT>" % cid)<EOL>bigger = cluster.locimaxid<EOL>if bigger in clus_obj.loci:<EOL><INDENT>s, e = min(clus_obj.loci[bigger].counts.keys()), max(clus_obj.loci[bigger].counts.keys())<EOL>scale = min(s, e)<EOL>logger.debug("<STR_LIT>" % (bigger, s, e))<EOL>dt = np.array([<NUM_LIT:0>] * (e - s + <NUM_LIT:12>))<EOL>for pos in clus_obj.loci[bigger].counts:<EOL><INDENT>ss = int(pos) - scale + <NUM_LIT:5><EOL>dt[ss] += clus_obj.loci[bigger].counts[pos]<EOL><DEDENT><DEDENT>x = np.array(range(<NUM_LIT:0>, len(dt)))<EOL>logger.debug("<STR_LIT>" % (x, dt))<EOL>if len(x) > <NUM_LIT> + <NUM_LIT:12>:<EOL><INDENT>peaks = pysen.pysenMMean(x, dt)<EOL>logger.debug(peaks)<EOL><DEDENT>else:<EOL><INDENT>peaks =  ['<STR_LIT>']<EOL><DEDENT>cluster.peaks = peaks<EOL>new_cluster[cid] = cluster<EOL><DEDENT>clus_obj.clus = new_cluster<EOL>return clus_obj<EOL>
Run peak calling inside each cluster