[Chimera-users] fit map --nogui

sean connell sean.connell at mac.com
Mon May 18 04:57:49 PDT 2009


Hello, I am having some problems using/adapting a script I found by  
searching the mailing list.  The script is pasted below but to  
summarize it should print out the transformation matrix used to fit  
one map to another. In principle I would like to do the same but in  
addition to writing out the matrix I would also like to apply it and  
save the resulting map. I am currently using chimera 1.4 build 27496  
(Aqua on OSX 10.5.7)

the first problem I have is just invoking the python interpreter.....   
if I use:

Chimera.app/Contents/MacOS/chimera --nogui fittomap.py
Executing fittomap.py...
Traceback (most recent call last):
   File "/Users/src/Downloads/Chimera.app/Contents/Resources/share/ 
__main__.py", line 65, in <module>
     value = chimeraInit.init(sys.argv)
   File "/Users/src/Downloads/Chimera.app/Contents/Resources/share/ 
chimeraInit.py", line 407, in init
     chimera.openModels.open(a, prefixableType=1)
   File "/Users/src/Downloads/Chimera.app/Contents/Resources/share/ 
chimera/__init__.py", line 1357, in open
     models = func(filename, *args, **kw)
   File "/Users/src/Downloads/Chimera.app/Contents/Resources/share/ 
chimera/__init__.py", line 794, in _openPython
     loadFunc(sandboxName, fileName, f)
   File "fittomap.py", line 70, in <module>
     fit_map_in_map(p1, p2)
   File "fittomap.py", line 24, in fit_map_in_map
     from VolumeViewer import Data_Region, full_region,  
Rendering_Options
ImportError: cannot import name Data_Region
Error while processing fittomap.py:
ImportError: cannot import name Data_Region
(see reply log for Python traceback info)






#  
-----------------------------------------------------------------------------
# Example script for fitting one map in another without the graphical  
user
# interface.
#
#       chimera --nogui fitnogui.py
#
# It can also be run using the graphical Chimera interface using File/ 
Open.
#
def fit_map_in_map(map1_path, map2_path,
                    initial_map1_transform = None,
                    map1_threshold = None,
                    ijk_step_size_min = 0.01,    # Grid index units
                    ijk_step_size_max = 0.5,     # Grid index units
                    max_steps = 100,
                    optimize_translation = True,
                    optimize_rotation = True):


   # Files have to have file suffix indicating volume format.
   from VolumeData import open_file
   data1 = open_file(map1_path)
   data2 = open_file(map2_path)

   from VolumeViewer import Data_Region, full_region, Rendering_Options
   ro = Rendering_Options()
   map1 = Data_Region(data1, full_region(data1.size), '', ro)
   map2 = Data_Region(data2, full_region(data2.size), '', ro)

   if initial_map1_transform:
     from PDBmatrices.matrices import chimera_xform
     xf = chimera_xform(initial_map1_transform)
     map1.surface_model().openState.globalXform(xf)

   use_threshold = (map1_threshold != None)

   from FitMap import map_points_and_weights, motion_to_maximum
   points, point_weights = map_points_and_weights(map1, use_threshold)

   if len(points) == 0:
     if use_threshold:
       print 'No grid points above map threshold.'
     else:
       print 'Map has no non-zero values.'
     return

   move_tf, stats = motion_to_maximum(points, point_weights, map2,  
max_steps,
                                      ijk_step_size_min,  
ijk_step_size_max,
                                      optimize_translation,  
optimize_rotation)

   if initial_map1_transform:
     from PDBmatrices.matrices import multiply_matrices
     move_tf = multiply_matrices(move_tf, initial_map1_transform)

   header = ('\nFit map %s in map %s using %d points\n'
             % (map1.full_name(), map2.full_name(), stats['points']) +
             '  correlation = %.4g, overlap = %.4g\n'
             % (stats['correlation'], stats['overlap']) +
             '  steps = %d, shift = %.3g, angle = %.3g degrees\n'
             % (stats['steps'], stats['shift'], stats['angle']))
   print header

   from FitMap.gui import transformation_description
   tfs = transformation_description(move_tf)
   print tfs

#  
-----------------------------------------------------------------------------
# Example call fitting map into itself.
#
p1 = p2 = '/usr/local/src/chimera-demos/volume/examples/groel.mrc'
fit_map_in_map(p1, p2)



More information about the Chimera-users mailing list