Gromacs  2021-beta2-UNCHECKED
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Enumerations | Files
Handling of writing new coordinate files
+ Collaboration diagram for Handling of writing new coordinate files:


Provides basic functions to handle writing of new coordinate files.

The methods included in the coordinateio module implement the basics for manipulating and writing coordinate trajectory files and changing metadata in the underlying datastructures. Included are a container for storing modules that change trajectory data, as well as a manager to write output files that uses those methods. It can be used from within Framework for Trajectory Analysis (trajectoryanalysis), and uses methods from:


The methods in coordinateio provide the infrastructure to perform operations on coordinate data files and structures during data analysis. It implements ways to change the information in coordinate data structures as well as checking that both input data and output method are matching for a given coordinate file writing operation. For this components verify first that all the requirements can be satisfied. Then components are build that will change the coordinate information accordingly.

The main parts are the outputadapters implemented using the IOutputAdapter interface to change information in a local (deep) copy of t_trxframes stored in the coordinatefile.


Each OutputAdapter module implements the same IOutputAdapter interface and has to set its requirements for final processing as a flag from the enum in requirementflags. During processing, they implement a custom version of the processFrame directive that modifies the stored trajectory data before writing a new file to disk.

The interaction between the CoordinateFile and the OutputAdapter modules derived from IOutputAdapter is shown in the diagram below.


Once the CoordinateFile object and its registered modules are created, they can be used to iterate over input data to write new coordinate frames.


Preparing new OutputAdapters

If additional methods are needed to perform changes to the t_trxframe metadata, new OutputAdapters can be written that again implement the IOutputAdapter interface. The new method should follow the approach of the other modules that are present in changing a minimal set of t_trxframe data.

Paul Bauer


class  gmx::TrajectoryFileOpener
 Low level method to take care of only file opening and closing. More...
class  gmx::TrajectoryFrameWriter
 Writes coordinate frames to a sink, e.g. a trajectory file. More...
class  gmx::IOutputAdapter
 OutputAdapter class for handling trajectory file flag setting and processing. More...
class  gmx::OutputSelector
 OutputSelector class controls setting which coordinates are actually written. More...
class  gmx::SetAtoms
 SetAtoms class controls availability of atoms data. More...
class  gmx::SetBox
 Allows changing box information when writing a coordinate file. More...
class  gmx::SetForces
 SetForces class allows changing writing of forces to file. More...
class  gmx::SetPrecision
 SetPrecision class allows changing file writing precision. More...
class  gmx::SetStartTime
 SetStartTime class allows changing trajectory time information. More...
class  gmx::SetTimeStep
 SetTimeStep class allows changing trajectory time information. More...
class  gmx::SetVelocities
 SetVelocities class allows changing writing of velocities to file. More...


enum  gmx::CoordinateFileFlags : unsigned long {
  gmx::CoordinateFileFlags::Base = 1 << 0, gmx::CoordinateFileFlags::RequireForceOutput = 1 << 1, gmx::CoordinateFileFlags::RequireVelocityOutput = 1 << 2, gmx::CoordinateFileFlags::RequireAtomConnections = 1 << 3,
  gmx::CoordinateFileFlags::RequireAtomInformation = 1 << 4, gmx::CoordinateFileFlags::RequireChangedOutputPrecision = 1 << 5, gmx::CoordinateFileFlags::RequireNewFrameStartTime = 1 << 6, gmx::CoordinateFileFlags::RequireNewFrameTimeStep = 1 << 7,
  gmx::CoordinateFileFlags::RequireNewBox = 1 << 8, gmx::CoordinateFileFlags::RequireCoordinateSelection = 1 << 9, gmx::CoordinateFileFlags::Count
 The enums here define the flags specifying the requirements of different outputadapter modules. More...


file  coordinatefile.cpp
 Implements methods from coordinatefile.h.
file  coordinatefile.h
 CoordinateFile takes care of opening files and writing output to them.
file  enums.h
 Enum class defining the different requirements that outputadapters have for the output file type. OutputManager objects can only be built with OutputAdapters whose requirements can be implemented with the available input.
file  ioutputadapter.h
 Declares gmx::IOutputAdapter interface for modifying coordinate file structures before writing them to disk.
file  outputadaptercontainer.cpp
 Implements gmx::OutputAdapterContainer.
file  outputadaptercontainer.h
 Declares gmx::OutputAdapterContainer, a storage object for multiple outputadapters derived from the IOutputadaper interface.
file  outputselector.cpp
 Implements outputselector class.
file  outputselector.h
 Declares gmx::OutputSelector.
file  setatoms.cpp
 Implements setatoms class.
file  setatoms.h
 Declares gmx::SetAtoms.
file  setbox.h
 Declares gmx::SetBox.
file  setforces.cpp
 Implements setforce class.
file  setforces.h
 Declares gmx::SetForces.
file  setprecision.cpp
 Implements setprecision class.
file  setprecision.h
 Declares gmx::SetPrecision.
file  setstarttime.cpp
 Implements setstarttime class.
file  setstarttime.h
 Declares gmx::SetStartTime.
file  settimestep.cpp
 Implements settimestep class.
file  settimestep.h
 Declares gmx::SetTimeStep.
file  setvelocities.cpp
 Implements SetVelocities class.
file  setvelocities.h
 Declares gmx:SetVelocities.
file  outputadapters.h
 Public API convenience header for accessing outputadapters.
file  requirements.cpp
 Implements helper function to populate requirements from user input.
file  requirements.h
 Storage object for requirements to build coordinate file writer.
file  builder.cpp
 Tests for outputmanager.
file  coordinate_test.h
 Helper classes for coordinatefile and coordinateio tests.
file  outputadaptercontainer.cpp
 Tests for outputadaptercontainer.
file  outputadapters.cpp
 Tests for outputmanager.
file  outputadapters.h
 Helpers and data for outputadapter module tests.
file  requirements.cpp
 Tests for processing of user input.
file  requirements.h
 Helpers and data for flag setting method.
file  setatoms.cpp
 Tests for gmx::SetAtoms.
file  setbothtime.cpp
 Tests for combination of gmx::SetTimeStep and gmx::SetStartTime.
file  setstarttime.cpp
 Tests for gmx::SetStartTime.
file  settimestep.cpp
 Tests for gmx::SetTimeStep.
file  testmodule.cpp
 Implements test module.
file  testmodule.h
 Dummy module used for tests and as an implementation example.
file  coordinateio.h
 Public API convenience header for coordinate file output.

Enumeration Type Documentation

enum gmx::CoordinateFileFlags : unsigned long

The enums here define the flags specifying the requirements of different outputadapter modules.

When building the object for deciding on the output to a new coordinate file, the CoordinateFile object needs to be able to validate that the dependencies of attached IOutputAdapters are fulfilled. Classes and interfaces that use the enum can check their dependencies against the information encoded in the flags and can then perform an appropriate reaction if there is a mismatch.

Use std::bitset<16> for the entries.

Base setting that says that the module has no requirements.

Sets the flags to default setting to make sure all output methods are supported.


Requires output method to support force output.

If set, only output methods supporting writing of forces will work, others will generate an invalid input error.


Requires output method to support velocity output.

If set, only writing to files that support velocity output will succeed. Other writing methods will generate an error.


Requires support for connection information in output format.

If set, only file output that supports writing of connection information will succeed. This means for now that only PDB and TNG files can be written. Other file writing methods will fail.


Requires that output format supports the writing of atom information to the file.

If set, files will only be written if they can output the information from t_atoms and otherwise create an error while writing.


Requires that output format supports writing user-specified output precision.

If set, output will only be written if the format supports the writing of custom precision of the included data.


Requires that output format supports writing time to the file.


Requires that output format supports writing time to the file.


Requires that output format supports writing box information.


Requires output to support changes to selection of coordinates.

Default for most methods, will need to be able to write coordinates to output file or generate an error.


Needed for enumeration array.