adjust contour to mass

Hi, I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names. Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01 for models I've found chimera.openModels and then you can list over them, but that's about it. Thanks, Martin Turk

Hi Martin, I am not aware that there is a python library reference. If there is, I would appreciate a pointer to it as well. Here are a few links I have found helpful when writing python code for Chimera: This shows how to execute command line commands, it may be what you want: http://www.cgl.ucsf.edu/chimera/data/downloads/1.8/docs/ProgrammersGuide/bas... This goes through how to make plugins and such, but is helpful since the examples show more of the API: http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html HTH, Shawn Waldon On Mon, Nov 18, 2013 at 9:10 AM, Martin Turk <turk@lmb.uni-muenchen.de>wrote:
Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
-- Shawn Waldon Graduate Research Assistant Department of Computer Science University of North Carolina at Chapel Hill swaldon@cs.unc.edu

To supplement Shawn and Tom's answers, obviously it would be best if everything were documented, but in the absence of that if there is a command that implements something similar to what you want to do, you can chase it down in the code base by: a) looking at Midas/__init__.py and see if it's one of the functions in there (they're arranged approximately alphabetically by command name), and if it's not in there… b) grep share/*/ChimeraExtension.py for the command name to find which module defines the command. Then look in that module's ChimeraExtension.py to see what file/method in the module implements the command. --Eric Eric Pettersen UCSF Computer Graphics Lab On Nov 18, 2013, at 9:06 AM, Shawn Waldon <swaldon@cs.unc.edu> wrote:
Hi Martin,
I am not aware that there is a python library reference. If there is, I would appreciate a pointer to it as well. Here are a few links I have found helpful when writing python code for Chimera:
This shows how to execute command line commands, it may be what you want: http://www.cgl.ucsf.edu/chimera/data/downloads/1.8/docs/ProgrammersGuide/bas...
This goes through how to make plugins and such, but is helpful since the examples show more of the API: http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html
HTH, Shawn Waldon
On Mon, Nov 18, 2013 at 9:10 AM, Martin Turk <turk@lmb.uni-muenchen.de> wrote: Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
-- Shawn Waldon Graduate Research Assistant Department of Computer Science University of North Carolina at Chapel Hill swaldon@cs.unc.edu _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev

Hi Shawn, Tom, Eric, thanks a lot for the help and for pointing me in the right direction. Finally I had some time and I've come up with a script that adjusts the volume level threshold from the active model to all opened models. For one model it's not a problem, but when one wants to adjust the levels for a series of volumes (for example after a 3d classification run in relion), it becomes cumbersome to do so for the ~50 models/run. Maybe other EM users find it handy, that's why I'd like to share it. It took me quite some time to find the right functions, which do the actual measurement. Got lost in the OpenModels.h, volume.py, volumedialog.py, and the gui scripts. The rest was easy :-) Thanks again for your help! Best, Martin Turk Beckmann Lab LMU Gence Center Munich On 18.11.2013 20:49, Eric Pettersen wrote:
To supplement Shawn and Tom's answers, obviously it would be best if everything were documented, but in the absence of that if there is a command that implements something similar to what you want to do, you can chase it down in the code base by:
a) looking at Midas/__init__.py and see if it's one of the functions in there (they're arranged approximately alphabetically by command name), and if it's not in there… b) grep share/*/ChimeraExtension.py for the command name to find which module defines the command. Then look in that module's ChimeraExtension.py to see what file/method in the module implements the command.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Nov 18, 2013, at 9:06 AM, Shawn Waldon <swaldon@cs.unc.edu <mailto:swaldon@cs.unc.edu>> wrote:
Hi Martin,
I am not aware that there is a python library reference. If there is, I would appreciate a pointer to it as well. Here are a few links I have found helpful when writing python code for Chimera:
This shows how to execute command line commands, it may be what you want: http://www.cgl.ucsf.edu/chimera/data/downloads/1.8/docs/ProgrammersGuide/bas...
This goes through how to make plugins and such, but is helpful since the examples show more of the API: http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html
HTH, Shawn Waldon
On Mon, Nov 18, 2013 at 9:10 AM, Martin Turk <turk@lmb.uni-muenchen.de <mailto:turk@lmb.uni-muenchen.de>> wrote:
Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
-- Shawn Waldon Graduate Research Assistant Department of Computer Science University of North Carolina at Chapel Hill swaldon@cs.unc.edu <mailto:swaldon@cs.unc.edu> _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev

Hi, added another step for fine tunning and reduced number of steps, now it works much faster. Maybe there is a better way of doing the threshold steps. I overshoot up, down then up again, but it works :) Best, Martin On 23.11.2013 16:29, Martin Turk wrote:
Hi Shawn, Tom, Eric,
thanks a lot for the help and for pointing me in the right direction. Finally I had some time and I've come up with a script that adjusts the volume level threshold from the active model to all opened models. For one model it's not a problem, but when one wants to adjust the levels for a series of volumes (for example after a 3d classification run in relion), it becomes cumbersome to do so for the ~50 models/run. Maybe other EM users find it handy, that's why I'd like to share it. It took me quite some time to find the right functions, which do the actual measurement. Got lost in the OpenModels.h, volume.py, volumedialog.py, and the gui scripts. The rest was easy :-) Thanks again for your help!
Best, Martin Turk
Beckmann Lab LMU Gence Center Munich
On 18.11.2013 20:49, Eric Pettersen wrote:
To supplement Shawn and Tom's answers, obviously it would be best if everything were documented, but in the absence of that if there is a command that implements something similar to what you want to do, you can chase it down in the code base by:
a) looking at Midas/__init__.py and see if it's one of the functions in there (they're arranged approximately alphabetically by command name), and if it's not in there… b) grep share/*/ChimeraExtension.py for the command name to find which module defines the command. Then look in that module's ChimeraExtension.py to see what file/method in the module implements the command.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Nov 18, 2013, at 9:06 AM, Shawn Waldon <swaldon@cs.unc.edu <mailto:swaldon@cs.unc.edu>> wrote:
Hi Martin,
I am not aware that there is a python library reference. If there is, I would appreciate a pointer to it as well. Here are a few links I have found helpful when writing python code for Chimera:
This shows how to execute command line commands, it may be what you want: http://www.cgl.ucsf.edu/chimera/data/downloads/1.8/docs/ProgrammersGuide/bas...
This goes through how to make plugins and such, but is helpful since the examples show more of the API: http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html
HTH, Shawn Waldon
On Mon, Nov 18, 2013 at 9:10 AM, Martin Turk <turk@lmb.uni-muenchen.de <mailto:turk@lmb.uni-muenchen.de>> wrote:
Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
-- Shawn Waldon Graduate Research Assistant Department of Computer Science University of North Carolina at Chapel Hill swaldon@cs.unc.edu <mailto:swaldon@cs.unc.edu> _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev

Hi Martin, Thanks for the script. This is something others have requested. So I added it to Chimera today, in tonight's daily builds. volume #0 encloseVolume 150000 Uses bisection of the density value until the enclosed volume differs from the target volume by less than 1e-5 of the target volume. Uses at most 30 bisection steps. Can set the level for multiple maps at once volume #0-5 encl 250000 Can specify multiple volume values to get multiple surfaces, for example volume #0 enclose 150000,300000 The enclosed volume is in cubic Angstroms if your map grid spacing is in Angstroms. You can report the current enclosed volume with the "measure volume" command measure volume #0 Thanks for figuring out code to do this. I used a slight variation of what you did. Tom On Nov 23, 2013, at 8:41 AM, Martin Turk wrote:
Hi,
added another step for fine tunning and reduced number of steps, now it works much faster. Maybe there is a better way of doing the threshold steps. I overshoot up, down then up again, but it works :)
Best, Martin
On 23.11.2013 16:29, Martin Turk wrote:
Hi Shawn, Tom, Eric,
thanks a lot for the help and for pointing me in the right direction. Finally I had some time and I've come up with a script that adjusts the volume level threshold from the active model to all opened models. For one model it's not a problem, but when one wants to adjust the levels for a series of volumes (for example after a 3d classification run in relion), it becomes cumbersome to do so for the ~50 models/run. Maybe other EM users find it handy, that's why I'd like to share it. It took me quite some time to find the right functions, which do the actual measurement. Got lost in the OpenModels.h, volume.py, volumedialog.py, and the gui scripts. The rest was easy :-) Thanks again for your help!
Best, Martin Turk
Beckmann Lab LMU Gence Center Munich
On 18.11.2013 20:49, Eric Pettersen wrote:
To supplement Shawn and Tom's answers, obviously it would be best if everything were documented, but in the absence of that if there is a command that implements something similar to what you want to do, you can chase it down in the code base by:
a) looking at Midas/__init__.py and see if it's one of the functions in there (they're arranged approximately alphabetically by command name), and if it's not in there… b) grep share/*/ChimeraExtension.py for the command name to find which module defines the command. Then look in that module's ChimeraExtension.py to see what file/method in the module implements the command.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Nov 18, 2013, at 9:06 AM, Shawn Waldon <swaldon@cs.unc.edu> wrote:
Hi Martin,
I am not aware that there is a python library reference. If there is, I would appreciate a pointer to it as well. Here are a few links I have found helpful when writing python code for Chimera:
This shows how to execute command line commands, it may be what you want: http://www.cgl.ucsf.edu/chimera/data/downloads/1.8/docs/ProgrammersGuide/bas...
This goes through how to make plugins and such, but is helpful since the examples show more of the API: http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html
HTH, Shawn Waldon
On Mon, Nov 18, 2013 at 9:10 AM, Martin Turk <turk@lmb.uni-muenchen.de> wrote: Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
-- Shawn Waldon Graduate Research Assistant Department of Computer Science University of North Carolina at Chapel Hill swaldon@cs.unc.edu _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
<chimera-volbymass3.py>

Hi Tom, that's great! and bisectioning is the way to go :) Best, Martin On 25.11.2013 22:03, Tom Goddard wrote:
Hi Martin,
Thanks for the script. This is something others have requested. So I added it to Chimera today, in tonight's daily builds.
volume #0 encloseVolume 150000
Uses bisection of the density value until the enclosed volume differs from the target volume by less than 1e-5 of the target volume. Uses at most 30 bisection steps. Can set the level for multiple maps at once
volume #0-5 encl 250000
Can specify multiple volume values to get multiple surfaces, for example
volume #0 enclose 150000,300000
The enclosed volume is in cubic Angstroms if your map grid spacing is in Angstroms. You can report the current enclosed volume with the "measure volume" command
measure volume #0
Thanks for figuring out code to do this. I used a slight variation of what you did.
Tom
On Nov 23, 2013, at 8:41 AM, Martin Turk wrote:
Hi,
added another step for fine tunning and reduced number of steps, now it works much faster. Maybe there is a better way of doing the threshold steps. I overshoot up, down then up again, but it works :)
Best, Martin
On 23.11.2013 16:29, Martin Turk wrote:
Hi Shawn, Tom, Eric,
thanks a lot for the help and for pointing me in the right direction. Finally I had some time and I've come up with a script that adjusts the volume level threshold from the active model to all opened models. For one model it's not a problem, but when one wants to adjust the levels for a series of volumes (for example after a 3d classification run in relion), it becomes cumbersome to do so for the ~50 models/run. Maybe other EM users find it handy, that's why I'd like to share it. It took me quite some time to find the right functions, which do the actual measurement. Got lost in the OpenModels.h, volume.py, volumedialog.py, and the gui scripts. The rest was easy :-) Thanks again for your help!
Best, Martin Turk
Beckmann Lab LMU Gence Center Munich
On 18.11.2013 20:49, Eric Pettersen wrote:
To supplement Shawn and Tom's answers, obviously it would be best if everything were documented, but in the absence of that if there is a command that implements something similar to what you want to do, you can chase it down in the code base by:
a) looking at Midas/__init__.py and see if it's one of the functions in there (they're arranged approximately alphabetically by command name), and if it's not in there… b) grep share/*/ChimeraExtension.py for the command name to find which module defines the command. Then look in that module's ChimeraExtension.py to see what file/method in the module implements the command.
--Eric
Eric Pettersen UCSF Computer Graphics Lab
On Nov 18, 2013, at 9:06 AM, Shawn Waldon <swaldon@cs.unc.edu <mailto:swaldon@cs.unc.edu>> wrote:
Hi Martin,
I am not aware that there is a python library reference. If there is, I would appreciate a pointer to it as well. Here are a few links I have found helpful when writing python code for Chimera:
This shows how to execute command line commands, it may be what you want: http://www.cgl.ucsf.edu/chimera/data/downloads/1.8/docs/ProgrammersGuide/bas...
This goes through how to make plugins and such, but is helpful since the examples show more of the API: http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/Examples/index.html
HTH, Shawn Waldon
On Mon, Nov 18, 2013 at 9:10 AM, Martin Turk <turk@lmb.uni-muenchen.de <mailto:turk@lmb.uni-muenchen.de>> wrote:
Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
-- Shawn Waldon Graduate Research Assistant Department of Computer Science University of North Carolina at Chapel Hill swaldon@cs.unc.edu <mailto:swaldon@cs.unc.edu> _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu <mailto:Chimera-dev@cgl.ucsf.edu> http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
<chimera-volbymass3.py>

Hi Martin, Here's some example Python code that opens a map an sets the contour level to 1.2 and displays it. from chimera import openModels vlist = openModels.open('/Users/goddard/Downloads/Chimera/EMDB/emd_1080.map') v = vlist[0] v.set_parameters(surface_levels = [1.2]) v.show() Or you can simply run a Chimera command from Python from chimera import runCommand runCommand("volume #0 level 1.2") There are more examples of Python code at the Chimera Python scripts web page http://plato.cgl.ucsf.edu/trac/chimera/wiki/Scripts Unfortunately there is not a reference manual listing all the available Python functions -- something we will remedy in Chimera 2, but that will not be out for perhaps a year. The density map data structure called "Volume" is defined in Python code included in Chimera chimera/share/VolumeViewer/volume.py so you can look at what Python methods are available by looking at that source code. Tom On Nov 18, 2013, at 6:10 AM, Martin Turk <turk@lmb.uni-muenchen.de> wrote:
Hi,
I am trying to write a simple python script that will iterate over opened volumes and adjust the contour level to a certain mass. This shouldn't be more than ~10 lines. However, I can't find chimera's python library reference to look up the class structure and operator names.
Does someone know how, for example, set volume level to 0.01 would look like in python? in the command line it would be for all models: volume #0-99 level 0.01
for models I've found chimera.openModels and then you can list over them, but that's about it.
Thanks, Martin Turk _______________________________________________ Chimera-dev mailing list Chimera-dev@cgl.ucsf.edu http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-dev
participants (4)
-
Eric Pettersen
-
Martin Turk
-
Shawn Waldon
-
Tom Goddard