Junction

class Junction(monomer_atom: Atom, residue_atom: Atom, name: str = None)[source]

Bases: object

Junctions are the polymerization sites of a monomer topology. They are defined by a name and a list of Bonds. The name should be unique to the Junction such that it can be unambigously identified by its name, thus ensuring that polymers can be built with consistent, desired conformations.

Parameters:
  • monomer_atom (Atom) – the Atom which will remain with this Monomer after polymerisation, and will obtain a new bond.

  • residue_atom (Atom) – the Atom which will be lost during polymerisation, analogous to the leaving atom in a chemical reaction.

  • name (str, optional) – the unique name of the Junction type, defaults to None.

Raises:

ValueError – if a Junction cannot be determined from the two provided atoms (i.e. if they are not bonded).

classmethod from_dict(data: dict, atoms: List[Atom])[source]

Create a new Junction from a dictionary, such as that created with Junction.to_dict().

The structure of the dictionary is as below: {“name”: self.name, “monomer_atom”: self.monomer_atom.atom_name, “residue_atom”: self.residue_atom.atom_name}

Parameters:
  • data (dict) – dictionary containing data to make a Junction, generate with ‘to_dict()’.

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

Returns:

a new Junction

Return type:

Junction

classmethod from_topology(topology: Topology, monomer_atom_name: str, residue_atom_name: str, residue_id: int = None, name: str = None) Junction[source]

Create a new Junction from a monomer or polymer Topology, and the names and shared residue id of the two Atoms used to form the Junction.

Parameters:
  • topology (Topology) – a polymer or monomer Topology. Obtain from the ‘.topology’ attribute of either a Monomer or Polymer.

  • monomer_atom_name (str) – the name of the Atom which will remain with this Topology after polymerisation, and will obtain a new bond.

  • residue_atom_name (str) – the name of the Atom which will be lost during polymerisation, analogous to the leaving atom in a chemical reaction.

  • residue_id (int, optional) – the id number of the residue both atoms belong to, defaults to None

  • name (str, optional) – the unique name used to identify the new Junction, defaults to None

Returns:

a new Junction

Return type:

Junction

named(newname: str) Junction[source]

Use to name or rename a Junction after it has been created.

Parameters:

newname (str) – the desired, unique name that will be used to identify this Junction.

Returns:

the Junction object with a name

Return type:

Junction

Depreciation warning: * This function will be depreciated shortly in favour of enforced setting the name attribute of a Junction when it is created.

Instead of: junction = Junction(atomA, atomB).named(“name”) Use: junction = Junction(atomA, atomB, name=”name”)

to_dict() dict[source]

Convert this Junction to a dictionary representation.

The structure of the dictionary is as below: {“name”: self.name, “monomer_atom”: self.monomer_atom.atom_name, “residue_atom”: self.residue_atom.atom_name}

Returns:

a dictionary containing the names of its Atoms and the unique name of this Junction.

Return type:

dict

class Junctions(iterable=(), /)[source]

Bases: list

Class used to group and list Junctions of a Monomer or Polymer for RDKit visualisation. Used by the Visualize Class.

add(junction: Junction)[source]

Add a new Junction to the Junction list.

Parameters:

junction (Junction) – a Junction to add to the Junction list.

classmethod from_dict(data: list, atoms: List[Atom]) Junctions[source]

Create a new list of Junctions from a list of Junction dictionary representations, such as that created with Junctions.to_dict().

The structure of each dictionary within the list is as below: {“name”: self.name, “monomer_atom”: self.monomer_atom.atom_name, “residue_atom”: self.residue_atom.atom_name}

Parameters:
  • data (list) – list of dictionaries containing data to make Junctions, generate with ‘to_dict()’.

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

Returns:

a new Junctions (i.e. list of Junction objects)

Return type:

Junctions

get_junctions() Junctions[source]

Getter method to access the list of Junctions.

Returns:

the list of Junction objects (i.e. a ‘Junctions’ object).

Return type:

Junctions

named(name: str) list[Junction][source]

Returns a list of Junctions with the name provided.

Parameters:

name (str) – the name of a Junction/s to retrieve.

Returns:

list[Junction]

Return type:

list

remove(junction: Junction)[source]

Remove a Junction from the list of Junctions.

Parameters:

junction (Junction) – the Junction object to be removed from the Junctions.

to_dict() list[dict][source]

Return a list containing the dictionary representations of all of the Junctions in the Junctions list.

The structure of each dictionary within the list is as below: {“name”: self.name, “monomer_atom”: self.monomer_atom.atom_name, “residue_atom”: self.residue_atom.atom_name}

Returns:

a list of Junction dictionary representations.

Return type:

list[dict]