Skip to content
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

Hbond update #3848

Merged
merged 22 commits into from
Dec 7, 2022
Merged

Hbond update #3848

merged 22 commits into from
Dec 7, 2022

Conversation

jaclark5
Copy link
Contributor

@jaclark5 jaclark5 commented Sep 21, 2022

Fixes #3847

Changes made in this Pull Request:

  • Added warning when distance or angle cutoffs produce zero hbonds to clarify a returned value of NaN
  • Guess_donor uses bonding information when available since it calls hydrogen types anyway
  • If resnames and names are not available, atom types are used. This is inclusive to LAMMPS users.
  • Change min max constraints to match inclusive language in the documentation.

PR Checklist

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

@jaclark5
Copy link
Contributor Author

I expect these changes will spur discussion so I didn't bother with the tests yet.

Copy link
Member

@richardjgowers richardjgowers left a comment

Choose a reason for hiding this comment

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

I think these changes don't look that controversial. Changing the output schema/columns might break something in the output, but I guess that will shake out when tests are added.

@jaclark5
Copy link
Contributor Author

It won't break the output. I've been using it with success for quite some time. I actually forgot I made some of these changes but I want to merge them and then stay current with the package.

@codecov
Copy link

codecov bot commented Sep 22, 2022

Codecov Report

Base: 94.34% // Head: 94.38% // Increases project coverage by +0.03% 🎉

Coverage data is based on head (0a16b13) compared to base (6bc52ec).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3848      +/-   ##
===========================================
+ Coverage    94.34%   94.38%   +0.03%     
===========================================
  Files          194      194              
  Lines        25226    25242      +16     
  Branches      3402     3406       +4     
===========================================
+ Hits         23800    23825      +25     
+ Misses        1377     1368       -9     
  Partials        49       49              
Impacted Files Coverage Δ
...DAnalysis/analysis/hydrogenbonds/hbond_analysis.py 98.85% <100.00%> (+0.11%) ⬆️
package/MDAnalysis/due.py 76.66% <0.00%> (+29.99%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

looking really good! few comments.

@jaclark5 jaclark5 force-pushed the hbond_update branch 2 times, most recently from 870e90d to 5f9fbab Compare September 29, 2022 00:56
@jaclark5 jaclark5 marked this pull request as ready for review September 29, 2022 21:51
@jaclark5 jaclark5 requested a review from hmacdope October 11, 2022 21:21
.gitignore Show resolved Hide resolved
package/CHANGELOG Outdated Show resolved Hide resolved
else:
hydrogens_list = np.unique(
[
'type {}'.format(tp) for tp in hydrogens_ag.types
Copy link
Member

Choose a reason for hiding this comment

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

I'm only quickly going through this so I might be missing something obvious - doesn't this assume that all types are the same? Wouldn't this be a problem if you end up with a type where some of the atoms are outside the bounds of the allowable charges but not others?

My recommendation here would be to default to a unique attribute, like the ix value, instead of using something that's broad and could pick up stuff outside the intended atomgroup selection.

Copy link
Contributor Author

@jaclark5 jaclark5 Oct 12, 2022

Choose a reason for hiding this comment

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

@IAlibay In most cases an atom type in LAMMPS is all identical with the exception of forcefields such as ReaxFF and COMB. Although you are right that LAMMPS allows for atoms to have individual charges so this could be an issue as forcefields develop...

Here's the issue, these structures look for a list of atom selection strings that represent categories, so if this was on an index basis, the list would be very long, and the resulting output would be useless (representing a single interaction). One could have this structure instead search the atoms of each type and make a long string that specifies the specific indices that meet the charge criteria. However, this string will be unnecessary computational time in 99% of cases, and in the 1% I would argue it would skew the results as these many-body forcefields will continue to fluctuate in charge throughout the simulation, as they are supposed to. I would argue counting "low" or "high" charges in that case wouldn't disrupt the intention of the calculation, it would result in a broken hydrogen bond with a more "realistic" decay time due to local atom environments.

@jaclark5 jaclark5 requested review from IAlibay and removed request for hmacdope October 20, 2022 21:30
Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

Just the one thing and one issue to raise please.

@jaclark5 jaclark5 force-pushed the hbond_update branch 2 times, most recently from 060e6bb to 333ef6b Compare November 4, 2022 22:40
Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

Minor doc changes + pep 8, please.

I am basically ok with the use of types, given that what we do is messy either way... see comment.

package/CHANGELOG Outdated Show resolved Hide resolved
package/CHANGELOG Outdated Show resolved Hide resolved
package/CHANGELOG Show resolved Hide resolved
Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

Thanks for addressing my previous requests. I found a few doc things and suggestions for simplifying code.

I am waiting for @IAlibay (and anyone else) to weigh in on the __group_categories() function.

Copy link
Member

@orbeckst orbeckst left a comment

Choose a reason for hiding this comment

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

Thank you for addressing my requested changes. LGTM!

Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

Just a few minor things.

package/CHANGELOG Outdated Show resolved Hide resolved
Copy link
Member

@hmacdope hmacdope left a comment

Choose a reason for hiding this comment

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

Other than raising the issue mentioned, all the comments I had have been addressed.

@IAlibay
Copy link
Member

IAlibay commented Nov 30, 2022

@jaclark5 I've not forgotten about this, it's at the top of my review list over the next few days.

@IAlibay IAlibay added this to the 2.4.0 milestone Nov 30, 2022
@IAlibay
Copy link
Member

IAlibay commented Dec 2, 2022

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@IAlibay IAlibay left a comment

Choose a reason for hiding this comment

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

lgtm, thanks for doing this @jaclark5. Sorry it took so long to re-review, but at least it'll make it for the 2.4.0 release 🎉 !

'(resname {} and name {})'.format(r,
p) for r, p in zip(group.resnames, group.names)
])
else:
Copy link
Member

Choose a reason for hiding this comment

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

I still think we should have the option to choose whether or not to default to types here, however for the sake of getting this done I'm going to let it go as-is here, and raise a separate issue to deal with later.

assert any(warning in rec.getMessage() for rec in caplog.records)


class TestHydrogenBondAnalysisNoRes(TestHydrogenBondAnalysisIdeal):
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for doing this, avoiding duplicate code as much as possible really helps us avoid future maintenance debt.

@IAlibay IAlibay merged commit 3712439 into MDAnalysis:develop Dec 7, 2022
@orbeckst
Copy link
Member

orbeckst commented Dec 7, 2022

Thank you @jaclark5 , nice work! 🎉

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.

HBond Analysis, efficiency, usability, LAMMPS friendliness
6 participants