Skip to content

Replace the distance search of finding hydrogens with a dictionary lookup#2519

Merged
richardjgowers merged 3 commits intoMDAnalysis:developfrom
xiki-tempula:wba_selection
Feb 15, 2020
Merged

Replace the distance search of finding hydrogens with a dictionary lookup#2519
richardjgowers merged 3 commits intoMDAnalysis:developfrom
xiki-tempula:wba_selection

Conversation

@xiki-tempula
Copy link
Contributor

@xiki-tempula xiki-tempula commented Feb 9, 2020

Changes made in this Pull Request:

In the original water bridge analysis implementation, the hydrogen associated with the hydrogen bond donor heavy atom were looked up through a distance search, which is repeated every single frame. This PR attempts to generate the dictionary of hydrogen bond donor heavy atom vs hydrogen pair in the first frame and do a dictionary lookup for the rest of the frames.

This PR should reduce the processing time for all the rest of the frames at the cost of increasing the time for the first frame. This PR should also reduce the computational overhead for turning on the option of update_selection .

Here are the benchmark results.

Frames new update_selection=False (sec) old update_selection=False (sec) new update_selection=True (sec) old update_selection=True (sec)
1 12.0 1.9 10.0 2.5
10 13.7 7.8 14.0 13.4
100 37.9 63.3 59.7 119.0
1000 288.6 649.6 478.7 1137.1

Combined with #2480, the water bridge analysis is now 4X faster than the original implementation and I felt there is probably little room for performance improvement now.

PR Checklist

  • Tests?
  • Docs?
  • CHANGELOG updated?
  • Issue raised/referenced?

@codecov
Copy link

codecov bot commented Feb 9, 2020

Codecov Report

Merging #2519 into develop will decrease coverage by 0.08%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2519      +/-   ##
===========================================
- Coverage    90.42%   90.33%   -0.09%     
===========================================
  Files          170      170              
  Lines        23145    23156      +11     
  Branches      2988     2991       +3     
===========================================
- Hits         20928    20919       -9     
- Misses        1620     1634      +14     
- Partials       597      603       +6
Impacted Files Coverage Δ
...age/MDAnalysis/analysis/hbonds/wbridge_analysis.py 92.89% <100%> (+0.2%) ⬆️
package/MDAnalysis/analysis/base.py 93.57% <0%> (-3.67%) ⬇️
package/MDAnalysis/coordinates/TRZ.py 82.15% <0%> (-1.49%) ⬇️
package/MDAnalysis/analysis/lineardensity.py 81.81% <0%> (-1.3%) ⬇️
package/MDAnalysis/lib/util.py 87.39% <0%> (-0.88%) ⬇️
package/MDAnalysis/analysis/gnm.py 95.27% <0%> (-0.79%) ⬇️
package/MDAnalysis/lib/formats/libdcd.pyx 78.31% <0%> (-0.65%) ⬇️
package/MDAnalysis/core/topologyobjects.py 97.51% <0%> (-0.36%) ⬇️
package/MDAnalysis/analysis/waterdynamics.py 82.5% <0%> (-0.22%) ⬇️
package/MDAnalysis/core/groups.py 98.15% <0%> (-0.1%) ⬇️
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 121ec06...2791289. Read the comment docs.

@xiki-tempula xiki-tempula changed the title [WIP] Replace the distance search of finding hydrogens with a dictionary lookup Replace the distance search of finding hydrogens with a dictionary lookup Feb 10, 2020
if atom.name in self.donors:
self._residue_dict[residue.resname][atom.name].update(self._get_bonded_hydrogens(atom).names)

def _update_donor_h(self, atom_ix, h_donors, donors_h):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this needs a docstring, it's not clear who/what/where atom_ix is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants