Skip to content

Commit

Permalink
Fix hbond cannot deal with atoms too far (PR #1325)
Browse files Browse the repository at this point in the history
* add check that s2 selection is empty
* add test
* add change log entry
  • Loading branch information
xiki-tempula authored and richardjgowers committed May 1, 2017
1 parent 5c6700b commit d5bc8f5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The rules for this file:

------------------------------------------------------------------------------


mm/dd/17 utkbansal, kain88-de, xiki-tempula, kaplajon, wouterboomsma


Expand All @@ -33,6 +34,8 @@ Fixes
(issue #1324)
* Fixed bug "no molecules in water selection" in waterdynamics analysis
module.
* Fix hbond_analysis cannot deal with Universe where no two atoms are with 3A.
(PR #1325)

Changes
* Enable various pylint warnings to increase python 3 compatibility
Expand Down
2 changes: 2 additions & 0 deletions package/MDAnalysis/analysis/hbonds/hbond_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,6 +823,8 @@ def _update_selection_2(self):
self._s2_donors = {}
self._s2_donors_h = {}
self._s2_acceptors = {}
if not self._s2:
return None
if self.selection1_type in ('donor', 'both'):
self._s2_acceptors = self._s2.select_atoms(
'name {0}'.format(' '.join(self.acceptors)))
Expand Down
12 changes: 12 additions & 0 deletions testsuite/MDAnalysisTests/analysis/test_hbonds.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

import itertools
import warnings
from six import StringIO

from MDAnalysisTests.datafiles import PDB_helix, GRO, XTC
# For type guessing:
Expand Down Expand Up @@ -87,6 +88,17 @@ def test_generate_table(self):
assert_array_equal(h.table.donor_resid, self.values['donor_resid'])
assert_array_equal(h.table.acceptor_resnm, self.values['acceptor_resnm'])

@staticmethod
def test_atoms_too_far():
pdb = '''
ATOM 1 N LEU 1 32.310 13.778 14.372 1.00 0.00 SYST N 0
ATOM 2 OW SOL 2 3.024 4.456 4.147 1.00 0.00 SYST H 0'''

u = MDAnalysis.Universe(StringIO(pdb), format="pdb")
h = MDAnalysis.analysis.hbonds.HydrogenBondAnalysis(u, 'resname SOL', 'protein')
h.run(verbose=False)
assert_equal(h.timeseries, [[]])

@staticmethod
def test_true_traj():
u = MDAnalysis.Universe(GRO, XTC)
Expand Down

0 comments on commit d5bc8f5

Please sign in to comment.