Bonds

class Bond(atom_a: Atom, atom_b: Atom, bond_type: int, bond_length: float, force_constant: float, order: int = 1, format: str = 'gromos')[source]

Bases: object

Represents a bond between two atoms in a molecular system.

Parameters:
  • atom_a (Atom) – The first atom involved in the bond.

  • atom_b (Atom) – The second atom involved in the bond.

  • bond_type (int) – The type of the bond (e.g., single, double, triple).

  • bond_length (float) – The length of the bond.

  • force_constant (float) – The force constant associated with the bond.

  • order (int, optional) – The bond order, defaults to 1 (single bond)

Raises:

ValueError – if either atom_a or atom_b are None

LHS() set['Atom'][source]

List of all atoms in the left-hand side of the bond.

Returns:

set of Atoms located on the left-hand side of this bond

Return type:

set[Atom]

RHS() set['Atom'][source]

List of all atoms in the right-hand side of the bond.

Returns:

set of Atoms located on the right-hand side of this bond

Return type:

set[Atom]

clone_bond_changing(from_atom: Atom, to_atom: Atom) Bond[source]

Clone the bond, changing the atom that is being replaced. Used during the polymer.extend() algorithm to copy and modify bonds where a new Monomer is joined to the Polymer.

Parameters:
  • from_atom (Atom) – the outgoing “Atom”, to be replaced

  • to_atom (Atom) – the incoming “Atom”, will replace the position of the outgoing Atom in this Bond

Raises:

ValueError – if ‘from_atom’ is not in the Bond

Returns:

the new, modified Bond

Return type:

Bond

contains_atom(atom: Atom) bool[source]

Check if this Bond contains a given atom.

Parameters:

atom (Atom) – the Atom you wish to check if it is in this Bond or not

Returns:

True if the Bond contains the given “Atom”, or False if not.

Return type:

bool

static from_atoms(atom_a: Atom, atom_b: Atom, find_empty: bool = False) Bond[source]

Class method to find and return Bond from between two Atoms.

Parameters:
  • atom_a (Atom) – The first atom involved in the angle.

  • atom_b (Atom) – The second atom in the angle.

  • find_empty (bool, defaults to False) – Optional argument used when de-duplicating bonds to ensure the bond without angles associated is returned to delete.

Returns:

a Bond between these Atoms, or None if either atom_a or atom_b are None or there is not a bond between them.

Return type:

Bond

classmethod from_dict(data: Dict[str, int | float], atoms: List['Atom']) Bond[source]

Create a new Bond from a dictionary, such as that created with Bond.to_dict(). Will retrieve an existing Bond if it already exists between these Atoms.

The structure of the dictionary is as below: {“atom_a”: self.atom_a.atom_id, “atom_b”: self.atom_b.atom_id, “bond_type”: self.bond_type, “bond_length”: self.bond_length, “force_constant”: self.force_constant, “order”: self.order}

Parameters:
  • data (Dict[str, Union[int, float]]) – dictionary containing data to make a Bond, generate with ‘to_dict()’.

  • atoms (List[Atom]) – list of Atoms. The list may contain more than 3 atoms, as long as the id’s of the three atoms specified in the data dict are present.

Returns:

a new Bond

Return type:

Bond

classmethod from_line(line: str, atoms: List['Atom'], format: str = 'gromos') Bond[source]

Class method to construct Bond from the line of an ITP file and a list of all Atom’s present in the topology.

Parameters:
  • line (str) – the ITP file line

  • atoms (List[Atom]) – list of all Atoms in the Topology

  • format (str, defaults to "gromos" for GROMOS forcefields.) – The forcefield the ITP file is formatted as, options are “gromos”, “amber”, “opls” and “charmm”

Returns:

the new Bond

Return type:

Bond

other_atom(atom: Atom) Atom[source]

Check if the given Atom is in this Angle and return a list of the other atoms present in this Angle (i.e. discluding ‘atom’).

Parameters:

atom (Atom) – the Atom you wish to check if it is in this Bond, and if so, which other atom it is bonded to

Raises:

ValueError – if ‘atom’ is not in this Bond

Returns:

the other Atom in this Bond

Return type:

Atom

remove()[source]

Delete self from all related Angles and the two Atoms. Used to cleanup and remove attributes during Polymer.extend().

to_dict() dict[source]

Convert this Bond to a dictionary representation.

The structure of the dictionary is as below: {“atom_a”: self.atom_a.atom_id, “atom_b”: self.atom_b.atom_id, “bond_type”: self.bond_type, “bond_length”: self.bond_length, “force_constant”: self.force_constant, “order”: self.order}

Returns:

a dictionary containing the id’s of its Atoms and other attributes of this Bond.

Return type:

dict