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

add relprop for atom selection and corresponding UT #4841

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

ChiahsinChu
Copy link
Contributor

@ChiahsinChu ChiahsinChu commented Dec 18, 2024

Implementaton of #4838

Changes made in this Pull Request:

  • add relprop keyword for atom selection
  • add UT for this keyword

I will update the User Guide once this implementation (especially the interface to users) is accepted.

PR Checklist

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

Developers certificate of origin


📚 Documentation preview 📚: https://mdanalysis--4841.org.readthedocs.build/en/4841/

Copy link

codecov bot commented Dec 18, 2024

Codecov Report

Attention: Patch coverage is 93.75000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 93.64%. Comparing base (1eca9f2) to head (f960ea7).

Files with missing lines Patch % Lines
package/MDAnalysis/core/selection.py 93.75% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #4841      +/-   ##
===========================================
- Coverage    93.66%   93.64%   -0.03%     
===========================================
  Files          177      189      +12     
  Lines        21796    22894    +1098     
  Branches      3067     3069       +2     
===========================================
+ Hits         20415    21438    +1023     
- Misses         929     1003      +74     
- Partials       452      453       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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.

Looks sensible at first glance.

In addition to the inline comments, could you please also add documentation to core.groups.AtomGroup.select_atoms() after prop

def select_atoms(self, sel, *othersel, periodic=True, rtol=1e-05,
which is the primary documentation for all selections? Include an example in the docs (follow prop 's docs) so that we can see how users would use it.

UPDATE: I added a few more comments after submitting my review. Please look at these, too. In particular, can you please explain the rationale for comparing to the COM of the reference group instead of calculating all distances and then comparing the min?

Additionally, the comparison needs to be able to take into account PBC (periodic=True).

package/MDAnalysis/core/selection.py Outdated Show resolved Hide resolved
package/MDAnalysis/core/selection.py Show resolved Hide resolved
package/MDAnalysis/core/selection.py Show resolved Hide resolved
values = values[:, col]
sel = self.sel.apply(group)
rel_value = (
sel.center_of_geometry().reshape(3).astype(np.float32)[col]
Copy link
Member

Choose a reason for hiding this comment

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

Your docs should make clear that the COM of the second group is used.

Is this what this selection should do? Or should it calculate all-vs-all distances and then compute the min over all distances and then compare this minimal distance to the value?

Copy link
Member

@orbeckst orbeckst Dec 19, 2024

Choose a reason for hiding this comment

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

When using center_of_geometry you also need to think carefully to what value wrap and unwrap needs to be set, especially if the user does not get a choice in setting it.

Copy link
Contributor Author

@ChiahsinChu ChiahsinChu Dec 29, 2024

Choose a reason for hiding this comment

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

Yes. COG (not COM) is what I want to implement. In my cases, the planar surfaces are used, and taking the average positions of the surfaces is better than the minimal distances as reference. But I can see the case when the minimal distance would be a better choice, for example, for the curved surfaces. I suggest to have a new selecton class. What is your opinion?

@pep8speaks
Copy link

pep8speaks commented Dec 29, 2024

Hello @ChiahsinChu! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

There are currently no PEP 8 issues detected in this Pull Request. Cheers! 🍻

Comment last updated at 2025-01-07 05:28:06 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: add RelPropertySelection to select atoms based on positions relative to a given selection
3 participants