-
Notifications
You must be signed in to change notification settings - Fork 670
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
AtomGroup.resids should return an array of equal size to AtomGroup #385
Comments
I like this. We've got ResidueGroup for working at the Residue level.. eg: ag.masses += 1.0 # not sure why you would, but it works
ag.resids += 1 # nope!
ag.resids = [atom.resid + 1 for atom in ag] # fugly!
# the resids of the ATOMS
ag.resids
# the resids of the RESIDUES
ag.residues.resids |
Thanks for the example of where this would directly benefit @richardjgowers! I know I've had to do backflips around this behavior before, but I can't remember the specific context of what I was trying to do. |
Thanks for taking this on @dotsdl With the tests for AtomGroup properties, I've added a new set right at the end of test_atomgroup which uses a test generator to apply the same test to all properties (test for identical behaviour by applying identical tests). This currently doesn't do resids because of this issue, but once it does if you could add it to those tests it would be good. |
Almost done with this. It's been a pretty major effort, especially since AtomGroups and ResidueGroups had some pretty bad stale cache problems that I've made some fixes to mitigate (which actually fix the Anyway, a new question: ag = u.atoms
rg = ag.residues
len(ag.resids) == len(ag)
len(rg.resids) == len(rg) For properties that refer "downward" in the hierarchy, an array of size equal to the appropriate level is returned e.g. ag = u.atoms
rg = ag.residues
sg = ag.segments
len(rg.indices) == len(rg.atoms)
len(sg.resids) == len(sg.residues) I think this adds some needed consistency. However, there are other properties, such as Thoughts? |
Re: automatic accumulative properties/methods: Your suggestion to automatically aggregate over extensive quantities sounds elegant. There is, however, a danger for this becoming a bit confusing because you won't really know which properties will behave in this way and then we are loosing consistency again (after all, you lobbied hard for In this instance I'm inclined to sacrifice elegance (that would be mainly appreciated by the people knowing the code very well) in favor of explicit naming, e.g. |
Ah, I missed the extra bit about summing residue properties, but it is something I have thought of before. It gets more interesting/confusing (depending on your taste) if you think about positions too. Should This would be useful for when you want to select residues based on position, I think the current best method for that is something like: Maybe you should be able to do: If @dotsdl 's idea isn't practical, then I'd like to remove |
Can we please open a new issue for the discussion of what |
Done: #411 |
AtomGroup.resids
gives an array of resids that is equal in size toAtomGroup.residues
, but it would be more consistent to makeAtomGroup.resids
yield an array of resids equal in size toAtomGroup
. Although the current behavior is useful, there are instances where one actually wants an array of the resids associated with each atom in theAtomGroup
, but currently one has to build this array with, e.g. a list comprehension like:The current behavior can also be achieved with
AtomGroup.residues.resids
, so changing this won't eliminate functionality.This issue was originally raised in #372.
Edit: we would also want to change
AtomGroup.segids
to also return an array of equal size toAtomGroup
.The text was updated successfully, but these errors were encountered: