def load_trr(trr_file, top, velocities=True): """Load a TRR file, ready for use as input to an OpenMMEngine. This is a single method to handle several peculiarities of both the TRR format (which rounds some values) and OpenMM (which has certain requirements of box vectors), plus the possibility that you'll want velocities. Parameters ---------- trr_file : string name of TRR file to load top : string name of topology (e.g., ``.gro``) file to use. See MDTraj documentation on md.load. velocities : bool whether to also load velocities from the TRR file; default ``True`` Return ------ :class:`.Trajectory` the OPS trajectory, with OpenMM-reduced box vectors and velocities (if requested) """ mdt = md.load(trr_file, top=top) trr = md.formats.TRRTrajectoryFile(trr_file) if velocities: vel = trr._read(n_frames=len(mdt), atom_indices=None, get_velocities=True)[5] else: vel = None traj = trajectory_from_mdtraj(mdt, velocities=vel) return reduce_trajectory_box_vectors(traj)
def topology_from_pdb(pdb_file, simple_topology=False): """ Construct a Topology from the first frame in a pdb file without velocities Parameters ---------- pdb_file : str The filename of the .pdb file to be used simple_topology : bool if `True` only a simple topology with n_atoms will be created. This cannot be used with complex CVs but loads and stores very fast Returns ------- :class:`openpathsampling.engines.Snapshot` the constructed Snapshot """ pdb = md.load(pdb_file) if simple_topology: topology = Topology(*pdb.xyz[0].shape) else: topology = MDTrajTopology(pdb.topology) return topology
def __init__(self, gro): self.gro = gro traj = md.load(gro) self.topology = MDTrajTopology(traj.topology) n_atoms = self.topology.n_atoms n_spatial = self.topology.n_spatial descriptor = SnapshotDescriptor.construct( snapshot_class=self.SnapshotClass, snapshot_dimensions={ 'n_spatial': n_spatial, 'n_atoms': n_atoms }) super(_GroFileEngine, self).__init__(options={}, descriptor=descriptor, template=None)
def ops_load_trajectory(filename, **kwargs): error_if_no_mdtraj("ops_load_trajectory") return trajectory_from_mdtraj(md.load(filename, **kwargs))
def read_frame_data(self, file_name, file_position): traj = md.load(file_name) xyz = traj.xyz[0] vel = np.zeros(shape=xyz.shape) box = traj.unitcell_vectors[0] return (xyz, vel, box)