trajectory

Code that encapsulates interactions with an MDAnalysis universe

Module Contents

class trajectory.Trajectory(mda_universe)[source]

A Trajectory object is a wrapper for the MDAnalysis Universe class. It encapsulates some MDA-specific function calls to make it simpler to use for the purposes of this codebase.

It’s possible to construct a Trajectory from any MDAnalysis Universe. However, it would usually happen from topology and trajectory paths (or a single combined PDB). It’s also possible to create one from an array of alpha-carbon coordinates.

If needed, more delegation methods can be added from a Trajectory to the inner Universe to avoid other classes directly interacting with it.

static from_paths(topology_path, trajectory_path=None)[source]

Build a Trajectory object from a topology file and a trajectory file. Mirrors the MDAnalysis Universe construction method.

static from_ca_frames(data, topology_attr={})[source]

A shortcut to create an in-memory MDAnalysis Universe with the given data as a list of coordinate matrices, each a list of triplets.

Each coordinate is considered to be an alpha carbon, so the number of residues is set to the number of given atoms. Some additional (optional) topology attributes you might provide:

  • names: atom names that match the coordinates (default to “CA”)

  • resids: residue ids that correspond to the given atoms

  • resnames: residue names that correspond to the given residue ids

All other topology attributes are passed along to the MDAnalysis Universe method add_TopologyAttr.

mda_universe[source]
property coordinates[source]
property frames[source]
__next__()[source]

Delegates to MDAnalysis to shift the internal trajectory of the Universe forward.

select_atoms(*args)[source]

Delegates to MDAnalysis to return an AtomGroup.

write_static(path: pathlib.Path | str, selection='all')[source]

Write the static coordinates of the current frame into the given file. It’s expected that it’s a PDB, but anything that MDAnalysis accepts will work.

write_frames(path: pathlib.Path | str, selection='all')[source]

Write the full trajectory to a file. It’s expected that it’s a PDB, but anything that MDAnalysis accepts will work.