pycgtool.bondset

Module containing classes to calculate bonded properties from a Frame.

BondSet contains a dictionary of lists of Bonds. Each list corresponds to a single molecule.

Module Contents

Classes

Bond

Class holding the properties of a single bonded term.

BondSet

Class used to perform bond measurements in a Frame.

Attributes

logger

PathLike

pycgtool.bondset.logger
pycgtool.bondset.PathLike
class pycgtool.bondset.Bond(atoms: Iterable[str], atom_numbers: Optional[Iterable[int]] = None, func_form=None)[source]

Class holding the properties of a single bonded term.

Bond lengths, angles and dihedrals are all equivalent, distinguished by the number of atoms present.

__iter__(self)[source]
boltzmann_invert(self, temp: float = 310)None[source]

Perform Boltzmann Inversion using measured values of bond to calculate equilibrium value and force constant.

Parameters

temp – Temperature at which the simulation was performed

__repr__(self)str[source]

Return repr(self).

class pycgtool.bondset.BondSet(filename: PathLike, options)[source]

Class used to perform bond measurements in a Frame.

BondSet contains a dictionary of lists of Bonds. Each list corresponds to a single molecule.

_get_default_func_forms(self, options)[source]
static _create_angles(mol_bonds)[source]

Create angles and dihedrals from bonded topology.

Parameters

mol_bonds – List of bonds within a molecule to generate angles for

Returns

List of angle and dihedral bond name tuples

get_bonds(self, mol: str, natoms: int, select: Callable[[Bond], bool] = lambda x: ...)List[Bond][source]

Return list of bonds from molecule containing natoms atoms.

Parameters
  • mol (str) – Molecule name

  • natoms (int) – Number of atoms in bond, i.e. 2 for bond length, 3 for angle, 4 for dihedral

  • select (function) – Optional lambda, return only bonds for which this is True

Return List[Bond]

List of bonds

get_bond_lengths(self, mol, with_constr=False)[source]

Return list of all bond lengths in molecule. May include constraints.

Parameters
  • mol – Molecule name to return bonds for

  • with_constr – Include constraints?

Returns

List of bonds

get_bond_length_constraints(self, mol)[source]

Return list of all bond length constraints in molecule.

Parameters

mol – Molecule name to return bonds for

Returns

List of bonds

get_bond_angles(self, mol, exclude_triangle=True)[source]

Return list of all bond angles in molecule.

Parameters
  • mol – Molecule name to return bonds for

  • exclude_triangle – Exclude angles that are part of a triangle?

Returns

List of bonds

get_bond_dihedrals(self, mol)[source]

Return list of all bond dihedrals in molecule.

Parameters

mol – Molecule name to return bonds for

Returns

List of bonds

get_virtual_beads(self, mapping)[source]

Return list of all virtual beads in molecule :param mapping: :return: list of virtual beads

_populate_atom_numbers(self, mapping)[source]

Add atom numbers to all bonds.

Uses previously defined atom names.

Parameters

mapping – AA->CG mapping used to collect atom/bead numbers

write_itp(self, filename, mapping)[source]

Output a GROMACS .itp file containing atoms/beads and bonded terms.

Parameters
  • filename – Name of output file

  • mapping – AA->CG Mapping from which to collect bead properties

itp_text(self, mapping)[source]
apply(self, frame)[source]

Calculate bond lengths/angles for all trajectory frames with a Frame instance and store into Bonds.

Parameters

frame – Frame from which to calculate values

boltzmann_invert(self)None[source]

Perform Boltzmann Inversion of all bonds to calculate equilibrium value and force constant.

static _get_lines_for_bond_dump(bonds, target_number: Optional[int] = None, rad2deg: bool = False)List[str][source]

Return a dump of bond measurements as a list of lines of text.

Parameters
  • bonds – Iterable of bonds

  • target_number (int) – Sample size of bonds to dump - None will dump all bonds

  • rad2deg (bool) – Should bond measurements be converted from radians to degrees?

Return List[str]

Lines of bond measurements dump

dump_values(self, target_number: int = 10000, output_dir: Optional[Union[pathlib.Path, str]] = None)None[source]

Output measured bond values to files for length, angles and dihedrals.

Parameters
  • target_number (int) – Approx number of sample measurements to output. If None, all samples will be output.

  • output_dir – Directory to write output files to.

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