-
Notifications
You must be signed in to change notification settings - Fork 90
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
Adds 'Live' MDAnalysis Selections #466
Conversation
@rbdavid this is an example of using the connected MDA Universe that is maintained between sessions. This won't be applicable to other import methods, but a similar approach could be done. |
This is awesome! From the video, it seems like you can add any number of selection atom groups where |
Yes the idea is that you can add any number of 'custom selections'. Each listed custom selection becomes a named attribute on the mesh, with a boolean selection that is generated through MDAnalysis. This can then be used inside of geometry nodes for styling / selecting etc. |
Related to #440 - I'm thinking we could manage universe transformations (smoothing, translations etc) from a similar list. |
Trajectory and selection updating now uses a UUID that is generated on import. This UUID is stored on the objects, so we iterate through objects, look up the relevant universe, then use that for updating rather than looping through universes and trying to find objects to update.
@rbdavid if you did want to have a look over the code - I'm pretty happy with how this implementation is now. I explain mostly in the edited PR, but along with adding the 'live' selections - this has now completely overhauled how MDA Universes are imported and tracked in a global |
Looks great! Sorry for the radio silence from me. I've had many distractions pushing my blender work to lower priority. I'd like to get back to finishing my visualizations as well as helping in development where possible. Hopefully things clear up for me soon. I likely won't be able to test out the One question, and this might show how out-of-date my knowledge is, the |
No worries @rbdavid . I think I'll merge this into the #501 branch and if you wanted to do a more broad review there that would be useful. Downloading from the PDB, opening class MNSession:
def __init__(self) -> None:
self.molecules: Dict[str, Molecule] = {}
self.universes: Dict[str, MNUniverse] = {}
self.ensembles: Dict[str, Ensemble] = {} |
Completely re-works how MDA universes are added and updated under the hood, while adding a panel for MDA selections. These are 'Live' selections which are updated when the selection string is updated and on frame change. Now that the universe linking is working really well - the 'in memory' option is removed.
Fixes #475, #455
Enables functionality to implement #440
The selections appear as boolean attributes on the mesh. It is a True / False for whether the atoms are selected via
universe.select_atoms(selection)
to the imported universe.New features:
Todo:
MNSession
for tracking imported molecules / universes / ensemblesSelections
The selections are defined by creating an
AtomGroup
and checking which universe atoms are inside of that group. Only on an update to theselection_str
is a newAtomGroup
created. For regular frame changes the same group is used, and the selection will updating internally ifupdating
is selected.name
: Name that will become the attribute name on the objectselection_str
: used inside ofmda.Universe.select_atoms(selection_str)
for defining the atom groupupdating
: whether the selection is updated on change of frame or change ofselection_str
periodic
: for geomtric selections whether to look into different periodic images when searchingProximity selections are a lot faster inside of Geometry Nodes / Molecular Nodes - so combining a selection with the proximity selection node is the fastest way to achieve distance selections. Need to improve proximity selection node related to #524
MNSession
Class for tracking the imported objects in the scene. Each dictionary for the correpsonding items uses a
uuid
that is generated when imported - which is also stored on the corresponding blender object when created. This allows for cleaner lookup of objects and universes, without relying on thebpy.data.objects['name']
approach which is very easy to break (a frustrating limitation of Blender).There is a dictionary for each type of item, (
Molecule
,MNUniverse
andEnsemble
). They are then available to the session after import is finished. The session won't persist between.blend
save and load, so on save we pickle the file and save it next to the.blend
file as.blend.MNSession
. When loading a.blend
file the pickle is loaded again and everything that was in the old session is appended to the new session. You can't pickle Blender's Object or Collection objects, so just before pickling a reference to their names are saved and then on load they are retrieved using the reference.This session system now handles refreshing for universes, molecules and ensembles, so that it is all united in one location.
CleanShot.2024-06-20.at.22.23.12.mp4