Comments (11)
Please feel free to to make some suggestions - it's early days for the class so I'm happy to make more drastic changes for the sake of usability in the future.
The Molecule class does reference the Blender object here:
When the create_model()
method is called an object is created and stored there for future reference.
Molecule
doesn't subclass bpy.types.Object
as the idea is to create a class that is better suited for molecular visualisation. The basic Object
class is very busy already (if you look at the docs linked). I had thought that it would be better to create a cleaner interface that just showed what was important. I'm not super familiar with OOP though, so if you can see improvements for this setup then please do suggest them.
I can certainly imagine this being part of GSoC, but we'll need to make sure it stays associated with MDAnalysis data. Currently the Molecule
class is separate to the AtomGroupInBlender
class which is currently how the MDA data is imported and viewed in Blender:
There would be potential for unifying these a bit better, which would certainly fit well with the GSoC.
from molecularnodes.
I have been working on the bug all day today and realized that you are already tackling it in the PR #448 and in the Issues #454 and #3.
Regarding the molecule
class I would like to offer my help.
I'm noticing some methods associated with the Molecule superclass that utilize self.data (see below), which is not an instantiated class variable in either the Molecule class nor the PDB, CIF, MMTF subclasses.
Some of these are leftovers of GitHub Copilot generated boilerplate that I didn't get around to cleaning up if I am being honest. I haven't really implemented anything that uses them - so it was on the todo list to clean up.
You raise an important point that about how these methods should work (or if they are relevant) which also touches on discussions in other threads.
Currently the
Molecule
object (and others) have theself.data
andself.object
. When usingnamed_attribute()
orstore_named_attribute()
we are getting and setting on the Blender object - should we be updating the underlying databiotite.AtomArray
orMDAnalysis.Universe
? Tracking and having two sources of 'truth' I am not a big fan of.My thoughts are that once we have everything inside of Blender we should pretty much just be interacting with the object, and we should just make sure we have pulled all relevant information from the file itself, with the option to 're-parse' the file for additional information if required for specific use cases.
Within this PR I would remove all code, which contains self.data
, so that the code works properly with the merged PR #448. After that we could open a follow-up PR?
from molecularnodes.
Hi @kainszs ! The first error you are getting is related to initilisation. Currently when the add-on is used inside of Blender, Blender calls a molecularnodes.register()
function. I haven't figured out a nice way to have that called when importing inside of a script other than just manually calling it. Something to hopefully be improved upon.
For now, you can fix it with
import molecularnodes as mn
mn.register()
mn.io.local.load("tests/data/1cd3.pdb")
from molecularnodes.
And yes if you wanted to open a PR to clean up the Molecule
class a bit that would be a great start!
from molecularnodes.
The API is a bit of a mess as you might see in some of the issues. A focus for me will be on improving it, which can hopefully work well with improving the interfacing with MDAnalysis as well for GSOC.
from molecularnodes.
I have looked at the auto_load.py
file, can you explain to me what exactly the init
, register
and unregister
methods are for? And it is also not clear to me from the code why the molecule object has an additional attribute after mn.register()
.
from molecularnodes.
Regarding the molecule class. What should it be able to do? How would you like to work with it?
from molecularnodes.
I have added some more documentation that hopefully explains some of the aspects of the add-on in #463
In short, all operators, UI components and other aspects that are to be used inside of Blender for the add-on have to be registered when loading the add-on, so that Blender knows about them and can display them properly. When the add-on is disabled, they have to be unregistered so you don't still have UI components hanging around when an add-on isn't enabled.
You have to register()
and unregister()
for each of those components individually. The Blender VSCode Development plugin provides a submodule auto_load
which scans through the add-on/package and detects all required operators and UI components, so they can be successfully registered and unregistered. That way we don't have to manually include each method.
from molecularnodes.
Regarding the Molecule
class. Currently when structures are imported, a 3D model is created inside of Blender. The idea is that the Molecule
will contain information about the file that this model came from, and provide an interface that the user can change the associated style and edit the underlying information of the structure through this class. The currently existing python API isn't setup well for interacting with molecular structures, or changing the Geometry Nodes tress that are associated with the models. The class will hopefully provide a neater interface for loading, editing and styling the model, in a way that is nice to script with inside of a Jupyter Notebook or similar script.
from molecularnodes.
Good morning, thank you for the detailed reply. Would you be open to me making a few suggestions for the molecule class? I think by writing magic methods (eg. setattr) a lot can be simplified. But it would also be a major change.
I haven't looked at the blender object in the source code either, but why doesn't molecule inherit from it, for example, or set it as an internal data structure?
Can you also imagine this as part of the GSoC?
from molecularnodes.
I will think about it.
In short, all operators, UI components and other aspects that are to be used inside of Blender for the add-on have to be registered when loading the add-on, so that Blender knows about them and can display them properly. When the add-on is disabled, they have to be unregistered so you don't still have UI components hanging around when an add-on isn't enabled.
from molecularnodes.
Related Issues (20)
- `Style Surface` doesn't update on MDAnalysis trajectory
- Add trajectory smoothing when importing via MDAnalysis HOT 4
- More options for MDAnalysis trajectory playback
- Missing secondary structure HOT 17
- "Centre Structure" option removes Center of Geometry translations rather than Center of Mass HOT 23
- Cartoon Style Not Showing for Local PDB HOT 5
- Pre-build structure specific node groups.
- Guessing atom attributes based on atom names can lead to misinterpretations HOT 3
- Molecule class implementation HOT 6
- Use an MDA Universe as a "data twin" to the blender objects HOT 3
- Usage of a missing attribute in the Molecule class HOT 2
- Introducing a Dev branch HOT 2
- Install MN via pip HOT 1
- Extend requirements file in a manner, that we can run the tests locally HOT 4
- Optimize molecule class HOT 14
- Defaul Materials HOT 2
- Missing VDW radius values for rarely used elements HOT 1
- Side packages install correctly but are not detected HOT 4
- 'Live' MDAnlaysis session loses connection upon object name change
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from molecularnodes.