In [3]:
from chemview import MolecularViewer
from chemview import enable_notebook
enable_notebook()

import numpy as np



In [4]:
# Drawing a water molecule
mv = MolecularViewer(np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0]]),
                     {'atom_types': ['H', 'O', 'H'],
                      'bonds': [[0, 1], [1, 2]]},
                     width = 300,
                     height = 300)
#mv.points()
#mv.lines()
mv.ball_and_sticks()
mv

In [5]:
mv.coordinates = mv.coordinates + 0.01

In [6]:
# We use MDTraj to get a secondary structure
import mdtraj as md
traj = md.load_pdb('2M6K.pdb')
print traj


---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-6-b4047e7da214> in <module>()
      1 # We use MDTraj to get a secondary structure
----> 2 import mdtraj as md
      3 traj = md.load_pdb('2M6K.pdb')
      4 print traj

ImportError: No module named mdtraj

In [7]:
# We build our version of topology

top = {}
top['atom_types'] = [a.element.symbol for a in traj.topology.atoms]
top['atom_names'] = [a.name for a in traj.topology.atoms]
top['bonds'] = [(a.index, b.index) for a, b in traj.topology.bonds]
top['secondary_structure'] = md.compute_dssp(traj[0])[0]
top['residue_types'] = [r.name for r in traj.topology.residues ]
top['residue_indices'] = [ [a.index for a in r.atoms] for r in traj.topology.residues ]

mv = MolecularViewer(traj.xyz[0], top)
mv.cylinder_and_strand()
#mv.line_ribbon()
#mv.wireframe()
mv


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-7-c7d06afe6a81> in <module>()
      2 
      3 top = {}
----> 4 top['atom_types'] = [a.element.symbol for a in traj.topology.atoms]
      5 top['atom_names'] = [a.name for a in traj.topology.atoms]
      6 top['bonds'] = [(a.index, b.index) for a, b in traj.topology.bonds]

NameError: name 'traj' is not defined

In [8]:
from chemview.widget import TrajectoryControls

tc = TrajectoryControls(traj.n_frames)

def update():
    mv.coordinates = traj.xyz[tc.frame]

tc.on_trait_change(update, "frame")
tc.fps = 10
tc


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-8-657f986eac7b> in <module>()
      1 from chemview.widget import TrajectoryControls
      2 
----> 3 tc = TrajectoryControls(traj.n_frames)
      4 
      5 def update():

NameError: name 'traj' is not defined