Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions benchmarks/benchmarks/analysis/contacts.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import MDAnalysis as mda
from MDAnalysis.analysis import contacts
from MDAnalysisTests.datafiles import PSF, DCD


class ContactsBench(object):
"""
Benchmarks for MDAnalysis.analysis.contacts.Contacts
"""

# Parameter combinations tested in the benchmark.
# radius : cutoff distance used to define a contact
# method : algorithm used to compute contacts
# pbc : whether periodic boundary conditions are applied
params = [
[4.5, 6.0],
["hard_cut", "soft_cut", "radius_cut"],
[True, False],
]

# Names corresponding to the parameters above
param_names = ["radius", "method", "pbc"]

def setup(self, radius, method, pbc):
"""
Prepare the Universe and contact analysis object
for benchmarking.
"""

# Load test trajectory
self.u = mda.Universe(PSF, DCD)

# Define atom selections
self.sel1 = "protein"
self.sel2 = "name CA"

# Create atom groups from the selections
g1 = self.u.select_atoms(self.sel1)
g2 = self.u.select_atoms(self.sel2)

# Initialize the Contacts analysis
# select : atom selection strings
# refgroup : reference atom groups used for contacts
# radius : contact cutoff distance
# method : contact calculation method
# pbc : periodic boundary conditions flag
self.analysis = contacts.Contacts(
self.u,
select=(self.sel1, self.sel2),
refgroup=(g1, g2),
radius=radius,
method=method,
pbc=pbc,
)

def time_contacts_run(self, radius, method, pbc):
"""
Benchmark execution of Contacts.run()
over the full trajectory.
"""

self.analysis.run()
1 change: 1 addition & 0 deletions package/AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ Chronological list of authors
- Kunj Sinha
- Ayush Agarwal
- Parth Uppal
- Amarendra Mohan

External code
-------------
Expand Down
1 change: 1 addition & 0 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ Fixes
DSSP by porting upstream PyDSSP 0.9.1 fix (Issue #4913)

Enhancements
* Added ASV benchmark for `MDAnalysis.analysis.contacts` (PR #5291)
* MOL2Parser now reads unit cell dimensions from @<TRIPOS>CRYSIN records (Issue #3341)
* Reduces duplication of code in _apply() function (Issue #5247, PR #5294)
* Added new top-level `MDAnalysis.fetch` module (PR #4943)
Expand Down
Loading