Skip to content

Commit

Permalink
Integrate reviewer comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jaclark5 committed Nov 5, 2022
1 parent 049c0ee commit f7185a1
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
6 changes: 4 additions & 2 deletions package/CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The rules for this file:
* 2.4.0

Fixes
* Update hbond analysis doc string to use exclusive bound language (#3847)
* LAMMPSDump Reader translates the box to the origin (#3741)
* hbond analysis: access hbonds results through new results member in count_by_ids() and count_by_type()
* Added isolayer selection method (Issue #3845)
Expand All @@ -31,9 +32,10 @@ Fixes
(e.g. bonds, angles) (PR #3779).

Enhancements
* Update hbond analysis doc string to use exclusive bound language (#3847)
* Added ability for hbond anaylsis to use types when resnames aren't there
* Added ability for hbond analysis to use types when resnames are not
present (#3847)
* Added explanatory warnings when hbond analysis doesn't find any hbonds
(#3847)
* LAMMPSDump Reader optionally unwraps trajectories with image flags upon
loading (#3843
* LAMMPSDump Reader now imports velocities and forces (#3843)
Expand Down
44 changes: 31 additions & 13 deletions package/MDAnalysis/analysis/hydrogenbonds/hbond_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,8 @@
protein-water and protein-protein hydrogen bonds will be found, but
no water-water hydrogen bonds.
One can now also define hydrogen bonds with atom types::
One can also define hydrogen bonds with atom types::
import MDAnalysis
from MDAnalysis.analysis.hydrogenbonds.hbond_analysis import HydrogenBondAnalysis as HBA
hbonds = HBA(
universe=u,
Expand Down Expand Up @@ -384,13 +383,11 @@ def guess_hydrogens(self,
):
"""Guesses which hydrogen atoms should be used in the analysis.
Hydrogen selections may be achieved with either a resname, atom
name combination, or when those are absent, atom types.
Parameters
----------
select: str (optional)
Selection string for atom group from which hydrogens will be identified.
:doc:`Selection string </documentation_pages/selections>` for atom group from which hydrogens
will be identified. (e.g., ``(resname X and name H1)`` or ``type 2``)
max_mass: float (optional)
The mass of a hydrogen atom must be less than this value.
min_mass: float (optional)
Expand All @@ -406,6 +403,9 @@ def guess_hydrogens(self,
Notes
-----
Hydrogen selections may be achieved with either a resname, atom
name combination, or when those are absent, atom types.
This function makes use of atomic masses and atomic charges to identify which atoms are hydrogen atoms that are
capable of participating in hydrogen bonding. If an atom has a mass less than :attr:`max_mass` and an atomic
charge greater than :attr:`min_charge` then it is considered capable of participating in hydrogen bonds.
Expand All @@ -415,6 +415,10 @@ def guess_hydrogens(self,
Alternatively, this function may be used to quickly generate a :class:`str` of potential hydrogen atoms involved
in hydrogen bonding. This str may then be modified before being used to set the attribute
:attr:`hydrogens_sel`.
.. versionchanged:: 2.4.0
Added ability to use atom types
"""

if min_mass > max_mass:
Expand All @@ -435,13 +439,11 @@ def guess_donors(self, select='all', max_charge=-0.5):
"""Guesses which atoms could be considered donors in the analysis. Only use if the universe topology does not
contain bonding information, otherwise donor-hydrogen pairs may be incorrectly assigned.
Donor selections may be achieved with either a resname, atom
name combination, or when those are absent, atom types.
Parameters
----------
select: str (optional)
Selection string for atom group from which donors will be identified.
:doc:`Selection string </documentation_pages/selections>` for atom group from which donors
will be identified. (e.g., ``(resname X and name O1)`` or ``type 2``)
max_charge: float (optional)
The charge of a donor atom must be less than this value.
Expand All @@ -453,6 +455,9 @@ def guess_donors(self, select='all', max_charge=-0.5):
Notes
-----
Donor selections may be achieved with either a resname, atom
name combination, or when those are absent, atom types.
This function makes use of and atomic charges to identify which atoms could be considered donor atoms in the
hydrogen bond analysis. If an atom has an atomic charge less than :attr:`max_charge`, and it is within
:attr:`d_h_cutoff` of a hydrogen atom, then it is considered capable of participating in hydrogen bonds.
Expand All @@ -464,6 +469,9 @@ def guess_donors(self, select='all', max_charge=-0.5):
in hydrogen bonding. This :class:`str` may then be modified before being used to set the attribute
:attr:`donors_sel`.
.. versionchanged:: 2.4.0
Added ability to use atom types
"""

# We need to know `hydrogens_sel` before we can find donors
Expand Down Expand Up @@ -502,7 +510,8 @@ def guess_acceptors(self, select='all', max_charge=-0.5):
Parameters
----------
select: str (optional)
Selection string for atom group from which acceptors will be identified.
:doc:`Selection string </documentation_pages/selections>` for atom group from which acceptors will
be identified. (e.g., ``(resname X and name O1)`` or ``type 2``)
max_charge: float (optional)
The charge of an acceptor atom must be less than this value.
Expand All @@ -514,6 +523,9 @@ def guess_acceptors(self, select='all', max_charge=-0.5):
Notes
-----
Acceptor selections may be achieved with either a resname, atom
name combination, or when those are absent, atom types.
This function makes use of and atomic charges to identify which atoms could be considered acceptor atoms in the
hydrogen bond analysis. If an atom has an atomic charge less than :attr:`max_charge` then it is considered
capable of participating in hydrogen bonds.
Expand All @@ -524,6 +536,9 @@ def guess_acceptors(self, select='all', max_charge=-0.5):
in hydrogen bonding. This :class:`str` may then be modified before being used to set the attribute
:attr:`acceptors_sel`.
.. versionchanged:: 2.4.0
Added ability to use atom types
"""

ag = self.u.select_atoms(select)
Expand All @@ -546,9 +561,12 @@ def __group_categories(group):
-------
select : str
String for each hydrogen bond acceptor/donor/hydrogen atom category.
.. versionadded:: 2.4.0
"""

if hasattr(group,"resnames") and hasattr(group,"names"):
if hasattr(group, "resnames") and hasattr(group, "names"):
group_list = np.unique(
[
'(resname {} and name {})'.format(r, p) for r, p in zip(group.resnames, group.names)
Expand Down Expand Up @@ -866,7 +884,7 @@ def count_by_type(self):
d = self.u.atoms[self.results.hbonds[:, 1].astype(np.intp)]
a = self.u.atoms[self.results.hbonds[:, 3].astype(np.intp)]

if hasattr(d,"resnames"):
if hasattr(d, "resnames"):
d_res = d.resnames
a_res = a.resnames
else:
Expand Down

0 comments on commit f7185a1

Please sign in to comment.