@@ -41,6 +41,7 @@ def merge_da(ts_d, ts_par_d, ts_a, ts_par_a):
4141# Timestamp simulation definitions
4242#
4343
44+
4445def em_rates_from_E_DA (em_rate_tot , E_values ):
4546 """Donor and Acceptor emission rates from total emission rate and E (FRET).
4647 """
@@ -49,12 +50,14 @@ def em_rates_from_E_DA(em_rate_tot, E_values):
4950 em_rates_d = em_rate_tot - em_rates_a
5051 return em_rates_d , em_rates_a
5152
53+
5254def em_rates_from_E_unique (em_rate_tot , E_values ):
5355 """Array of unique emission rates for given total emission and E (FRET).
5456 """
5557 em_rates_d , em_rates_a = em_rates_from_E_DA (em_rate_tot , E_values )
5658 return np .unique (np .hstack ([em_rates_d , em_rates_a ]))
5759
60+
5861def em_rates_from_E_DA_mix (em_rates_tot , E_values ):
5962 """D and A emission rates for two populations.
6063 """
@@ -65,6 +68,7 @@ def em_rates_from_E_DA_mix(em_rates_tot, E_values):
6568 em_rates_a .append (em_rate_ai )
6669 return em_rates_d , em_rates_a
6770
71+
6872def populations_diff_coeff (particles , populations ):
6973 """Diffusion coefficients of the two specified populations.
7074 """
@@ -83,6 +87,7 @@ def populations_diff_coeff(particles, populations):
8387 D_pop_start += counts
8488 return D_list
8589
90+
8691def populations_slices (particles , num_pop_list ):
8792 """2-tuple of slices for selection of two populations.
8893 """
@@ -142,7 +147,7 @@ def __init__(self, S, em_rates, E_values, num_particles,
142147 bg_rate_a = bg_rate_a , timeslice = timeslice ,
143148 em_rates_d = em_rates_d , em_rates_a = em_rates_a ,
144149 D_values = D_values , populations = populations ,
145- traj_filename = S .store .filepath .name )
150+ traj_filename = S .store .filepath .name )
146151
147152 for k , v in params .items ():
148153 setattr (self , k , v )
@@ -167,13 +172,14 @@ def __init__(self, S, em_rates, E_values, num_particles,
167172 Donor: {self.bg_rate_d:7,} cps
168173 Acceptor: {self.bg_rate_a:7,} cps
169174 """
175+
170176 def __str__ (self ):
171177 txt = [self .txt_header .format (self = self )]
172178 pop_params = (self .em_rates , self .E_values , self .num_particles ,
173179 self .D_values , self .populations )
174180 for p_i , (em_rate , E , num_pop , D , pop ) in enumerate (zip (* pop_params )):
175181 txt .append (self .txt_population .format (p_i = p_i + 1 ,
176- num_pop = num_pop , D = D , em_rate = em_rate , E = E , pop = pop ))
182+ num_pop = num_pop , D = D , em_rate = em_rate , E = E , pop = pop ))
177183
178184 txt .append (self .txt_background .format (self = self ))
179185 return '' .join (txt )
@@ -222,9 +228,9 @@ def run(self, rs, overwrite=True, skip_existing=False, path=None,
222228 self .hash_d = hash_ (rs .get_state ())[:6 ] # needed by merge_da()
223229 print ('%s Donor timestamps - %s' % (header , ctime ()), flush = True )
224230 self .S .simulate_timestamps_mix (
225- populations = self .populations ,
226- max_rates = self .em_rates_d ,
227- bg_rate = self .bg_rate_d ,
231+ populations = self .populations ,
232+ max_rates = self .em_rates_d ,
233+ bg_rate = self .bg_rate_d ,
228234 ** kwargs )
229235
230236 # Acceptor timestamps hash is from 'last_random_state' attribute
@@ -235,9 +241,9 @@ def run(self, rs, overwrite=True, skip_existing=False, path=None,
235241 self .hash_a = hash_ (rs .get_state ())[:6 ] # needed by merge_da()
236242 print ('\n %s Acceptor timestamps - %s' % (header , ctime ()), flush = True )
237243 self .S .simulate_timestamps_mix (
238- populations = self .populations ,
239- max_rates = self .em_rates_a ,
240- bg_rate = self .bg_rate_a ,
244+ populations = self .populations ,
245+ max_rates = self .em_rates_a ,
246+ bg_rate = self .bg_rate_a ,
241247 ** kwargs )
242248 print ('\n %s Completed. %s' % (header , ctime ()), flush = True )
243249
@@ -257,30 +263,28 @@ def run_da(self, rs, overwrite=True, skip_existing=False, path=None,
257263 print ('%s Donor + Acceptor timestamps - %s' %
258264 (header , ctime ()), flush = True )
259265 self .S .simulate_timestamps_mix_da (
260- max_rates_d = self .em_rates_d ,
261- max_rates_a = self .em_rates_a ,
262- populations = self .populations ,
263- bg_rate_d = self .bg_rate_d ,
264- bg_rate_a = self .bg_rate_a ,
266+ max_rates_d = self .em_rates_d ,
267+ max_rates_a = self .em_rates_a ,
268+ populations = self .populations ,
269+ bg_rate_d = self .bg_rate_d ,
270+ bg_rate_a = self .bg_rate_a ,
265271 ** kwargs )
266272 print ('\n %s Completed. %s' % (header , ctime ()), flush = True )
267273
268-
269274 @property
270275 def name_timestamps_d (self ):
271- names_d = self .S .timestamps_match_mix (self . em_rates_d , self . populations ,
272- self .bg_rate_d , self .hash_d )
276+ names_d = self .S .timestamps_match_mix (
277+ self . em_rates_d , self . populations , self .bg_rate_d , self .hash_d )
273278 assert len (names_d ) == 1
274279 return names_d [0 ]
275280
276281 @property
277282 def name_timestamps_a (self ):
278- names_a = self .S .timestamps_match_mix (self . em_rates_a , self . populations ,
279- self .bg_rate_a , self .hash_a )
283+ names_a = self .S .timestamps_match_mix (
284+ self . em_rates_a , self . populations , self .bg_rate_a , self .hash_a )
280285 assert len (names_a ) == 1
281286 return names_a [0 ]
282287
283-
284288 def merge_da (self ):
285289 """Merge donor and acceptor timestamps, computes `ts`, `a_ch`, `part`.
286290 """
0 commit comments