pycgtool.mapping

This module contains classes required to perform an atomistic to coarse-grain mapping.

The Mapping class contains a dictionary of lists of BeadMaps. Each list corresponds to a single molecule.

Module Contents

Classes

BeadMap

Class holding values relating to the AA->CG transformation for a single bead.

VirtualMap

Class holding values relating to the AA->CG transformation for a single bead.

Mapping

Class used to perform the AA->CG mapping.

Functions

calc_coords_weight(ref_coords, coords, weights, box=None)

Calculate the coordinates of a single CG bead from weighted component atom coordinates.

Attributes

logger

PathLike

pycgtool.mapping.logger
pycgtool.mapping.PathLike
class pycgtool.mapping.BeadMap(name: str, num: int, type: str = None, atoms=None, charge: float = 0, mass: float = 0)[source]

Class holding values relating to the AA->CG transformation for a single bead.

__repr__(self)[source]

Return repr(self).

__iter__(self)[source]

Iterate through the atom names from which the bead is made up.

Returns

Iterator over atoms

__len__(self)[source]
__getitem__(self, item)[source]
guess_atom_masses(self)None[source]

Guess masses for the atoms inside this bead.

class pycgtool.mapping.VirtualMap(name, num, type=None, atoms=None, charge=0)[source]

Bases: BeadMap

Class holding values relating to the AA->CG transformation for a single bead.

guess_atom_masses(self)None[source]

Virtual beads should not define atom masses.

class pycgtool.mapping.Mapping(filename: PathLike, options, itp_filename: Optional[PathLike] = None)[source]

Class used to perform the AA->CG mapping.

Contains a dictionary of lists of BeadMaps. Each list corresponds to a single molecule.

_load_itp(self, itp_filename: str)None[source]

Load mass and charge of atoms in mapping from a GROMACS itp topology file.

Parameters

itp_filename – ITP file to read

_set_bead_weights(self)None[source]

Set bead weights for the mapping center being used.

static _itp_section_into_mol_map(mol_map: List[BeadMap], itp_mol_entry, manual_charges: bool)None[source]
static _mol_map_from_section(mol_section)Tuple[List[BeadMap], bool][source]
_rename_atoms(self)None[source]

Rename residues and atoms in mapping according to MDTraj conventions.

This means that users can create mappings using the same names as are in the input topology file and not have this broken by MDTraj renaming the residues and atoms.

__len__(self)[source]
__contains__(self, item)[source]
__getitem__(self, item)[source]
__iter__(self)[source]
items(self)[source]
_guess_atom_masses(self)None[source]

Guess atom masses from their names.

_cg_frame_setup(self, aa_residues: Iterable[mdtraj.core.topology.Residue])[source]

Create a new CG Frame and populate beads :param aa_residues: Iterable of atomistic residues to map from :return: New CG Frame instance

apply(self, frame: pycgtool.frame.Frame, cg_frame: Optional[pycgtool.frame.Frame] = None)[source]

Apply the AA->CG mapping to an atomistic Frame.

Parameters
  • frame – Frame to which mapping will be applied

  • cgframe – CG Frame to remap - optional

Returns

Frame instance containing the CG frame

pycgtool.mapping.calc_coords_weight(ref_coords, coords, weights, box=None)[source]

Calculate the coordinates of a single CG bead from weighted component atom coordinates.

Parameters
  • ref_coords – Coordinates of reference atom, usually first atom in bead

  • coords – Array of coordinates of component atoms

  • weights – Array of atom weights, must sum to 1

  • box – PBC box vectors

Returns

Coordinates of CG bead