Function manipulating CHFL_TRAJECTORYΒΆ

The Trajectory type is the main entry point when using chemfiles. A trajectory behave a bit like a FILE* pointer, and the chfl_close free the memory associated with the file.

CHFL_TRAJECTORY * chfl_trajectory_open(const char * filename, char mode)

Open a trajectory file.

Return
A pointer to the file, or NULL in case of error
Parameters
  • filename -

    The path to the trajectory file

  • mode -

    The opening mode: ‘r’ for read, ‘w’ for write and ‘a’ for append.

CHFL_TRAJECTORY * chfl_trajectory_with_format(const char * filename, char mode, const char * format)

Open a trajectory file using a specific file format.

This can be needed when the file format does not match the extension, or when there is not standard extension for this format.

Return
A pointer to the file, or NULL in case of error
Parameters
  • filename -

    The path to the trajectory file

  • mode -

    The opening mode: ‘r’ for read, ‘w’ for write and ‘a’ for append.

  • format -

    The file format to use. An empty string means that the format should be guessed from the extension.

int chfl_trajectory_read(CHFL_TRAJECTORY * file, CHFL_FRAME * frame)

Read the next step of the trajectory into a frame.

Return
The status code.
Parameters
  • file -

    A pointer to the trajectory

  • frame -

    A frame to fill with the data

int chfl_trajectory_read_step(CHFL_TRAJECTORY * file, size_t step, CHFL_FRAME * frame)

Read a specific step of the trajectory in a frame.

Return
The status code.
Parameters
  • file -

    A pointer to the trajectory

  • step -

    The step to read

  • frame -

    A frame to fill with the data

int chfl_trajectory_write(CHFL_TRAJECTORY * file, const CHFL_FRAME * frame)

Write a frame to the trajectory.

Return
The status code.
Parameters
  • file -

    The trajectory to write

  • frame -

    the frame which will be writen to the file

int chfl_trajectory_set_topology(CHFL_TRAJECTORY * file, const CHFL_TOPOLOGY * topology)

Set the topology associated with a trajectory. This topology will be used when reading and writing the files, replacing any topology in the frames or files.

Return
The status code.
Parameters
  • file -

    A pointer to the trajectory

  • topology -

    The new topology to use

int chfl_trajectory_set_topology_file(CHFL_TRAJECTORY * file, const char * filename)

Set the topology associated with a trajectory by reading the first frame of filename; and extracting the topology of this frame.

Return
The status code.
Parameters
  • file -

    A pointer to the trajectory

  • filename -

    The file to read in order to get the new topology

int chfl_trajectory_set_topology_with_format(CHFL_TRAJECTORY * file, const char * filename, const char * format)

Set the topology associated with a trajectory by reading the first frame of filename using the file format in format; and extracting the topology of this frame.

This can be needed when the topology file format does not match the extension, or when there is not standard extension for this format.

Return
The status code.
Parameters
  • file -

    A pointer to the trajectory

  • filename -

    The file to read in order to get the new topology

  • format -

    The name of the file format to use for reading the topology. An empty string means that the format should be guessed from the extension.

int chfl_trajectory_nsteps(CHFL_TRAJECTORY * file, size_t * nsteps)

Get the number of steps (the number of frames) in a trajectory.

Return
The status code.
Parameters
  • file -

    A pointer to the trajectory

  • nsteps -

    This will contain the number of steps

int chfl_trajectory_close(CHFL_TRAJECTORY * file)

Close a trajectory file, and free the associated memory.

Return
The status code
Parameters
  • file -

    A pointer to the file