def mapped_reads_from_chip_ps_np(ps,mean_frag_length,cells=10000): G = len(ps) genome = np.zeros(G) lamb = 1.0/mean_frag_length for cell in (xrange(cells)): print cell config = rfd_xs_np(ps) config_len = len(config) idx = 0 l = 0 r = 0 while l < G and idx < config_len: #print l,r,idx,config[idx] l,r = r,r+nprand.geometric(lamb) if l <= config[idx] < r: #print "got hit" genome[l:r] += 1 while idx < config_len and config[idx] < r: idx += 1 return genome
def chip_ps_np(ps,mean_frag_length,cells=10000,verbose=False): """Do a chip seq experiment given the distribution ps""" w = 10 G = len(ps)# + w - 1 #XXX HACK cell_iterator = verbose_gen(xrange(cells),modulus=1000) if verbose else xrange(cells) return concat(chip(G,rfd_xs_np(ps),mean_frag_length) for cell in cell_iterator)