mdtraj.formats.AmberRestartFile¶
-
class
mdtraj.formats.
AmberRestartFile
(filename, mode='r', force_overwrite=True)¶ Interface for reading and writing AMBER ASCII restart files. This is a file-like object, that supports both reading and writing depending on the mode flag. It implements the context manager protocol, so you can also use it with the python ‘with’ statement.
- Parameters
- filenamestr
The name of the file to open
- mode{‘r’, ‘w’}, default=’r’
The mode in which to open the file. Valid options are ‘r’ or ‘w’ for ‘read’ or ‘write’
- force_overwritebool, default=False
In write mode, if a file named filename already exists, clobber it and overwrite it
See also
md.AmberNetCDFRestartFile
Low level interface to AMBER NetCDF-format restart files
- Attributes
- n_atoms
- n_frames
Methods
read
(self[, atom_indices])Read data from an AMBER ASCII restart file
read_as_traj
(self, topology[, atom_indices])Read an AMBER ASCII restart file as a trajectory.
write
(self, coordinates[, time, …])Write one frame of a MD trajectory to disk in the AMBER ASCII restart file format.
close
-
__init__
(self, filename, mode='r', force_overwrite=True)¶ Initialize self. See help(type(self)) for accurate signature.
Methods
__init__
(self, filename[, mode, force_overwrite])Initialize self.
close
(self)read
(self[, atom_indices])Read data from an AMBER ASCII restart file
read_as_traj
(self, topology[, atom_indices])Read an AMBER ASCII restart file as a trajectory.
write
(self, coordinates[, time, …])Write one frame of a MD trajectory to disk in the AMBER ASCII restart file format.
Attributes
distance_unit
n_atoms
n_frames
-
read
(self, atom_indices=None)¶ Read data from an AMBER ASCII restart file
- Parameters
- atom_indicesnp.ndarray, dtype=int, optional
The specific indices of the atoms you’d like to retrieve. If not supplied, all of the atoms will be retrieved.
- Returns
- coordinatesnp.ndarray, shape=(1, n_atoms, 3)
The cartesian coordinates of the atoms, in units of angstroms. These files only ever contain 1 frame
- timenp.ndarray, None
The time corresponding to the frame, in units of picoseconds, or None if no time information is present
- cell_lengthsnp.ndarray, None
The lengths (a, b, c) of the unit cell for the frame in angstroms, or None if the information is not present in the file
- cell_anglesnp.ndarray, None
The angles (lpha, eta, gamma) defining the unit cell for each frame, or None if the information is not present in the file.
-
read_as_traj
(self, topology, atom_indices=None)¶ Read an AMBER ASCII restart file as a trajectory.
- Parameters
- topologyTopology
The system topology
- atom_indicesarray_like, optional
If not none, then read only a subset of the atoms coordinates from the file. This may be slightly slower than the standard read because it required an extra copy, but will save memory.
- Returns
- trajectoryTrajectory
A trajectory object with 1 frame created from the file.
-
write
(self, coordinates, time=None, cell_lengths=None, cell_angles=None)¶ Write one frame of a MD trajectory to disk in the AMBER ASCII restart file format.
- Parameters
- coordinatesnp.ndarray, dtype=np.float32, shape=([1,] n_atoms, 3)
The cartesian coordinates of each atom, in units of angstroms. Must be only a single frame (shape can be (1,N,3) or (N,3) where N is the number of atoms)
- timearray-like with 1 element or float, optional
The time corresponding to this frame. If not specified, a place holder of 0 will be written
- cell_lengthsnp.ndarray, dtype=np.double, shape=([1,] 3)
The lengths (a,b,c) of the unit cell for the frame in Angstroms
- cell_anglesnp.ndarray, dtype=np.double, shape=([1,] 3)
The angles between the unit cell vectors for the frame in Degrees