Hi Eran,
Ok, here is code to read an MRC file and print the sum of map values
without using Chimera. You need Python, the Numeric Python module which
handles multidimensional arrays and the VolumeData module from Chimera.
Numeric is obtained from sourceforge:
http://sourceforge.net/project/showfiles.php?group_id=1369&package_id=1351
The VolumeData module is in your Chimera distribution.
chimera/share/VolumeData
Here's an example running the script where I've set PYTHONPATH to have
access to the VolumeData module:
% env PYTHONPATH=/usr/local/chimera/share python2.4 volumesum2.py
Sum of values of groel.mrc = 21720.8984375
Send future questions to chimera-users@cgl.ucsf.edu so others who
have similar problems can benefit. I get that email just as fast.
Tom
-------
file volumesum2.py follows:
# Script to print the sum of volume data values.
# Does not need Chimera, just the VolumeData module and Numeric and Python.
path = 'groel.mrc'
# Read the MRC volume data and get the 3-D Numeric array.
from VolumeData.mrc.mrc_format import MRC_Data
data = MRC_Data(path)
m = data.matrix()
# Compute the sum of the elements of the volume matrix.
import Numeric
sum = Numeric.sum(m.flat)
# Print the sum
print 'Sum of values of', path, ' = ', sum
-------
Date: Wed, 12 Apr 2006 14:46:14 -0700
From: Eran Shacham <eshacham@burnham.org>
To: Thomas Goddard <goddard@cgl.ucsf.edu>
Subject: Re: Sum of volume data values
Hey Tom,
Thanks for your reply. However, I would like to do that from within a
script I already wrote. i.e I would like to integrate a read_in method
for an MRC file, access it values and then calculate the sum. I would
like to avoid doing that by opening my file in Chimera at this stage of
the program. Can it be done by importing some of your code?
Thanks,
Eran.