def binding_prob(P, **params): for p, result in nanopores.collect_dict(P): pore = nanopores.get_pore(**params) rw = randomwalk.RandomWalk(pore, **params) receptorp = dict(receptor_params) receptorp["p"] = p rw.add_domain(receptor, **receptorp) print "Start Random Walk with p = %s." % p for t in rw.walk(): pass # times with binding times = rw.times[rw.bindings > 0] result.new = dict( p0=np.mean(rw.bindings > 0), a0=np.mean(rw.attempts > 0), mean_bindings=np.mean(rw.bindings), mean_attempts=np.mean(rw.attempts), std_bindings=np.std(rw.bindings), std_attempts=np.std(rw.attempts), mean_time=np.mean(times), std_time=np.std(times), mean_log_time=np.mean(np.log(times)), ) return result
def setup_rw(params): pore = nanopores.get_pore(**params) rw = randomwalk.RandomWalk(pore, **params) zrec = rw.zbot + rrec + (rw.ztop - rw.zbot - 2. * rrec) * params["zreceptor"] xrec = pore.radius_at(zrec) - distrec posrec = [xrec, 0., zrec] print "Receptor position: %s" % posrec receptor = randomwalk.Ball(posrec, rrec) # ztop 46.5 rw.add_domain(receptor, **receptor_params(params)) return rw
def setup_rw(params, **_): pore = nanopores.get_pore(**params) rw = randomwalk.RandomWalk(pore, **params) binding_params = binding_(params) if params["bind_everywhere"]: rw.add_wall_binding(**binding_params) else: r = pore.params.l3 / 2. z = -pore.params.hpore / 2. + pore.params.h4 wbind = 1. lbind = params["lbind"] bindsite = Rectangle((r, r + wbind), (z, z + lbind)) rw.add_domain(bindsite, exclusion=False, **binding_params) #rw.domains[0].__dict__.update(exclusion=True, binding=True, # bind_type="collision", eps=0., p=1., walldist=1.) return rw
def setup_default(params): pore = get_pore(**params) return RandomWalk(pore, **params)
if params.video: ani = video(rw, cyl=params.cyl, **aniparams) if params.save: save(ani, name=name) else: plt.show() else: for t in rw.walk(): pass if plot and ((not params.video) or (not params.save)): histogram(rw, a, b) #plt.figure() #hist_poisson(rw, "attempts") #plt.figure() #hist_poisson(rw, "bindings") plt.show() if __name__ == "__main__": pore = get_pore(**params) rw = RandomWalk(pore, **params) receptor = Ball([15., 0., 30.], 8.) rw.add_domain(receptor, exclusion=True, walldist=1., binding=True, eps=1., t=1.5e6, p=0.14) run(rw, name="wei")