Skip to content

Commit 629d550

Browse files
committed
[contacts.select_and_report_residue_neighborhood_idxs] new arg ctc_cutoff_Ang, tests (even if deprecated keep testing)
1 parent 7c8cec8 commit 629d550

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

mdciao/contacts/contacts.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def _DataFrame2NeighborhoodDF(df, res_idx):
290290
return idf
291291

292292
#TODO consider deprecating
293-
def select_and_report_residue_neighborhood_idxs(ctc_freqs, res_idxs, fragments,
293+
def select_and_report_residue_neighborhood_idxs(ctc_freqs, ctc_cutoff_Ang, res_idxs, fragments,
294294
residxs_pairs, top,
295295
ctcs_kept=5,
296296
restrict_to_resSeq=None,
@@ -310,6 +310,8 @@ def select_and_report_residue_neighborhood_idxs(ctc_freqs, res_idxs, fragments,
310310
----------
311311
ctc_freqs: iterable of floats
312312
Contact frequencies between 0 and 1
313+
ctc_cutoff_Ang : float
314+
Cutoff at which `ctc_freqs` were obtained.
313315
res_idxs: list of integers
314316
list of residue idxs for which one wants to extract the neighborhoods
315317
fragments: iterable of integers
@@ -390,8 +392,9 @@ def select_and_report_residue_neighborhood_idxs(ctc_freqs, res_idxs, fragments,
390392
print_if_v("%-6s %3.2f %8s-%-8s %5u-%-5u %7u-%-7u %5u %3.2f" % (
391393
'%u:' % (ii + 1), ifreq, top.residue(idx1), top.residue(idx2), frg1, frg2, idx1, idx2, oo, isum))
392394
if n_ctcs>0 and verbose:
393-
_contact_fraction_informer(_np.min([ii+1, len(order_mask)]), ctc_freqs[order_mask], or_frac={True: fraction,
394-
False: None}[_fraction])
395+
_contact_fraction_informer(_np.min([ii+1, len(order_mask)]), ctc_freqs[order_mask], ctc_cutoff_Ang,
396+
or_frac={True: fraction,
397+
False: None}[_fraction])
395398
else:
396399
print_if_v("No contacts here!")
397400
if interactive:

tests/test_contacts.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,14 +1270,15 @@ def setUp(self):
12701270
self.residxs, self.fragidxs = residues_from_descriptors(self.residues,
12711271
self.fragments,
12721272
self.geom.top)
1273+
self.ctc_cutoff_Ang = 3
12731274

12741275
def test_select_and_report_residue_neighborhood_idxs_just_works(self):
12751276
ctc_freqs = [1, .5]
12761277
ctc_residxs_pairs = [[0, 1], [2, 1]]
12771278

12781279
input_values = (val for val in ["1", "2"])
12791280
with mock.patch('builtins.input', lambda *x: next(input_values)): # Checking against the input 1 and 1
1280-
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freqs, self.residxs,
1281+
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freqs, self.ctc_cutoff_Ang, self.residxs,
12811282
self.fragments, ctc_residxs_pairs,
12821283
self.geom.top,
12831284
interactive=True)
@@ -1290,7 +1291,7 @@ def test_select_and_report_residue_neighborhood_idxs_select_by_resSeq(self):
12901291

12911292
input_values = (val for val in ["2"])
12921293
with mock.patch('builtins.input', lambda *x: next(input_values)): # Checking against the input 1 and 1
1293-
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freqs, self.residxs,
1294+
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freqs, self.ctc_cutoff_Ang, self.residxs,
12941295
self.fragments, ctc_residxs_pairs,
12951296
self.geom.top,
12961297
restrict_to_resSeq=[31],
@@ -1304,7 +1305,7 @@ def test_select_and_report_residue_neighborhood_idxs_hit_enter(self):
13041305

13051306
input_values = (val for val in ["", ""])
13061307
with mock.patch('builtins.input', lambda *x: next(input_values)):
1307-
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.residxs,
1308+
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.ctc_cutoff_Ang, self.residxs,
13081309
self.fragments, ctc_residxs_pairs,
13091310
self.geom.top,
13101311
interactive=True)
@@ -1313,7 +1314,7 @@ def test_select_and_report_residue_neighborhood_idxs_hit_enter(self):
13131314
def test_select_and_report_residue_neighborhood_idxs_no_interactive(self):
13141315
ctc_freq = [1.,.5]
13151316
ctc_residxs_pairs = [[0, 1], [2, 1]]
1316-
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.residxs,
1317+
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.ctc_cutoff_Ang, self.residxs,
13171318
self.fragments, ctc_residxs_pairs,
13181319
self.geom.top,
13191320
interactive=False)
@@ -1324,7 +1325,7 @@ def test_select_and_report_residue_neighborhood_idxs_no_interactive_true_ctc_per
13241325
ctc_freq = [1.,.5]
13251326
ctc_residxs_pairs = [[0, 1], [2, 1]]
13261327

1327-
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.residxs,
1328+
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.ctc_cutoff_Ang, self.residxs,
13281329
self.fragments, ctc_residxs_pairs,
13291330
self.geom.top,
13301331
ctcs_kept=.5, restrict_to_resSeq=None,
@@ -1336,7 +1337,7 @@ def test_select_and_report_residue_neighborhood_idxs_no_interactive_ctc_percenta
13361337
ctc_freq = [0, 0]
13371338
ctc_residxs_pairs = [[0, 1], [2, 1]]
13381339

1339-
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.residxs,
1340+
per_residx_ctc_idxs = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.ctc_cutoff_Ang, self.residxs,
13401341
self.fragments, ctc_residxs_pairs,
13411342
self.geom.top,
13421343
ctcs_kept=.5, restrict_to_resSeq=None,
@@ -1351,7 +1352,7 @@ def test_select_and_report_residue_neighborhood_idxs_keyboard_interrupt(self):
13511352
resname2residx, resname2fragidx = residues_from_descriptors("GLU30", self.fragments,
13521353
self.geom.top)
13531354

1354-
ctc_freq = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, resname2residx,
1355+
ctc_freq = contacts.select_and_report_residue_neighborhood_idxs(ctc_freq, self.ctc_cutoff_Ang, resname2residx,
13551356
self.fragments, per_residx_ctc_idxs,
13561357
self.geom.top,
13571358
ctcs_kept=5, restrict_to_resSeq=None,

0 commit comments

Comments
 (0)