MolecularNodes icon indicating copy to clipboard operation
MolecularNodes copied to clipboard

Add support for Atom Indices Import

Open BradyAJohnston opened this issue 1 year ago • 7 comments

Add support for importing atom indices import from MD / topology files from programs such as MDAnalysis and mdtraj.

BradyAJohnston avatar Jul 15 '22 10:07 BradyAJohnston

If somebody can come up with a parser (one probably exists in a function in MDAnalysis or similar somewhere) that can parse the .ndx files which provide the atom groups for GROMACS etc, then this can become at attribute on import and allow for inclusion of the atom groups inside of Molecular Nodes.

BradyAJohnston avatar Dec 31 '22 01:12 BradyAJohnston

Hi Brady! I've never contributed before, so I don't know how to do it necessarily. I did however find this other project that seems to accomplish what you need.

https://gist.github.com/jbarnoud/09a22ac41fbd5969af51458eb89317e7

If you'd like, you can give me a little more specific guidance and I can try to add this, or else it looks like it has all the info you might need to do it yourself.

germanbarcenas avatar Jan 24 '23 17:01 germanbarcenas

oooh thanks for pointing this out! I hadn't looked into it deeply yet, but it seems like this should be straightforward to implement.

Happy to support a PR, if you'd like to have a go at implementing it. I'd like to prioritise encouraging community contributions over doing everything myself.

BradyAJohnston avatar Jan 24 '23 23:01 BradyAJohnston

In terms of contributing, I've got some minor details in the README about how to do it in terms of building your own Molecular Nodes. You'll want VSCode and a couple of specific addons for Blender addon development.

The function that does the MDAnalysis importing is here: https://github.com/BradyAJohnston/MolecularNodes/blob/7979e3821f6f68438f9208e7d79d2ca771c12df5/MolecularNodes/md.py#L65-L246

For this to be used, I imagine adding an extra argument to the function maybe file_idx which defaults to None. If a file is given, then use the code above to create a list of boolean selections, each of which can be applied as attributes, similarly to: https://github.com/BradyAJohnston/MolecularNodes/blob/7979e3821f6f68438f9208e7d79d2ca771c12df5/MolecularNodes/md.py#L206-L218

The function is called in this operator: https://github.com/BradyAJohnston/MolecularNodes/blob/7979e3821f6f68438f9208e7d79d2ca771c12df5/MolecularNodes/ui.py#L78

so it will need to be updated, along with adding a new bpy.context.scene.* property for the file, and displaying that in the UI.

If it's a bit much, then I'm happy to go about it as well. The code base I think still requires a bit of a refactor, and blender addons can be a bit overwhelming if you haven't worked with them before as well.

BradyAJohnston avatar Jan 24 '23 23:01 BradyAJohnston

I'll give it a go as well. This isn't top priority for me at the moment, but I really like this project, and it's getting me to learn some more git and Blender, which I'm super happy about!

germanbarcenas avatar Jan 25 '23 04:01 germanbarcenas

If you have questions about approach to take, please let me know! As a brief outline, you'll want to:

  1. Fork the repo into your github account.
  2. Download your fork onto you local computer.
  3. Tinker around with making the changes.
  4. Push your changes back to your fork of the repo.
  5. When you are ready to get some feedback on code / ideas, create a pull request to merge your fork back into my repo. That will allow me to do code review & give feedback.
  6. You can continue to make changes on your fork, which will be reflected in the pull request.
  7. Once it's all good, I'll merge it in to main and it's part of the package!

BradyAJohnston avatar Jan 31 '23 01:01 BradyAJohnston

Brady thanks for the generous guide! I should have some time next week to start poking at this.

germanbarcenas avatar Feb 07 '23 23:02 germanbarcenas