Importing a trajectory in DCD formatΒΆ

 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
# Conversion of a DCD trajectory (CHARMM/XPlor) to MMTK's trajectory format.
#
# Note: In order to create the files "rotation.dcd" and "rotation.pdb" which
#       are read by this example, you must run the example dcd_export.py.
#

from MMTK import *
from MMTK.Proteins import Protein
from MMTK.PDB import PDBConfiguration
from MMTK.Trajectory import Trajectory, TrajectoryOutput
from MMTK.DCD import DCDReader

# Create the universe.
universe = InfiniteUniverse()

# Create all objects from the PDB file. The PDB file *must* match the
# the DCD file (same atom order), and you *must* create all objects
# defined in the PDB file, otherwise interpretation of the DCD file
# is not possible.
conf = PDBConfiguration('rotation.pdb')
chain = conf.peptide_chains[0].createPeptideChain(c_terminus=1)
universe.addObject(Protein([chain]))

# Create the trajectory object for output.
t = Trajectory(universe, "rotation_from_dcd.nc", "w", "Converted from DCD")

# Create a DCD reader that reads all configurations.
dcd_reader = DCDReader(universe, dcd_file = 'rotation.dcd',
                       actions = [TrajectoryOutput(t, "all", 0, None, 1)])
# Run the reader...
dcd_reader()
# ... and close the output trajectory.
t.close()

This Page