Save centroids in scene coordinates
Hi there, I have aligned a bunch of models with matchmaker, and then I defined centroids for each model with `define centroid`. I would like to export those centroids for further analysis (trying to see the spatial relationship between chains B from each model when all models are aligned on chain A). However, the only way I could figure out how to do it was to press "Save Info..." in the Structure Measurements window. This text file reports the centroids in the model coordinate system for each model. But because I aligned the models with matchmaker, I'd rather have the centroids in the scene coordinate system. I am not sure how to do this transformation and export all the coordinates (~dozens of models). The only other option I found that might work was the `getcrg` command which I could use to save the coordinates to the Log, but then I will have to save the log as an HTML and parse that, right? Is there any more straightforward way? Alternatively, is there a better way to define centroids (ideally programmatically) so I can extract them from Chimera easily in scene coordinates? Perhaps the measure center command is the thing I should be using? Thanks a bunch! I'm running ChimeraX v1.10.1 (2025-07-24) on Mac OS 15.6 Sequoia Thank you!! Andrew
Hi Andrew, The centroids are represented by atoms, which means you can use any operation on them that you could use on normal atoms, including saving to a PDB file. Let’s say your reference model when you were doing matchmaker was model 1. To save a PDB with the centroid coordinates in model 1’s coordinate system to a file on your desktop named “centroids.pdb”, you would use this command: save ~/Desktop/centroids.pdb ##name=centroid rel #1 It seems like it should be easy to throw together a script that opens files of interest, defines centroids, and then saves a PDB file. --Eric Eric Pettersen UCSF Computer Graphics Lab
On Oct 2, 2025, at 2:09 PM, Andrew Kennard via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi there,
I have aligned a bunch of models with matchmaker, and then I defined centroids for each model with `define centroid`. I would like to export those centroids for further analysis (trying to see the spatial relationship between chains B from each model when all models are aligned on chain A). However, the only way I could figure out how to do it was to press "Save Info..." in the Structure Measurements window. This text file reports the centroids in the model coordinate system for each model. But because I aligned the models with matchmaker, I'd rather have the centroids in the scene coordinate system. I am not sure how to do this transformation and export all the coordinates (~dozens of models).
The only other option I found that might work was the `getcrg` command which I could use to save the coordinates to the Log, but then I will have to save the log as an HTML and parse that, right? Is there any more straightforward way?
Alternatively, is there a better way to define centroids (ideally programmatically) so I can extract them from Chimera easily in scene coordinates? Perhaps the measure center command is the thing I should be using? Thanks a bunch!
I'm running ChimeraX v1.10.1 (2025-07-24) on Mac OS 15.6 Sequoia
Thank you!!
Andrew _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
Hi Eric, Thanks for the suggestion! I ended up deciding this was the moment to finally take the plunge into the ChimeraX source code. Thanks to you and the rest of RBVI for making it very readable! After reading some other messages on the mailing list and inspecting the source code I learned about some modules and methods that don't have docstrings in the API reference <https://www.cgl.ucsf.edu/chimerax/docs/devel/modules.html> (e.g. `chimerax.centroids` and `chimerax.core.models.Models.list`), and from that I was able to piece together a solution that allowed me to do everything in one script without saving an intermediate file (pdb or otherwise). As an example (in case others are interested): ``` from chimerax.centroids import CentroidModel # a useful handle to identify models made with define centroid centroids_models = session.models.list(type=CentroidModel) # this was useful! centroids_list = [model.scene_coord for model in centroids_models] #Do fun things with the centroids! ``` Cheers, Andrew On Thu, Oct 2, 2025 at 8:20 PM Eric Pettersen <pett@cgl.ucsf.edu> wrote:
Hi Andrew, The centroids are represented by atoms, which means you can use any operation on them that you could use on normal atoms, including saving to a PDB file. Let’s say your reference model when you were doing matchmaker was model 1. To save a PDB with the centroid coordinates in model 1’s coordinate system to a file on your desktop named “centroids.pdb”, you would use this command:
save ~/Desktop/centroids.pdb ##name=centroid rel #1
It seems like it should be easy to throw together a script that opens files of interest, defines centroids, and then saves a PDB file.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Oct 2, 2025, at 2:09 PM, Andrew Kennard via ChimeraX-users < chimerax-users@cgl.ucsf.edu> wrote:
Hi there,
I have aligned a bunch of models with matchmaker, and then I defined centroids for each model with `define centroid`. I would like to export those centroids for further analysis (trying to see the spatial relationship between chains B from each model when all models are aligned on chain A). However, the only way I could figure out how to do it was to press "Save Info..." in the Structure Measurements window. This text file reports the centroids in the model coordinate system for each model. But because I aligned the models with matchmaker, I'd rather have the centroids in the scene coordinate system. I am not sure how to do this transformation and export all the coordinates (~dozens of models).
The only other option I found that might work was the `getcrg` command which I could use to save the coordinates to the Log, but then I will have to save the log as an HTML and parse that, right? Is there any more straightforward way?
Alternatively, is there a better way to define centroids (ideally programmatically) so I can extract them from Chimera easily in scene coordinates? Perhaps the measure center command is the thing I should be using? Thanks a bunch!
I'm running ChimeraX v1.10.1 (2025-07-24) on Mac OS 15.6 Sequoia
Thank you!!
Andrew _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
Glad you were able to do fun things with centroids. :-) --Eric
On Oct 3, 2025, at 1:19 PM, Andrew Kennard via ChimeraX-users <chimerax-users@cgl.ucsf.edu> wrote:
Hi Eric,
Thanks for the suggestion! I ended up deciding this was the moment to finally take the plunge into the ChimeraX source code. Thanks to you and the rest of RBVI for making it very readable!
After reading some other messages on the mailing list and inspecting the source code I learned about some modules and methods that don't have docstrings in the API reference <https://www.cgl.ucsf.edu/chimerax/docs/devel/modules.html> (e.g. `chimerax.centroids` and `chimerax.core.models.Models.list`), and from that I was able to piece together a solution that allowed me to do everything in one script without saving an intermediate file (pdb or otherwise).
As an example (in case others are interested):
``` from chimerax.centroids import CentroidModel # a useful handle to identify models made with define centroid
centroids_models = session.models.list(type=CentroidModel) # this was useful! centroids_list = [model.scene_coord for model in centroids_models]
#Do fun things with the centroids! ```
Cheers, Andrew
On Thu, Oct 2, 2025 at 8:20 PM Eric Pettersen <pett@cgl.ucsf.edu <mailto:pett@cgl.ucsf.edu>> wrote:
Hi Andrew, The centroids are represented by atoms, which means you can use any operation on them that you could use on normal atoms, including saving to a PDB file. Let’s say your reference model when you were doing matchmaker was model 1. To save a PDB with the centroid coordinates in model 1’s coordinate system to a file on your desktop named “centroids.pdb”, you would use this command:
save ~/Desktop/centroids.pdb ##name=centroid rel #1
It seems like it should be easy to throw together a script that opens files of interest, defines centroids, and then saves a PDB file.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Oct 2, 2025, at 2:09 PM, Andrew Kennard via ChimeraX-users <chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu>> wrote:
Hi there,
I have aligned a bunch of models with matchmaker, and then I defined centroids for each model with `define centroid`. I would like to export those centroids for further analysis (trying to see the spatial relationship between chains B from each model when all models are aligned on chain A). However, the only way I could figure out how to do it was to press "Save Info..." in the Structure Measurements window. This text file reports the centroids in the model coordinate system for each model. But because I aligned the models with matchmaker, I'd rather have the centroids in the scene coordinate system. I am not sure how to do this transformation and export all the coordinates (~dozens of models).
The only other option I found that might work was the `getcrg` command which I could use to save the coordinates to the Log, but then I will have to save the log as an HTML and parse that, right? Is there any more straightforward way?
Alternatively, is there a better way to define centroids (ideally programmatically) so I can extract them from Chimera easily in scene coordinates? Perhaps the measure center command is the thing I should be using? Thanks a bunch!
I'm running ChimeraX v1.10.1 (2025-07-24) on Mac OS 15.6 Sequoia
Thank you!!
Andrew _______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu <mailto:chimerax-users@cgl.ucsf.edu> To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu <mailto:chimerax-users-leave@cgl.ucsf.edu> Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
_______________________________________________ ChimeraX-users mailing list -- chimerax-users@cgl.ucsf.edu To unsubscribe send an email to chimerax-users-leave@cgl.ucsf.edu Archives: https://mail.cgl.ucsf.edu/mailman/archives/list/chimerax-users@cgl.ucsf.edu/
participants (2)
-
Andrew Kennard -
Eric Pettersen