Skip to content
Sections
Personal tools
You are here: Home » BALLView » Support » PythonScripts » Scripts » VisualiseTrajectory.py

VisualiseTrajectory.py

Document Actions
Create a sphere for the position of every non hydrogen atom for every snapshot in a trajectory.
dcd = DCDFile("test.dcd")
system = getComposites()[0]
number_ss = dcd.getNumberOfSnapShots()

ssm = SnapShotManager(system, getMolecularStructure().getForceField(), dcd)
nr_ss = dcd.getNumberOfSnapShots()

rep = Representation()

positions = []
for atom in atoms(system):
  if atom.getElement().getSymbol() == "H":
    continue
  positions.append(atom.getPosition())

  
current_ss = 0
while ssm.applyNextSnapShot():
  current_ss = current_ss + 1
  ratio = float(current_ss) / float(nr_ss)
  i = 0
  for atom in atoms(system):
    if atom.getElement().getSymbol() == "H":
      continue
    sphere = Sphere()
    sphere.setPosition((positions[i] + atom.getPosition()) / 2.0)
    sphere.setComposite(atom)
    sphere.setColor(ColorRGBA(1.0 - ratio, 1.0 - ratio, ratio))
    sphere.setRadius(0.03)
    rep.insert(sphere) &bsp; &bsp; &bsp;
    i = i + 1

getMainControl().insert(rep)
getMainControl().update(rep)
getMainControl().update(system)
 
 

Powered by Plone

This site conforms to the following standards: