[Chimera-users] Sum of volume data values

Thomas Goddard goddard at cgl.ucsf.edu
Wed Apr 12 15:28:05 PDT 2006


Hi Eran,

  You can open your MRC file in Chimera, then open the following
script "volumesum.py" which contains Python code to have the sum of
all the volume values printed.  Use menu entry File / Open to open
both files.  If you want to do this many times I can give you a
modified version that creates a Chimera menu entry (under the Tools
menu) that runs the script.

	Tom

------------
File volumesum.py follows:

# Script to print the sum of volume data values.

# Get the volume dialog object
import VolumeViewer
d = VolumeViewer.volume_dialog()

# Get the volume data currently shown by the volume dialog
dr = d.focus_region
m = dr.full_matrix()

# Compute the sum of the elements of the volume matrix.
import Numeric
sum = Numeric.sum(m.flat)

# Print the sum to the reply log dialog.
message = 'Sum of values of %s = %.6g' % (dr.full_name(), sum)
print message

# Display the reply log dialog.
from chimera import dialogs
dialogs.display('reply')

-------------


> Date: Wed, 12 Apr 2006 13:52:26 -0700
> From: Eran Shacham <eshacham at burnham.org>
> To: Thomas Goddard <goddard at cgl.ucsf.edu>
> Subject: Reading mrc files
> 
> Hi Tom,
> 
> Can I use Chimera's code for reading in mrc files? Essentially, I would 
> like to read in an mrc file and access its values. It is a mask file, 
> and I simply need to add up it values. Any suggestions on how to do that 
> easily with a Chimera module?
> 
> Cheers,
> Eran



More information about the Chimera-users mailing list