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 intra_connections (intra_bonds, intra_angles, etc) #3200

Merged
merged 26 commits into from
May 3, 2021

Conversation

lilyminium
Copy link
Member

@lilyminium lilyminium commented Apr 2, 2021

Fixes #1264
Fixes #2821

Changes made in this Pull Request:

  • After PR Added get_connections #3160, sets the default get_atoms to only return connections where all atoms are within the queried AtomGroup (i.e. outside=False)
  • However, it still returns all connections involving the atom in Atom.bonds/angles/dihedrals etc (i.e. outside=True)
  • I would expect Atom.bonds to include all the bonds involving that Atom, but AtomGroup to only include the bonds within the group.
  • Also changes various parsers and writers to use get_connections instead of .bonds etc to get the previous data
  • Changes a bunch of tests to pass
  • Added intra_bonds, etc. by way of metaclass jiggling.

PR Checklist

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

@pep8speaks
Copy link

pep8speaks commented Apr 2, 2021

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

Line 1474:1: E302 expected 2 blank lines, found 1

Comment last updated at 2021-05-02 17:03:39 UTC

@codecov
Copy link

codecov bot commented Apr 2, 2021

Codecov Report

Merging #3200 (c7997b5) into develop (fe22dc3) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #3200   +/-   ##
========================================
  Coverage    92.85%   92.86%           
========================================
  Files          170      170           
  Lines        22840    22865   +25     
  Branches      3240     3243    +3     
========================================
+ Hits         21208    21233   +25     
  Misses        1584     1584           
  Partials        48       48           
Impacted Files Coverage Δ
package/MDAnalysis/coordinates/MOL2.py 97.69% <100.00%> (ø)
package/MDAnalysis/coordinates/ParmEd.py 93.18% <100.00%> (ø)
package/MDAnalysis/core/groups.py 98.47% <100.00%> (+0.01%) ⬆️
package/MDAnalysis/core/topologyattrs.py 96.72% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe22dc3...c7997b5. Read the comment docs.

@IAlibay IAlibay added this to the 2.0 milestone Apr 6, 2021
@lilyminium lilyminium marked this pull request as draft April 6, 2021 18:49
@lilyminium lilyminium changed the title Set AtomGroup.bonds, angles, dihedrals etc. to only get values *within* AtomGroup Add intra_connections (intra_bonds, intra_angles, etc) Apr 7, 2021
@lilyminium lilyminium force-pushed the get_connections_develop branch 2 times, most recently from f37d148 to a65edfa Compare April 7, 2021 06:27
@lilyminium lilyminium force-pushed the get_connections_develop branch from a65edfa to 981c22a Compare April 7, 2021 06:30
@lilyminium lilyminium marked this pull request as ready for review April 7, 2021 14:32
@IAlibay IAlibay requested review from jbarnoud and mnmelo April 22, 2021 18:03
@lilyminium lilyminium force-pushed the get_connections_develop branch from 967ebf7 to c0f0f52 Compare April 23, 2021 04:23
Copy link
Contributor

@jbarnoud jbarnoud left a comment

Choose a reason for hiding this comment

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

The good thing with a good self-contained and well scoped PR is that I can nitpick. So here is my nitpicking.

package/MDAnalysis/core/groups.py Show resolved Hide resolved
package/MDAnalysis/core/groups.py Show resolved Hide resolved
package/MDAnalysis/core/groups.py Outdated Show resolved Hide resolved
ugroup = getattr(self.universe.atoms, typename)
if not len(ugroup):
return ugroup
func = np.any if outside else np.all
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer a more explicit name for that. logic_comparator maybe?

Copy link
Contributor

Choose a reason for hiding this comment

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

I see the conversation marked as resolved, but the variable is still named func.

@@ -2296,14 +2309,22 @@ def set_atoms(self, ag):
return NotImplementedError("Cannot set bond information")

def get_atoms(self, ag):
"""
Get subset for atoms.
Copy link
Contributor

Choose a reason for hiding this comment

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

It is good to add a docstring, but I am not sure this one helps much: what subset of the atoms?

Copy link
Member Author

Choose a reason for hiding this comment

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

I hope this new one is more helpful, although I'm not certain users will ever really see it

testsuite/MDAnalysisTests/core/test_groups.py Outdated Show resolved Hide resolved
package/MDAnalysis/core/topologyattrs.py Outdated Show resolved Hide resolved
lilyminium and others added 9 commits April 28, 2021 09:54
Towards MDAnalysis#2468 

## Work done in this PR
* Add aromaticity and Gasteiger charges guessers which work via the RDKIT converter.
Fixes MDAnalysis#3109 

## Work done in this PR
* gracefully handle the case where `gcc` toolchain
in use on MacOS has been built from source using `clang`
by `spack` (so it really is `gcc` in use, not `clang`)

## Notes
* we could try to add regression testing, but a few problems:
- `using_clang()` is inside `setup.py`, which probably
can't be safely imported because it has unguarded statements/
code blocks that run right away
- testing build issues is typically tricky with mocking, etc.
(though in this case, probably just need to move `using_clang()`
somewhere else and then test it against a variety of compiler
metadata strings
* Fixes MDAnalysis#2974
* Python 3.9 officially supported
* Add  Python 3.9 to testing matrix
* Adds macOS CI entry, formalises 3.9 support
@lilyminium lilyminium force-pushed the get_connections_develop branch from 385f956 to eb0e5c0 Compare April 28, 2021 17:44
Copy link
Contributor

@jbarnoud jbarnoud left a comment

Choose a reason for hiding this comment

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

There is one tiny little thing left, really tiny tiny one. I approve the PR, but I'll merge only tomorrow to give you a chance to look at it if you think it is worth changing.

ugroup = getattr(self.universe.atoms, typename)
if not len(ugroup):
return ugroup
func = np.any if outside else np.all
Copy link
Contributor

Choose a reason for hiding this comment

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

I see the conversation marked as resolved, but the variable is still named func.

@jbarnoud jbarnoud merged commit a82113b into MDAnalysis:develop May 3, 2021
@jbarnoud
Copy link
Contributor

jbarnoud commented May 3, 2021

Sorry, I thought I clicked the button already.

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