Skip to content
Snippets Groups Projects
Select Git revision
  • 33d64b5abfd0373f5a04e7b84067ad1953bec110
  • master default protected
  • develop protected
  • cmake_boost_refactor
  • ubuntu_ci
  • mmtf
  • non-orthogonal-maps
  • no_boost_filesystem
  • data_viewer
  • 2.11.1
  • 2.11.0
  • 2.10.0
  • 2.9.3
  • 2.9.2
  • 2.9.1
  • 2.9.0
  • 2.8.0
  • 2.7.0
  • 2.6.1
  • 2.6.0
  • 2.6.0-rc4
  • 2.6.0-rc3
  • 2.6.0-rc2
  • 2.6.0-rc
  • 2.5.0
  • 2.5.0-rc2
  • 2.5.0-rc
  • 2.4.0
  • 2.4.0-rc2
29 results

entity_to_density.py

Blame
  • user avatar
    marco authored
    git-svn-id: https://dng.biozentrum.unibas.ch/svn/openstructure/trunk@2614 5a81b35b-ba03-0410-adc8-b2c5c5119f08
    b5802731
    History
    entity_to_density.py 1.26 KiB
    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)