@@ -171,8 +171,8 @@ def universe():
171
171
return mda .Universe (PSF , DCD )
172
172
173
173
def _run_Contacts (
174
- self , universe ,
175
- start = None , stop = None , step = None , ** kwargs
174
+ self , universe , client_Contacts , start = None ,
175
+ stop = None , step = None , ** kwargs
176
176
):
177
177
acidic = universe .select_atoms (self .sel_acidic )
178
178
basic = universe .select_atoms (self .sel_basic )
@@ -181,7 +181,8 @@ def _run_Contacts(
181
181
select = (self .sel_acidic , self .sel_basic ),
182
182
refgroup = (acidic , basic ),
183
183
radius = 6.0 ,
184
- ** kwargs ).run (start = start , stop = stop , step = step )
184
+ ** kwargs
185
+ ).run (** client_Contacts , start = start , stop = stop , step = step )
185
186
186
187
@pytest .mark .parametrize ("seltxt" , [sel_acidic , sel_basic ])
187
188
def test_select_valid_types (self , universe , seltxt ):
@@ -195,7 +196,7 @@ def test_select_valid_types(self, universe, seltxt):
195
196
196
197
assert ag_from_string == ag_from_ag
197
198
198
- def test_contacts_selections (self , universe ):
199
+ def test_contacts_selections (self , universe , client_Contacts ):
199
200
"""Test if Contacts can take both string and AtomGroup as selections.
200
201
"""
201
202
aga = universe .select_atoms (self .sel_acidic )
@@ -210,8 +211,8 @@ def test_contacts_selections(self, universe):
210
211
refgroup = (aga , agb )
211
212
)
212
213
213
- cag .run ()
214
- csel .run ()
214
+ cag .run (** client_Contacts )
215
+ csel .run (** client_Contacts )
215
216
216
217
assert cag .grA == csel .grA
217
218
assert cag .grB == csel .grB
@@ -228,26 +229,31 @@ def test_select_wrong_types(self, universe, ag):
228
229
) as te :
229
230
contacts .Contacts ._get_atomgroup (universe , ag )
230
231
231
- def test_startframe (self , universe ):
232
+ def test_startframe (self , universe , client_Contacts ):
232
233
"""test_startframe: TestContactAnalysis1: start frame set to 0 (resolution of
233
234
Issue #624)
234
235
235
236
"""
236
- CA1 = self ._run_Contacts (universe )
237
+ CA1 = self ._run_Contacts (universe , client_Contacts = client_Contacts )
237
238
assert len (CA1 .results .timeseries ) == universe .trajectory .n_frames
238
239
239
- def test_end_zero (self , universe ):
240
+ def test_end_zero (self , universe , client_Contacts ):
240
241
"""test_end_zero: TestContactAnalysis1: stop frame 0 is not ignored"""
241
- CA1 = self ._run_Contacts (universe , stop = 0 )
242
+ CA1 = self ._run_Contacts (
243
+ universe , client_Contacts = client_Contacts , stop = 0
244
+ )
242
245
assert len (CA1 .results .timeseries ) == 0
243
246
244
- def test_slicing (self , universe ):
247
+ def test_slicing (self , universe , client_Contacts ):
245
248
start , stop , step = 10 , 30 , 5
246
- CA1 = self ._run_Contacts (universe , start = start , stop = stop , step = step )
249
+ CA1 = self ._run_Contacts (
250
+ universe , client_Contacts = client_Contacts ,
251
+ start = start , stop = stop , step = step
252
+ )
247
253
frames = np .arange (universe .trajectory .n_frames )[start :stop :step ]
248
254
assert len (CA1 .results .timeseries ) == len (frames )
249
255
250
- def test_villin_folded (self ):
256
+ def test_villin_folded (self , client_Contacts ):
251
257
# one folded, one unfolded
252
258
f = mda .Universe (contacts_villin_folded )
253
259
u = mda .Universe (contacts_villin_unfolded )
@@ -259,12 +265,12 @@ def test_villin_folded(self):
259
265
select = (sel , sel ),
260
266
refgroup = (grF , grF ),
261
267
method = "soft_cut" )
262
- q .run ()
268
+ q .run (** client_Contacts )
263
269
264
270
results = soft_cut (f , u , sel , sel )
265
271
assert_allclose (q .results .timeseries [:, 1 ], results [:, 1 ], rtol = 0 , atol = 1.5e-7 )
266
272
267
- def test_villin_unfolded (self ):
273
+ def test_villin_unfolded (self , client_Contacts ):
268
274
# both folded
269
275
f = mda .Universe (contacts_villin_folded )
270
276
u = mda .Universe (contacts_villin_folded )
@@ -276,13 +282,13 @@ def test_villin_unfolded(self):
276
282
select = (sel , sel ),
277
283
refgroup = (grF , grF ),
278
284
method = "soft_cut" )
279
- q .run ()
285
+ q .run (** client_Contacts )
280
286
281
287
results = soft_cut (f , u , sel , sel )
282
288
assert_allclose (q .results .timeseries [:, 1 ], results [:, 1 ], rtol = 0 , atol = 1.5e-7 )
283
289
284
- def test_hard_cut_method (self , universe ):
285
- ca = self ._run_Contacts (universe )
290
+ def test_hard_cut_method (self , universe , client_Contacts ):
291
+ ca = self ._run_Contacts (universe , client_Contacts = client_Contacts )
286
292
expected = [1. , 0.58252427 , 0.52427184 , 0.55339806 , 0.54368932 ,
287
293
0.54368932 , 0.51456311 , 0.46601942 , 0.48543689 , 0.52427184 ,
288
294
0.46601942 , 0.58252427 , 0.51456311 , 0.48543689 , 0.48543689 ,
@@ -306,7 +312,7 @@ def test_hard_cut_method(self, universe):
306
312
assert len (ca .results .timeseries ) == len (expected )
307
313
assert_allclose (ca .results .timeseries [:, 1 ], expected , rtol = 0 , atol = 1.5e-7 )
308
314
309
- def test_radius_cut_method (self , universe ):
315
+ def test_radius_cut_method (self , universe , client_Contacts ):
310
316
acidic = universe .select_atoms (self .sel_acidic )
311
317
basic = universe .select_atoms (self .sel_basic )
312
318
r = contacts .distance_array (acidic .positions , basic .positions )
@@ -316,15 +322,20 @@ def test_radius_cut_method(self, universe):
316
322
r = contacts .distance_array (acidic .positions , basic .positions )
317
323
expected .append (contacts .radius_cut_q (r [initial_contacts ], None , radius = 6.0 ))
318
324
319
- ca = self ._run_Contacts (universe , method = 'radius_cut' )
325
+ ca = self ._run_Contacts (
326
+ universe , client_Contacts = client_Contacts , method = "radius_cut"
327
+ )
320
328
assert_array_equal (ca .results .timeseries [:, 1 ], expected )
321
329
322
330
@staticmethod
323
331
def _is_any_closer (r , r0 , dist = 2.5 ):
324
332
return np .any (r < dist )
325
333
326
- def test_own_method (self , universe ):
327
- ca = self ._run_Contacts (universe , method = self ._is_any_closer )
334
+ def test_own_method (self , universe , client_Contacts ):
335
+ ca = self ._run_Contacts (
336
+ universe , client_Contacts = client_Contacts ,
337
+ method = self ._is_any_closer
338
+ )
328
339
329
340
bound_expected = [1. , 1. , 0. , 1. , 1. , 0. , 0. , 1. , 0. , 1. , 1. , 0. , 0. ,
330
341
1. , 0. , 0. , 0. , 0. , 1. , 1. , 0. , 0. , 0. , 1. , 0. , 1. ,
@@ -340,21 +351,28 @@ def test_own_method(self, universe):
340
351
def _weird_own_method (r , r0 ):
341
352
return 'aaa'
342
353
343
- def test_own_method_no_array_cast (self , universe ):
354
+ def test_own_method_no_array_cast (self , universe , client_Contacts ):
344
355
with pytest .raises (ValueError ):
345
- self ._run_Contacts (universe , method = self ._weird_own_method , stop = 2 )
346
-
347
- def test_non_callable_method (self , universe ):
356
+ self ._run_Contacts (
357
+ universe ,
358
+ client_Contacts = client_Contacts ,
359
+ method = self ._weird_own_method ,
360
+ stop = 2 ,
361
+ )
362
+
363
+ def test_non_callable_method (self , universe , client_Contacts ):
348
364
with pytest .raises (ValueError ):
349
- self ._run_Contacts (universe , method = 2 , stop = 2 )
365
+ self ._run_Contacts (
366
+ universe , client_Contacts = client_Contacts , method = 2 , stop = 2
367
+ )
350
368
351
369
@pytest .mark .parametrize ("pbc,expected" , [
352
370
(True , [1. , 0.43138152 , 0.3989021 , 0.43824337 , 0.41948765 ,
353
371
0.42223239 , 0.41354071 , 0.43641354 , 0.41216834 , 0.38334858 ]),
354
372
(False , [1. , 0.42327791 , 0.39192399 , 0.40950119 , 0.40902613 ,
355
373
0.42470309 , 0.41140143 , 0.42897862 , 0.41472684 , 0.38574822 ])
356
374
])
357
- def test_distance_box (self , pbc , expected ):
375
+ def test_distance_box (self , pbc , expected , client_Contacts ):
358
376
u = mda .Universe (TPR , XTC )
359
377
sel_basic = "(resname ARG LYS)"
360
378
sel_acidic = "(resname ASP GLU)"
@@ -363,13 +381,15 @@ def test_distance_box(self, pbc, expected):
363
381
364
382
r = contacts .Contacts (u , select = (sel_acidic , sel_basic ),
365
383
refgroup = (acidic , basic ), radius = 6.0 , pbc = pbc )
366
- r .run ()
384
+ r .run (** client_Contacts )
367
385
assert_allclose (r .results .timeseries [:, 1 ], expected ,rtol = 0 , atol = 1.5e-7 )
368
386
369
- def test_warn_deprecated_attr (self , universe ):
387
+ def test_warn_deprecated_attr (self , universe , client_Contacts ):
370
388
"""Test for warning message emitted on using deprecated `timeseries`
371
389
attribute"""
372
- CA1 = self ._run_Contacts (universe , stop = 1 )
390
+ CA1 = self ._run_Contacts (
391
+ universe , client_Contacts = client_Contacts , stop = 1
392
+ )
373
393
wmsg = "The `timeseries` attribute was deprecated in MDAnalysis"
374
394
with pytest .warns (DeprecationWarning , match = wmsg ):
375
395
assert_equal (CA1 .timeseries , CA1 .results .timeseries )
@@ -385,10 +405,11 @@ def test_n_initial_contacts(self, datafiles, expected):
385
405
r = contacts .Contacts (u , select = select , refgroup = refgroup )
386
406
assert_equal (r .n_initial_contacts , expected )
387
407
388
- def test_q1q2 ():
408
+
409
+ def test_q1q2 (client_Contacts ):
389
410
u = mda .Universe (PSF , DCD )
390
411
q1q2 = contacts .q1q2 (u , 'name CA' , radius = 8 )
391
- q1q2 .run ()
412
+ q1q2 .run (** client_Contacts )
392
413
393
414
q1_expected = [1. , 0.98092643 , 0.97366031 , 0.97275204 , 0.97002725 ,
394
415
0.97275204 , 0.96276113 , 0.96730245 , 0.9582198 , 0.96185286 ,
0 commit comments