File: entity_to_density.py

package info (click to toggle)
openstructure 2.9.3-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 205,228 kB
  • sloc: cpp: 188,129; python: 35,361; ansic: 34,298; fortran: 3,275; sh: 286; xml: 146; makefile: 29
file content (35 lines) | stat: -rw-r--r-- 1,290 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from ost.mol import alg
# tabula rasa first
scene.RemoveAll()

# load the fragment
frag=io.LoadPDB('data/1crn.pdb')

# now let's calculate the size of the map by taking the bounding box of
# the fragment and adding 5 Angstrom on each side.
frag_bounds=frag.bounds
real_size=frag_bounds.max-frag_bounds.min+geom.Vec3(10,10,10)
# We use 2 pixels per Angstroem, so we have to multiply the size by 2.
map_size=img.Size(int(real_size.x)*2, int(real_size.y)*2, int(real_size.z)*2)
den_map=img.CreateImage(map_size)
# we use 2 pixels per Angstrom
den_map.SetSpatialSampling(2)
den_map.SetAbsoluteOrigin(frag_bounds.min-geom.Vec3(5, 5, 5))


# Calculate a density map from the fragment using a simple real-space method:
#
# This function is based on Dimaio et al.,J. Mol. Biol(2009)
# In essence every atom gives rise to a Gaussian centered at the atom's
# position. Sigma and Magnitude of the Gaussian are calculated from the
# atomic mass.
alg.EntityToDensityRosetta(frag.CreateFullView(), den_map,
                           alg.HIGH_RESOLUTION, 5.0)

# Create Graphical Representations and add to the Scene
gfx_frag=gfx.Entity('Fragment', gfx.HSC, frag)
gfx_frag.SetColor(gfx.YELLOW)
gfx_map=gfx.MapIso('Density', den_map, 250.0)
scene.Add(gfx_frag)
scene.Add(gfx_map)
scene.CenterOn(gfx_frag)