8 stable releases

1.3.0 Mar 2, 2024
1.2.0 Jan 13, 2024
1.1.0 Oct 14, 2023
1.0.3 Sep 25, 2023

#84 in Science

Download history 6/week @ 2024-01-09 1/week @ 2024-02-20 135/week @ 2024-02-27 24/week @ 2024-03-05 5/week @ 2024-03-12 10/week @ 2024-03-26 49/week @ 2024-04-02

65 downloads per month

MIT license

34KB
567 lines

gcenter: Center Any Group in a Gromacs Trajectory

Center your chosen group within a Gromacs trajectory or structure file effortlessly using the Bai & Breen algorithm.

gcenter can accurately center atom groups, even when they span multiple molecules that may extend beyond the box boundaries. gcenter exclusively supports orthogonal simulation boxes.

gcenter supports gro, pdb, and tpr structure files and xtc and trr trajectories and it can autodetect protein residues. Use VMD-like groan selection language to select groups of atoms to center.

Installation

  1. Install rust.
  2. Run cargo install gcenter.

Example usage

gcenter -c system.gro -f trajectory.xtc -o output_trajectory.xtc

Options

Usage: gcenter [OPTIONS] --structure <STRUCTURE> --output <OUTPUT>

Options:
  -c, --structure <STRUCTURE>
          Path to a gro, pdb, or tpr file containing the system structure. If a trajectory is also provided, the coordinates from the structure file will be ignored.
          Currently, tpr file can only be used if a trajectory is also provided.

  -f, --trajectory [<TRAJECTORIES>...]
          Path to xtc or trr file(s) containing the trajectory or trajectories to be manipulated. 
          If not provided, the centering operation will use the structure file itself.
          Multiple files separated by whitespace can be provided. These will be concatenated into one output file.
          All trajectory files must be of the same type (i.e., all must be either xtc or trr files).
          When joining trajectories, the last frame of each trajectory and the first frame of the following trajectory are checked for matching simulation steps. 
          If the simulation steps coincide, only the first of these frames is centered and written to output.

  -n, --index <INDEX>
          Path to an ndx file containing groups associated with the system.
          
          [default: index.ndx]

  -o, --output <OUTPUT>
          Name of the output file, which can be in gro, pdb (if no trajectory is provided), xtc, or trr format.

  -r, --reference <REFERENCE>
          Specify the group to be centered. Use VMD-like 'groan selection language' to define the group. This language also supports ndx group names.
          
          [default: Protein]

  -b, --begin <START_TIME>
          Time of the first frame to read from the trajectory (in ps). All previous frames will be skipped. This option is only applicable when trajectory file(s) is/are provided.
          
          [default: 0.0]

  -e, --end <END_TIME>
          Time of the last frame to read from the trajectory (in ps). All following frames will be skipped. This option is only applicable when trajectory file(s) is/are provided.
          
          [default: NaN]

  -s, --step <STEP>
          Center and write only every <STEP>th frame of the trajectory to the output file. This option is only applicable when trajectory file(s) is/are provided.
          
          [default: 1]

  -x
          Perform centering operation in the x-dimension. This can be combined with other dimensions. If no dimensions are selected, it defaults to '-xyz'.

  -y
          Perform centering operation in the y-dimension. This can be combined with other dimensions. If no dimensions are selected, it defaults to '-xyz'.

  -z
          Perform centering operation in the z-dimension. This can be combined with other dimensions. If no dimensions are selected, it defaults to '-xyz'.

      --com
          Use center of mass instead of center of geometry when centering the reference group. This requires information about atom masses. 
          If they are not explicitly provided using a tpr file, the masses are guessed.

      --whole
          Do not wrap all atoms into the simulation box but keep molecules whole. This requires providing a tpr file as an input structure file.

      --silent
          Suppress all standard output generated by the 'gcenter' tool, except for error messages written to stderr.

      --overwrite
          Enable this option to overwrite existing files with the same name as the output file. No backup copies will be created.

  -h, --help
          Print help (see a summary with '-h')

  -V, --version
          Print version

Limitations

Only tested on Linux but should work anywhere.

Only supports orthogonal simulation boxes!

Dependencies

~11–22MB
~318K SLoC