File: charmm_trj_blur.py

package info (click to toggle)
openstructure 2.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 206,240 kB
  • sloc: cpp: 188,571; python: 36,686; ansic: 34,298; fortran: 3,275; sh: 312; xml: 146; makefile: 29
file content (45 lines) | stat: -rw-r--r-- 1,422 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
36
37
38
39
40
41
42
43
44
45
# trajectory generated by Raimund Dutzler
from PyQt5 import QtCore
scene.RemoveAll()


class Anim(QtCore.QTimer):
  """
  Timer used to animate the trajectory on screen. Each time the OnTimer
  method gets called we advance the trajectory by one step and render
  the scene on the screen.
  """
  def __init__(self,cg,go):
      QtCore.QTimer.__init__(self)
      self.cg_=cg
      self.go_=go
      self.frame_=0
      self.timeout.connect(self.OnTimer)
      
  def OnTimer(self):
    self.frame_=(self.frame_+1)%self.cg_.GetFrameCount()
    self.go_.BlurSnapshot()
    self.cg_.CopyFrame(self.frame_)
    self.go_.UpdatePositions()
        

# load CHARMM trajectory from sample.pdb and sample.dcd
cg = io.LoadCHARMMTraj("data/sample.pdb","data/sample.dcd")
# create graphical representation of the entity
eh=cg.GetEntity()
# we don't want to display the hydrogen atoms, so select everything that is 
# not a hydrogen and pass that view to the gfx.Entity() constructor.
ev=eh.Select("not ele=H")
go=gfx.Entity("mol",gfx.SIMPLE, ev)
# enable the blur effect
go.SetBlur(True)

# add it to the scene for rendering
scene.Add(go)
scene.SetCenter(go.GetCenter())
scene.AutoAutoslab(True)

# create an animation timer and start it
anim=Anim(cg,go)
print('Demo 6: Import of a CHARMM trajectory. Type anim.stop() to halt animation, anim.start(100) to start it again with stepsize 100!Starting animation now....')
anim.start(50)