The MDAnalysis.coordinates.xdrfile.core module contains generic classes to access Gromacs XDR-encoded trajectory formats such as TRR and XTC.
A generic Gromacs trajectory is simply called “trj” within this module.
See also
MDAnalysis.coordinates.base for the generic MDAnalysis base classes and MDAnalysis.coordinates.xdrfile.libxdrfile2 for the low-level bindings to the XDR trajectories.
The generic classes are subclassed to generate the specific classes for the XTC and TRR format.
Changed in version 0.8.0: The XTC/TRR I/O interface now uses libxdrfile2, which has seeking and indexing capabilities. Note that unlike libxdrfile before it, libxdrfile2 is distributed under the GNU GENERAL PUBLIC LICENSE, version 2 (or higher).
Changed in version 0.9.0: TrjReader now stores the offsets used for frame seeking automatically as a hidden file in the same directory as the source trajectory. These offsets are automatically retrieved upon TrjReader instantiation, resulting in substantially quicker initialization times for long trajectories. The ctime and filesize of the trajectory are stored with the offsets, and these are checked against the trajectory on load to ensure the offsets aren’t stale. The offsets are automatically regenerated if they are stale or missing.
Timestep for a Gromacs trajectory.
Generic base class for reading Gromacs trajectories inside MDAnalysis.
Derive classes and set TrjReader.format, TrjReader._read_trj and TrjReader._read_trj_atoms.
reader = TrjReader(“file.trj”) for ts in reader:
print ts
Arguments : |
|
---|---|
Keywords : |
|
Changed in version 0.9.0: New keyword refresh_offsets
Returns a Gromacs TrjWriter for filename with the same parameters as this trajectory.
All values can be changed through keyword arguments.
Arguments : |
|
---|---|
Keywords : |
|
Returns : | appropriate TrjWriter |
Time step length in ps.
The result is computed from the trajectory and cached. If for any reason the trajectory cannot be read then 0 is returned.
override to define trajectory format of the reader (XTC or TRR)
Loads current trajectory offsets from pickled filename.
Checks if ctime and size of trajectory file matches that stored in pickled filename. If either one does not match (and check == True) then the offsets are not loaded. This is intended to conservatively avoid loading out-of-date offsets.
Arguments : |
|
---|---|
Keywords : |
|
Raises : | IOError if the file cannot be read (see open()). |
The number of publically available atoms that this reader will store in the timestep.
If ‘sub’ was not given in the ctor, then this value will just be the actual number of atoms in the underlying trajectory file. If however ‘sub’ was given, then this value is the number specified by the ‘sub’ sub-selection.
If for any reason the trajectory cannot be read then a negative value is returned.
Read the number of frames from the trajectory.
The result is cached. If for any reason the trajectory cannot be read then 0 is returned.
This takes a long time because the frames are counted by iterating through the whole trajectory. If the trajectory was previously loaded and saved offsets exist, then loading will be significantly faster.
See also
Open xdr trajectory file.
Returns : | pointer to XDRFILE (and sets self.xdrfile) |
---|---|
Raises : | IOError with code EALREADY if file was already opened or ENOENT if the file cannot be found |
Saves current trajectory offsets into filename, as a pickled object.
Along with the offsets themselves, the ctime and file size of the trajectory file are also saved. These are used upon load as a check to ensure the offsets still match the trajectory they are being applied to.
Arguments : |
|
---|
units of time (ps) and length (nm) in Gromacs
Writes to a Gromacs trajectory file
(Base class)
Create a new TrjWriter
Arguments : |
|
---|---|
Keywords : |
|
Changed in version 0.8.0: The TRR writer is now able to write TRRs without coordinates/velocities/forces, depending on the properties available in the Timestep objects passed to write().
Read dimensions from timestep ts and return Gromacs box vectors
override to define trajectory format of the reader (XTC or TRR)
units of time (ps) and length (nm) in Gromacs