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 'com of' selection syntax #2017

Open
pckroon opened this issue Jul 30, 2018 · 2 comments
Open

Add 'com of' selection syntax #2017

pckroon opened this issue Jul 30, 2018 · 2 comments

Comments

@pckroon
Copy link

pckroon commented Jul 30, 2018

Hello world!

First off, thanks for making and maintaining this, it's a really nice project!

I have a problem where I want to calculate the density of a molecule in multiple simulations. I've solved this by subclassing AnalysisBase and feeding my atom positions to np.histogramdd. This works. What I want now is to calculate a similar density profile, but only looking at the center of mass of the molecule. The cleanest way (from the perspective of my code) of doing this would be by changing my selection string from resid 0-17 to com of resid 0-17, which MDA would deal with by creating an atomgroup with a single particle, which would be some kind of pseudo-atom.

If you have more questions, feel free to ask :)

@pckroon pckroon changed the title Add pseudo-atoms for analysis Add 'com of' selection syntax Jul 30, 2018
@richardjgowers
Copy link
Member

Hey @pckroon

What you're suggesting is sort of #1861 where we want a fake particle which represents the aggregated properties of many particles. I posted some code here which does the trick, although it only does positions (until you hack in more attributes)

So you could use it as

ag = u.select_atoms('resid 0-17')

bg = BeadGroup([ag])

bg.positions  # should give you an array of 1 position

# And to capture many groups..

ag2 = u.select_atoms(????)

bg = BeadGroup([ag, ag2])

# bg now has length 2, ie represents the COM of 2 groups

It should be fairly easy to hack in extra attributes, ie mass you'd want to sum for each group etc. Hope that helps!

@pckroon
Copy link
Author

pckroon commented Jul 30, 2018

Hi @richardjgowers

Thanks! It's indeed similar. To me as an outsider it sounds like it would be a good idea if a com of or cog of selection would create one of these BeadGroups, or AgregateGroups under the hood.

Peter

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

No branches or pull requests

3 participants