Python script for reading volume values at atom positions

Hi Terry, Here is a Python script to read a volume map and a PDB file and print the values of the map interpolated at the atom positions. It will work without the Chimera graphical user interface. I tested it in Chimera 1.2415. Tom # ----------------------------------------------------------------------------- # Script that opens PDB and map files and prints the map values interpolated # at each atom position. Can be run without graphical user interface: # # chimera --nogui avalnogui.py # def map_values_at_atoms(pdb_path, map_path): # Open map file. # File name has to have file suffix indicating volume format. from VolumeData import open_file data = open_file(map_path) from VolumeViewer import Data_Region, full_region, Rendering_Options ro = Rendering_Options() map = Data_Region(data, full_region(data.size), '', ro) attribute_name = data.name.split('.')[0] # Open PDB model(s). from chimera import openModels molecules = openModels.open(pdb_path, 'PDB') # Interpolate map values at atom positions. from AtomDensity import set_atom_volume_values for mol in molecules: set_atom_volume_values(mol, map, attribute_name) # Print values. for mol in molecules: for a in mol.atoms: v = getattr(a, attribute_name) print '%-15s %12.4g' % (a.oslIdent(), v) # ----------------------------------------------------------------------------- # map_path = '/usr/local/src/chimera-demos/volume/examples/1a0m.omap' pdb_path = '/usr/local/src/chimera-demos/volume/examples/1a0m.pdb' map_values_at_atoms(pdb_path, map_path)

Thanks! I'll try to test it out tomorrow! Terry Tom Goddard wrote:
Hi Terry,
Here is a Python script to read a volume map and a PDB file and print the values of the map interpolated at the atom positions. It will work without the Chimera graphical user interface. I tested it in Chimera 1.2415.
Tom
------------------------------------------------------------------------
# ----------------------------------------------------------------------------- # Script that opens PDB and map files and prints the map values interpolated # at each atom position. Can be run without graphical user interface: # # chimera --nogui avalnogui.py # def map_values_at_atoms(pdb_path, map_path):
# Open map file. # File name has to have file suffix indicating volume format. from VolumeData import open_file data = open_file(map_path) from VolumeViewer import Data_Region, full_region, Rendering_Options ro = Rendering_Options() map = Data_Region(data, full_region(data.size), '', ro) attribute_name = data.name.split('.')[0]
# Open PDB model(s). from chimera import openModels molecules = openModels.open(pdb_path, 'PDB')
# Interpolate map values at atom positions. from AtomDensity import set_atom_volume_values for mol in molecules: set_atom_volume_values(mol, map, attribute_name)
# Print values. for mol in molecules: for a in mol.atoms: v = getattr(a, attribute_name) print '%-15s %12.4g' % (a.oslIdent(), v)
# ----------------------------------------------------------------------------- # map_path = '/usr/local/src/chimera-demos/volume/examples/1a0m.omap' pdb_path = '/usr/local/src/chimera-demos/volume/examples/1a0m.pdb' map_values_at_atoms(pdb_path, map_path)
-- P. Therese Lang Postdoctoral Scholar Alber Lab, UC Berkeley
participants (2)
-
Terry Lang
-
Tom Goddard