[Chimera-users] fit map --nogui
Thomas Goddard
goddard at cgl.ucsf.edu
Mon May 18 11:35:52 PDT 2009
Hi Sean,
That fitnogui.py script from 2 years ago is not compatible with the
current Chimera 1.4. Here's an updated version of the script
http://socrates2.cgl.ucsf.edu/trac/chimera/wiki/Scripts
The Chimera fitting only does a local optimization so the starting
position has to be close to the correct fit for it to work.
To write the fit map out in the new orientation you have to
interpolate it on a new grid because the map file formats don't support
specifying a rotation of the coordinate system. There is a Chimera
command to do that "vop" (volume operation). For example if map #1 has
been fit to map #0 the following commands will interpolate the new map
#1 placement at the grid points of map #0 and save the resulting map
(#5) to a new file.
vop #1 resample onGrid #0 modelId 5
volume #5 save /tmp/newmap.mrc
Here's documentation
http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/vop.html
http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/volume.html
You can run such commands from Python as follows.
from chimera import runCommand as r
r('vop #1 resample onGrid #0 modelId 5')
Unfortunately there is not a Chimera command for the fitting that would
allow you to avoid the Python altogether. There is a command in Chimera
1.4 daily builds to report the rotation/translation of one model
relative to another
measure rotation #0 #1
Matrix rotation and translation
1.00000000 -0.00008162 0.00004438 0.00003441
0.00008162 1.00000000 -0.00001398 -0.00008961
-0.00004438 0.00001398 1.00000000 0.00031721
Axis 0.14880493 0.47238450 0.86874045
Axis point 2.47734414 -0.01307674 0.00000000
Rotation angle (degrees) 0.00538331
Shift along axis 0.00023836
The measure command is described here
http://www.cgl.ucsf.edu/chimera/docs/UsersGuide/midas/measure.html
Tom
sean connell wrote:
> 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)
> _______________________________________________
> Chimera-users mailing list
> Chimera-users at cgl.ucsf.edu
> http://www.cgl.ucsf.edu/mailman/listinfo/chimera-users
More information about the Chimera-users
mailing list