Skip to content

Commit 776779d

Browse files
committed
Merge branch 'standardize-atomicdistances-to-use-results' of https://github.com/charity-g/mdanalysis into standardize-atomicdistances-to-use-results
2 parents 062c598 + d4f7cab commit 776779d

File tree

5 files changed

+55
-0
lines changed

5 files changed

+55
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
"""
2+
Benchmark for HydrogenBondAnalysis
3+
"""
4+
5+
try:
6+
from MDAnalysis.analysis.hydrogenbonds.hbond_analysis import HydrogenBondAnalysis as HBA
7+
from MDAnalysisTests.datafiles import waterPSF , waterDCD
8+
except ImportError:
9+
pass
10+
11+
import MDAnalysis
12+
13+
class HydrogenBondAnalysisBenchmark:
14+
"""
15+
It tests performance of hbond.run() across different
16+
number of frames using waterPSF/waterDCD test files.
17+
"""
18+
19+
unit = "ms"
20+
timeout = 60.0
21+
params = [2, 5, 10]
22+
param_names = ["n_frames"]
23+
24+
25+
def setup(self, n_frames):
26+
u = MDAnalysis.Universe(waterPSF, waterDCD)
27+
self.hbonds = HBA(universe= u)
28+
29+
def time_run(self, n_frames):
30+
self.hbonds.run(stop = n_frames)
31+

package/CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The rules for this file:
2323

2424
Fixes
2525
* `MDAnalysis.analysis.atomicdistances.AtomicDistances` results are now consistent with expected `analysis` documentation data type = Results (Issue #4819, PR #5347) Note: This fix is backwards-incompatible.
26+
* Fix mixed-case atom types in guess_bonds (Issue #5342, PR #5343)
2627
* Fixes msd for non-linear frames, when non_linear is not explicitly
2728
provided (Issue #5100, PR #5254)
2829
* Fixes TypeError with np.int64 indexing in GSD Reader (Issue #5224)
@@ -46,6 +47,9 @@ Fixes
4647
DSSP by porting upstream PyDSSP 0.9.1 fix (Issue #4913)
4748

4849
Enhancements
50+
* Added documentation for all keyword in select_atoms() and
51+
selections.rst (Issue #5317, PR #5325)
52+
* Added HydrogenBondAnalysis benchmark for performance tracking (PR #5309)
4953
* Added `select=None` in `analysis.rms.RMSD` to perform no selection on
5054
the input `atomgroup` and `reference` (Issue #5300, PR #5296)
5155
* MOL2Parser now reads unit cell dimensions from @<TRIPOS>CRYSIN records (Issue #3341)

package/MDAnalysis/core/groups.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3289,6 +3289,10 @@ def select_atoms(
32893289
32903290
**Simple selections**
32913291
3292+
all
3293+
selects all atoms in the current group; the resulting
3294+
:class:AtomGroup is unique and sorted by index. If the group
3295+
already corresponds to Universe.atoms, it is returned unchanged.
32923296
protein, backbone, nucleic, nucleicbackbone
32933297
selects all atoms that belong to a standard set of residues;
32943298
a protein is identfied by a hard-coded set of residue names so

package/MDAnalysis/guesser/default_guesser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,9 @@ def guess_bonds(self, atoms=None, coords=None):
433433
else:
434434
atomtypes = self.guess_types(atom_types=atoms.names)
435435

436+
# vdwradii keys are uppercase, so normalize atomtypes to match
437+
atomtypes = np.char.upper(np.asarray(atomtypes, dtype=str))
438+
436439
# check that all types have a defined vdw
437440
if not all(val in vdwradii for val in set(atomtypes)):
438441
raise ValueError(

testsuite/MDAnalysisTests/guesser/test_default_guesser.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,19 @@ def test_guess_bonds_peptide():
280280
assert_equal(np.sort(u.bonds.indices, axis=0), np.sort(bonds, axis=0))
281281

282282

283+
def test_guess_bonds_mixed_case_types():
284+
"""Test that the guesser can handle mixed-case types"""
285+
n_atoms = 2
286+
# Actual positions don't matter for this test
287+
positions = np.array([[0.0, 0.0, 0.0], [2.5, 0.0, 0.0]])
288+
# Use mixed-case types
289+
topology = Topology(n_atoms, attrs=[Atomtypes(["Au", "h"])])
290+
u = mda.Universe(topology)
291+
guesser = DefaultGuesser(None)
292+
# This should not raise an error due to the mixed-case types
293+
bonds = guesser.guess_bonds(u.atoms, positions)
294+
295+
283296
@pytest.mark.parametrize(
284297
"smi",
285298
[

0 commit comments

Comments
 (0)