Scripts: avalnogui.py

File avalnogui.py, 1.2 KB (added by goddard, 9 years ago)
Line 
1# -----------------------------------------------------------------------------
2# Script that opens PDB and map files and prints the map values interpolated
3# at each atom position. Can be run without graphical user interface:
4#
5# chimera --nogui --silent --script "avalnogui.py 1a0m.pdb 1a0m.omap"
6#
7def map_values_at_atoms(pdb_path, map_path):
8
9 # Open map file.
10 # File name has to have file suffix indicating volume format.
11 from VolumeViewer import open_volume_file
12 maps = open_volume_file(map_path)
13 map = maps[0] # File could have multiple arrays, use first
14 attribute_name = map.name.split('.')[0]
15
16 # Open PDB model(s).
17 from chimera import openModels
18 molecules = openModels.open(pdb_path, 'PDB')
19
20 # Interpolate map values at atom positions.
21 from AtomDensity import set_atom_volume_values
22 for mol in molecules:
23 set_atom_volume_values(mol, map, attribute_name)
24
25 # Print values.
26 for mol in molecules:
27 for a in mol.atoms:
28 v = getattr(a, attribute_name)
29 print '%-15s %12.4g' % (a.oslIdent(), v)
30
31# -----------------------------------------------------------------------------
32#
33pdb_path, map_path = arguments
34map_values_at_atoms(pdb_path, map_path)