CDTK.gmx2cdtk module

This module has several functions to transform coordinates and velocities obtained from Gromacs calculation into suitable input files for CDTK. Use gmx2cdtk -h to find out how to use this program.

Basic units in GMX, please look at the following web. https://manual.gromacs.org/documentation/2019/reference-manual/definitions.html#table-basicunits

1 Picoseconds = 41341.374575751 Atomic Unit Of Time 1 nm = 18.8973 Bohr 1 nm/ps = 18.8973/41341.374575751 Bohr/a.u. = 0.00045710381413114194 1 nm/ps = 4.571038E-04 Bohr/a.u.

CDTK.gmx2cdtk.atomName2Element(atomName)[source]

converts atomName into element name :param atomName: :type atomName: string

Returns:

element name

Return type:

string

CDTK.gmx2cdtk.atomName2atomMass(atomName)[source]

converts atomName into element mass :param atomName: :type atomName: string

Returns:

element mass in atomic units

Return type:

float

CDTK.gmx2cdtk.atomName2atomNum(atomName)[source]

converts atomName into element number :param atomName: :type atomName: string

Returns:

element number

Return type:

index

CDTK.gmx2cdtk.get_coord_center(n_center, molec, centerMethod='first')[source]

This will return the coordinate center of residue index n_center

Parameters:
  • Ncenter (int) – Index of molecule (residue index) that you want to be the center.

  • molec (dict of ndarrays.)

  • centerMethod (either "com" or "first")

Returns:

X, Y, Z coordinates of center.

Return type:

ndarray of float.

CDTK.gmx2cdtk.get_parser()[source]
CDTK.gmx2cdtk.makeResiduesWhole(molec)[source]

Rearranges the atoms by multiples of boxsize such that the residues are closest together

Parameters:

molec (dict of ndarray.)

Returns:

xyz – new coordinates.

Return type:

(n_atoms, 3) ndarray of float.

CDTK.gmx2cdtk.print_geom_files(molec)[source]

Prints input files needed for xsample first sorting all atoms from closest to the center of the box to furthest. The files printed are .in, .xyz and .vel.

Parameters:

molec (dict of ndarray.) – Dictionary built from reading gromax file (check readgmx documentation).

CDTK.gmx2cdtk.print_xpyder(filename, center_new, xyz, vxyz, elems)[source]
CDTK.gmx2cdtk.print_xsample(filename, center_new, xyz, vxyz, elems)[source]
CDTK.gmx2cdtk.readgmx(filename, check_water=False)[source]

Read gromacs file and return the topolgy, element types, coordinates, velocities of all atoms and the box size.

Parameters:

filename (string) – Name of gromacs file.

Returns:

molec – Dictionary containing the following arrays: - geom : (n_atoms, 3) ndarray of float.

Coordinates of all atoms.

  • vel(n_atoms, 3) ndarray of float.

    Velocities of all atoms.

  • residueIndex: (n_atoms) ndarray of ints

  • residueName: (n_atoms) ndarray of str

  • topol(n_atoms) ndarray of str.

    String identifiers for the topology of the system (atoms in molecules).

  • atomlist(n_atoms) ndarray of str.

    String identifiers of all atoms types (e.g., “O”, “H”).

  • atomnums(n_atoms) ndarray of int.

    Intigers with atomic numners of each element in atomloist.

  • atommass(n_atoms) ndarray of float.

    Atomic masses of each element in atomlist.

  • boxsize(3) ndarray of float.

    Box size (len_x, len_y, len_z).

  • residueName(n_atoms) ndarray of str

    Name of residue for each atom

  • residueIndex(n_atoms) ndarray of int

    Index of residue for each atom

  • atomName(n_atoms) ndarray of str

    Name of atoms (e.g. “OW”, “HW1”)

Return type:

dict of ndarray.

CDTK.gmx2cdtk.readtrr(xtcfilename, gmxfilename)[source]
CDTK.gmx2cdtk.shift_box(shift, xyz, v_box)[source]

Shift all molecules by shift and move atoms that fall outside the box according to periodic boundary conditions :param shift: X, Y, Z coordinates of new center (oxygen atom). :type shift: (3) ndarray of float. :param xyz: Original coordinates of all atoms. :type xyz: (n_atoms, 3) ndarray of float.

Returns:

New coordinates centered arund center_new in the box.

Return type:

(n_atoms, 3) ndarray of float.

CDTK.gmx2cdtk.sort_molec(molec, skipDistance=False)[source]

Sorts the molecules (residues) according to their center-of-mass positions (distance to the origin)

Parameters:

molec (dict of ndarray.) – Dictionary built from reading gromax file (check readgmx documentation).

Returns:

molec – Updated dictionary with sorted molecules.

Return type:

dict of ndarray

CDTK.gmx2cdtk.start()[source]
CDTK.gmx2cdtk.writegmx(filename, molec, reIndexResidues=True)[source]

Writes gromacs .gro file from molec stricture

Parameters:
  • filename (string) – Name of gromacs file.

  • molec (dict of ndarray.) –

    Dictionary containing the following arrays: - geom : (n_atoms, 3) ndarray of float.

    Coordinates of all atoms.

    • vel(n_atoms, 3) ndarray of float.

      Velocities of all atoms.

    • topol(n_atoms) ndarray of str.

      String identifiers for the topology of the system (atoms in molecules).

    • atomlist(n_atoms) ndarray of str.

      String identifiers of all atoms types.

    • atomnums(n_atoms) ndarray of int.

      Intigers with atomic numners of each element in atomloist.

    • atommass(n_atoms) ndarray of float.

      Atomic masses of each element in atomlist.

    • boxsize(3) ndarray of float.

      Box size (len_x, len_y, len_z).

    • residueName(n_atoms) ndarray of str

      Name of residue for each atom

    • residueIndex(n_atoms) ndarray of int

      Index of residue for each atom

    • atomName(n_atoms) ndarray of str

      Name of atoms (e.g. “OW”, “HW1”)

CDTK.gmx2cdtk.writetrr(trrFilename, molec)[source]

write a gromacs .trr file based on the data from molec uses the MDAnalysis python package

Parameters:
  • trrFilename (string) – filename

  • molec (dictionary) – data