mdanalysis icon indicating copy to clipboard operation
mdanalysis copied to clipboard

Feature: AtomGroupGroup

Open richardjgowers opened this issue 6 years ago • 19 comments

So this is kind of inspired by https://groups.google.com/forum/#!topic/mdnalysis-discussion/eqegNLWvHAY and also some other work I did on coarse-graining before.

Wouldn't it be cool if we could do something like:

from MDAnalysis.coarsegraining import Bead / SuperGroup / ÜberGroup (fur ze deutsch)

ags = u.atoms[:4], u.atoms[4:8], u.atoms[8:12]

ug = ÜberGroup(ags)

# Then properties of the ug are averages* of the subgroups
ug.positions == [ag.center_of_mass() for ag in ags]
ug.charges == [np.mean(ag.charges) for ag in ags]
ug.masses == [np.sum(ag.masses) for ag in ags]

This is useful for coarsegraining, but also for dealing with concepts like aromatic rings. This would also let us move further towards using AtomGroups more, as ÜberGroup would subclass from it and would mimic all possible attributes.

Thoughts? (ping @jbarnoud @mnmelo)

richardjgowers avatar Apr 10 '18 14:04 richardjgowers

I have seen at least two shots given at the issue, one of them being from you if I well remember. They were dealing with CG universes, though. I am obviously in favour of anything that would make my life of coarse-grainer (is it a thing? it should!) easier; so I am in favour of this. But I think having the coarse-graining done by a reader is better: indeed, it allows to use transparently everything we already have in place.

How we build the CG reader is an other question. It could very be:

from MDAnalysis.coarsegraining import ÜberReader, ÜberParser

ags = u.atoms[:4], u.atoms[4:8], u.atoms[8:12]
ucg = mda.Universe(ÜberParser(ags), ÜberReader(ags))

jbarnoud avatar Apr 10 '18 15:04 jbarnoud

It'd be definitely cool to resurrect CGUniverse, that was pre-new-topology system!

I think there's also issues like #1053 where you want to treat groups of atoms as single sites, but not in a CG way, or you don't want to construct an entire Universe for that. I'm dealing with a lot of phenyl rings lately and it's annoying to drop the object based approach and end up with arrays of ring centers, arrays of other properties etc.

richardjgowers avatar Apr 10 '18 20:04 richardjgowers

When I read the email I also thought of BlobGroup.

In principle the new topology system allows this at the AtomGroup level: create a new attribute (blobid) and assign the blobids as you wish, the ag.groupby("blobid") to get your AtomGroups for the blobs.

EDIT: ... of course it does not do the automated averaging.

orbeckst avatar Apr 11 '18 03:04 orbeckst

... and ja, die ÜberGruppe zounds wery nice.

orbeckst avatar Apr 11 '18 03:04 orbeckst

@orbeckst I was mostly joking about ÜberGroup, then I warmed to it after I couldn't think of anything better, now I realise it's confusing because of the Uber app :(. Maybe BeadGroup.

Having it as an attribute is a cool idea but it would mean that each Atom could only be in a single Bead, or you'd need a new dummy attribute for each different Bead representation layer you added. It's an interesting idea!

richardjgowers avatar Apr 13 '18 13:04 richardjgowers

I don't mind claiming "Uber" – it's been used in American English before the ride sharing company. I would probably still choose a more boring and descriptive name but I think whoever implements it gets to choose ;-).

orbeckst avatar Apr 13 '18 16:04 orbeckst

Just another thought, it would be cool if an AtomGroup had a to_BeadGroup method. So then when you had a collection of AGs, ag.to_BeadGroup lets you treat many atoms as a single entity, sum(ag.to_BeadGroup for ag in my_ags) would give you the array of Beads

richardjgowers avatar Jul 30 '18 16:07 richardjgowers

It might be useful to work out an API proposal (sort of an "MDAnalysis Extra Enhancement Proposal" or MEEP for short...) that gives an idea of what the API would look like and what it would enable.

There's also the old issue on coarse grained FF awareness #507 that would make MDA more useable for the CG community.

orbeckst avatar Jul 30 '18 20:07 orbeckst

I think we can implement the data structures for the centres of mass and the atoms in a more systematic way, cause there are plenty of issues which arise from concatenations in python. but I also think that this can be implemented fairly well in the pre-existing structure. (P.S I look forward to working on the same for GSoc2020)

Shlokatadistance avatar Mar 11 '20 14:03 Shlokatadistance

@Shlokatadistance , you might want to look deeper in how MDAnalysis represents systems, namely as numpy arrays of integers, where the integer is the id of the particle. The 2016 paper also explains a little bit more. (And if you really want to learn more, look at issue #363 and the blog post A shiny, new and faster topology system.)

orbeckst avatar Mar 11 '20 22:03 orbeckst

Another request for this: https://groups.google.com/forum/#!topic/mdnalysis-discussion/7gnJ-dLLZsc

richardjgowers avatar Apr 14 '20 08:04 richardjgowers

how to get started with the project as a newbie? @anyone

danonymous856 avatar Apr 12 '22 14:04 danonymous856

Yeah1 Also what abt this one . from where do I collect worthy info to contribute at this part specifically only.

danonymous856 avatar Apr 12 '22 14:04 danonymous856

Hello @danonymous856 , welcome to MDAnalysis. I suggest you introduce yourself first on the developer mailing list and let us know what you‘re interested in (GSoC or Outreachy or generally contributing); also include your GitHub username in the intro email. We can then point you in the right directions.

This specific issue is not well suited for a new contribution as it overlaps with a GSoC project.

orbeckst avatar Apr 12 '22 15:04 orbeckst

Sure thing

danonymous856 avatar Apr 12 '22 15:04 danonymous856

@bintang-aswam according to https://www.mdanalysis.org/2024/02/27/gsoc2024 you need to have an approved pre-proposal to submit a full proposal. If you don't have that, then it's too late to apply for working with MDAnalysis, sorry.

orbeckst avatar Apr 02 '24 19:04 orbeckst