Download Desmond User's Guide

Transcript
133
CHAPTER 11. TRAJECTORY FORMAT AND ANALYSIS
The iterators can be accessed via the at time near, at time lt, at time le, at time gt,
at time ge methods.
11.4.3
molfile module
The molfile module is a Python interface to the set of file I/O plugins that are included
with the program VMD, developed at the University of Illinois. The Python interface
provides methods for creating, loading and saving molecular structures and coordinates
to all the file formats supported by VMD.
Below is a synopsis of how to perform common tasks using molfile.
Example 11.11
import molfile
# Reading a structure file:
reader = molfile.mae.read(’/path/to/foo.mae’)
# Iterating through the frames in a file:
for frame in molfile.dtr.read(’/path/to/foo.dtr’).frames():
function( frame.pos, frame.vel, frame.time, frame.box )
# Random access to frames (only dtr files support this currently):
f27 = molfile.dtr.read(’/path/to/foo.dtr’).frame(27) # 0-based index
# Convert an mae file to a pdb file:
input=molfile.mae.read(’foo.mae’)
output=molfile.pdb.write(’foo.pdb’, atoms=input.atoms)
output.frame(input.frames().next())
output.close()
# Write every 10th frame in a dtr to a trr:
input=molfile.dtr.read(’big.dtr’)
output=molfile.trr.write(’out.trr, natoms=input.natoms)
for i in range(0,input.nframes, 10):
output.frame( input.frame(i) )
output.close()