-
Notifications
You must be signed in to change notification settings - Fork 830
Add ASV benchmark for Contacts analysis #5291
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+65
−1
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d2e98ad
Added ASV benchmark for Contacts analysis
TailoredAIamarendra 4a8bbfb
Add ASV benchmarks for MDAnalysis.lib core kernels
TailoredAIamarendra 57398bc
Add ASV benchmarks for Contacts Analysis
Amarendra22 fb61c65
Add ASV benchmarks for Contacts Analysis
Amarendra22 d493eee
Add ASV benchmarks for Contacts Analysis
Amarendra22 9f39fed
Fix AUTHORS and CHANGELOG ordering for contacts benchmark PR
Amarendra22 f2c5b58
Merge branch 'develop' into benchmark-contacts
Amarendra22 b1f3e3e
Remove unrelated files from contacts benchmark PR
Amarendra22 f86ba57
Merge branch 'develop' into benchmark-contacts
orbeckst File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import numpy as np | ||
| from MDAnalysis.lib.distances import calc_dihedrals | ||
|
|
||
|
|
||
| class DihedralBench: | ||
|
|
||
| params = [100, 500, 1000, 10000] | ||
| param_names = ["n_dihedrals"] | ||
|
|
||
| def setup(self, n_dihedrals): | ||
| self.coords = np.random.random((n_dihedrals, 4, 3)) | ||
|
|
||
| def time_calc_dihedrals(self, n_dihedrals): | ||
| calc_dihedrals( | ||
| self.coords[:,0], | ||
| self.coords[:,1], | ||
| self.coords[:,2], | ||
| self.coords[:,3] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import numpy as np | ||
| from MDAnalysis.lib.distances import distance_array, self_distance_array | ||
|
|
||
|
|
||
| class DistanceArrayBench: | ||
|
|
||
| params = [100, 500, 1000, 10000] | ||
| param_names = ["n_atoms"] | ||
|
|
||
| def setup(self, n_atoms): | ||
| self.coords1 = np.random.random((n_atoms, 3)) | ||
| self.coords2 = np.random.random((n_atoms, 3)) | ||
|
|
||
| def time_distance_array(self, n_atoms): | ||
| distance_array(self.coords1, self.coords2) | ||
|
|
||
| class SelfDistanceArrayBench: | ||
|
|
||
| params = [100, 500, 1000, 10000] | ||
| param_names = ["n_atoms"] | ||
|
|
||
| def setup(self, n_atoms): | ||
| self.coords = np.random.random((n_atoms, 3)) | ||
|
|
||
| def time_self_distance_array(self, n_atoms): | ||
| self_distance_array(self.coords) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import numpy as np | ||
| from MDAnalysis.lib.nsgrid import FastNS | ||
|
|
||
|
|
||
| class FastNSBench: | ||
|
|
||
| params = [100, 500, 1000, 10000] | ||
| param_names = ["n_atoms"] | ||
|
|
||
| def setup(self, n_atoms): | ||
| self.coords = np.random.random((n_atoms, 3)).astype(np.float32) | ||
| self.box = np.array([10, 10, 10, 90, 90, 90], dtype=np.float32) | ||
|
|
||
| def time_fastns(self, n_atoms): | ||
| ns = FastNS(5.0, self.coords, self.box) | ||
| ns.self_search() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| import numpy as np | ||
| from MDAnalysis.lib.NeighborSearch import AtomNeighborSearch | ||
| import MDAnalysis as mda | ||
| from MDAnalysisTests.datafiles import PSF, DCD | ||
|
|
||
|
|
||
| class NeighborSearchBench: | ||
|
|
||
| def setup(self): | ||
| self.u = mda.Universe(PSF, DCD) | ||
| self.atoms = self.u.select_atoms("protein") | ||
| self.ns = AtomNeighborSearch(self.atoms) | ||
|
|
||
| def time_neighbor_search(self): | ||
| self.ns.search(self.atoms, 5.0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.