[chimerax-users] A couple questions about programming in ChimeraX
William Hofsøy
2wswer at gmail.com
Wed Sep 22 05:21:51 PDT 2021
Hi again! Thank you for all the answers from last time. It was very helpful.
I have another question. I was trying to save extra attributes on a marker
model from a cmm file and ran into some issues.
I made a function to test it out using:
marker_set.save_marker_attribute_in_sessions('marker_extra_attributes',
Dict[str, str])
and got an error:
ValueError: error processing: 'attribute registration' -> : No bundle
information for typing._GenericAlias
File "C:\Program Files\ChimeraX
1.2.5\bin\lib\site-packages\chimerax\core\session.py", line 262, in
discovery
raise ValueError("error processing: %s: %s" % (_obj_stack(parents, obj), e))
Is it only possible to save more primitive types or can I fix this somehow?
In my project the cmm files contain extra attributes that my plugin makes
use of. These are the attributes that I would like to save in sessions.
I would like this save enabling function to be called automatically when a
cmm file is opened so that I can enable saving of these attributes on file
open.
Is there perhaps some onFileOpened that I could subscribe to, or is there
another way that could allow me to achieve this?
-William
fre. 27. aug. 2021 kl. 22:15 skrev Tom Goddard <goddard at sonic.net>:
> Hi William,
>
> To add a marker to an open marker set:
>
> from chimerax.markers import MarkerSet
> marker_sets = session.models.list(type = MarkerSet)
> m = marker_sets[0]
> xyz = (15.3, -34, 8.8)
> color = (255,0,0,255) # RGBA 0-255 range.
> radius = 2.5
> m.create_marker(xyz, color, radius)
>
> I see MarkerSet is not in our online programming documentation yet. The
> source code is in your ChimeraX distribution under
>
> chimerax/lib/python3.9/site-packages/chimerax/markers/markers.py
>
> or on GitHub
>
>
> https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/markers/src/markers.py
>
> The marker_extra_attributes is saved and restored in cmm files. For
> ChimeraX session files you can get extra attributes to save by saying what
> attributes you want saved
>
> marker_set.save_marker_attribute_in_sessions('myattribute', float)
>
> For placing geometric surfaces in the scene look at the shape command
>
> https://www.cgl.ucsf.edu/chimerax/docs/user/commands/shape.html
>
> Surprised there is no cube shape, but maybe rectangle with the slab option
> can make a cube. Python code is here
>
>
> https://github.com/RBVI/ChimeraX/blob/develop/src/bundles/shape/src/shape.py
>
> for example
>
> from chimerax.shape.shape import shape_rectangle
> model = shape_rectangle(session, width = 10, height = 10, slab = (-5,5),
> mesh = True)
>
> Tom
>
>
> On Aug 27, 2021, at 8:21 AM, William Hofsøy via ChimeraX-users <
> chimerax-users at cgl.ucsf.edu> wrote:
>
> Hi, I'm currently working on a plugin that deals with a cmm-file model and
> have a few questions about how to do certain things. Mainly I would like to
> be able to modify the model by adding new markers and links to the model. I
> have managed to figure out how to make new markersets and add them to the
> session but not how to alter existing ones aka the model that I load from
> the cmm file.
> Additionally I am making use of the marker_extra_attributes info since the
> cmm file im reading has attributes there that I need, but as I read in the
> documentation these aren't saved in sessions and I wondered if there is a
> way to do just that.
> Lastly, I was wondering if it is possible to place any mesh in the scene,
> for instance a cube.
>
> -William
> _______________________________________________
> ChimeraX-users mailing list
> ChimeraX-users at cgl.ucsf.edu
> Manage subscription:
> https://www.rbvi.ucsf.edu/mailman/listinfo/chimerax-users
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimerax-users/attachments/20210922/abe540a1/attachment.html>
More information about the ChimeraX-users
mailing list