htmd.simlist module#

HTMD can handle a large amount of simulations. Simulation lists allow to create a simple list containing all relevant information about the simulations to later perform any type of analysis.

class htmd.simlist.Frame(sim, piece, frame)#

Bases: object

Class used for referencing a specific frame of a Sim object object.

Parameters:
  • sim (Sim object) – The simulation.

  • piece (int) – Which trajectory piece the frame corresponds to.

  • frame (int) – The frame of the specific trajectory piece.

frame#
piece#
sim#
class htmd.simlist.Sim(trajf: str | list | tuple | ndarray, topology: str | list | tuple | ndarray | None = None, inputf: str | None = None, _simid=None, _parent=None, _input=None, _trajectory=None, _molfile=None, _numframes=None)#

Bases: object

Information on a single simulation trajectory.

This class is used for storing information related to simulations. This information includes the path to the simulation, the path to a structure file (pdb) which corresponds to the simulation, the folder containing the input files used to generate the simulation (useful for adaptive), the parent of the simulation (if it was filtered it will point to the original simulation) and a unique simulation id.

copy() Sim#

Return a deep copy of this simulation.

static fromHDF5(h5group: Group) Sim#

Reconstruct a Sim from an open HDF5 group.

toHDF5(h5group: Group)#

Write this simulation’s fields into an open HDF5 group.

htmd.simlist.simfilter(sims: list | ndarray, outfolder: str, filtersel: str | ndarray, njobs: int | None = None) ndarray#

Filter a list of simulations generated by simlist().

Writes new trajectories containing only the desired atoms to a new directory.

Parameters:
  • sims (list or numpy.ndarray) – A simulation list produced by simlist().

  • outfolder (str) – The folder in which to write the modified trajectories.

  • filtersel (str or np.ndarray) – An atom selection string, a boolean mask, or an integer index array (see Molecule.atomselect) describing the atoms to keep.

  • njobs (int, optional) – Number of parallel jobs to spawn for filtering. If None, uses the value from htmd.config.

Returns:

fsims – A list of filtered simulations.

Return type:

np.ndarray of Sim objects

Examples

>>> sims  = simlist(glob('data/*/'), glob('input/*/structure.pdb'))
>>> fsims = simfilter(sims, 'filtered', filtersel='not water')
htmd.simlist.simlist(datafolders: str | list, topologies: str | list, inputfolders: str | list | None = None) list#

Create a list of simulations.

Parameters:
  • datafolders (str or list) – A list of directories (or a single directory), each containing a single trajectory.

  • topologies (str or list) – A list of topology files or folders containing a topology file corresponding to the trajectories in datafolders. Can also be a single path to a structure that applies to all trajectories. If the single path is a folder, topology files will be auto-detected in that folder.

  • inputfolders (str or list, optional) – A list of directories (or a single directory), each containing the input files used to produce the trajectories in datafolders.

Returns:

sims – A list of simulations.

Return type:

list of Sim objects

Examples

>>> simlist(glob('./test/data/*/'), './test/data/0/')
>>> simlist(glob('./test/data/*/'), glob('./test/input/*/'), glob('./test/input/*/'))
>>> simlist(glob('./test/data/*/'), glob('./test/input/*/*.pdb'), glob('./test/input/*/'))
htmd.simlist.simmerge(simlist1: list | ndarray, simlist2: list | ndarray) list | ndarray#

Merge two simlists by updating their simid fields.

Parameters:
  • simlist1 (list or numpy.ndarray of Sim objects) – First list.

  • simlist2 (list or numpy.ndarray of Sim objects) – Second list.

Returns:

newlist – All simulations from both input lists with updated simid values. If one input is empty, the other is returned unchanged.

Return type:

list or numpy.ndarray of Sim objects