pycgtool.frame

This module contains classes for storing atomic data.

The Frame class may contain multiple Residues which may each contain multiple Atoms. Both Frame and Residue are iterable. Residue is indexable with either atom numbers or names.

Module Contents

Classes

Frame

Load and store data from a simulation trajectory.

Functions

load_traj(filepath: PathLike, **kwargs) → mdtraj.Trajectory

Load a trajectory, if a PDB fails with zero box volume disable volume check and try again.

Attributes

logger

PathLike

pycgtool.frame.logger
pycgtool.frame.PathLike
exception pycgtool.frame.UnsupportedFormatException(msg=None)[source]

Bases: Exception

Exception raised when a topology/trajectory format cannot be parsed.

exception pycgtool.frame.NonMatchingSystemError(msg=None)[source]

Bases: ValueError

Exception raised when topology and trajectory do not match.

pycgtool.frame.load_traj(filepath: PathLike, **kwargs)mdtraj.Trajectory[source]

Load a trajectory, if a PDB fails with zero box volume disable volume check and try again.

class pycgtool.frame.Frame(topology_file: Optional[PathLike] = None, trajectory_file: Optional[PathLike] = None, frame_start: int = 0, frame_end: Optional[int] = None)[source]

Load and store data from a simulation trajectory.

_slice_trajectory(self, frame_start: int = 0, frame_end: Optional[int] = None)mdtraj.Trajectory[source]

Slice input simulation trajectory to a subset of frames.

Parameters
  • frame_start – First frame of trajectory to use

  • frame_end – Last frame of trajectory to use

_load_trajectory(self)None[source]

Load a trajectory into the frame attributes.

property residues(self)

Residues in the frame topology.

residue(self, *args, **kwargs)mdtraj.core.topology.Residue[source]

Get a residue from the frame topology by name or id.

property atoms(self)

Atoms in the frame topology.

atom(self, *args, **kwargs)mdtraj.core.topology.Atom[source]

Get an atom from the frame topology by name or id.

property natoms(self)int

Number of atoms in the frame topology.

property n_frames(self)int

Number of frames in the trajectory.

add_residue(self, name, chain: Optional[mdtraj.core.topology.Residue] = None, **kwargs)mdtraj.core.topology.Residue[source]

Add a residue to the frame topology.

Parameters
  • name – Name of residue

  • chain – MDTraj chain of residue

Returns

New residue

add_atom(self, name: str, element: Optional[mdtraj.element.Element], residue: mdtraj.core.topology.Residue)mdtraj.core.topology.Atom[source]

Add an atom or CG bead to the frame topology.

Parameters
  • name – Name of atom

  • element – MDTraj element of atom

  • residue – MDTraj residue of atom

Returns

New atom

save(self, filename: PathLike, frame_number: Optional[int] = None, **kwargs)None[source]

Write trajctory to file.

Parameters
  • filename – Name of output file

  • frame_number – Which trajectory frame to save - defaults to all

build_trajectory(self)None[source]

Build an MDTraj trajectory from atom coordinates and the values stored as attributes on this frame.