MDAnalysis / mdanalysis

MDAnalysis is a Python library to analyze molecular dynamics simulations.
https://mdanalysis.org
Other
1.26k stars 639 forks source link

Feature: AtomGroupGroup #1861

Open richardjgowers opened 6 years ago

richardjgowers commented 6 years ago

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)

jbarnoud commented 6 years ago

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))
richardjgowers commented 6 years ago

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.

orbeckst commented 6 years ago

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 commented 6 years ago

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

richardjgowers commented 6 years ago

@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!

orbeckst commented 6 years ago

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 ;-).

richardjgowers commented 5 years ago

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

orbeckst commented 5 years ago

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.

Shlokatadistance commented 4 years ago

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)

orbeckst commented 4 years ago

@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.)

richardjgowers commented 4 years ago

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

danonymous856 commented 2 years ago

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

danonymous856 commented 2 years ago

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

orbeckst commented 2 years ago

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.

danonymous856 commented 2 years ago

Sure thing

orbeckst commented 3 months ago

@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.

bintang-aswam commented 1 month ago

@orbeckst, could I contribute to pull-requests alongside open project (if any) outside of GSoC program?

orbeckst commented 1 month ago

You and anybody else are more than welcome to contribute to MDAnalysis. It's an open source project and we value all contributions from the community. I'd generally suggest to engage in conversations in Discord or our Discussion forums, especially if they are more general or open ended. If there's a specific issue you are looking into, communicate on the issue.

bintang-aswam commented 1 month ago

To be honest, I want to focus on advancing the recent MDAnalysis solver @orbeckst.