Visualize
- class Visualize(topology: Topology, junctions: Junctions = None, infer_bond_order=True)[source]
Bases:
objectEnables conversion of a molecular system representation (Polymer, Monomer or Topology) to a rdKit Chem mol for 2D and 3D visualisation.
- Parameters:
topology (Topology) – the molecular system Topology to visualise.
junctions (Junctions, optional) – the Junctions present with the Topology, to enable optional highlighting of the Junction locations, defaults to None
infer_bond_order (bool, optional) – if true, the bond order will be inferred based on the atom type and its number of bonds, defaults to True
- draw2D(filename: str, size: Tuple[int, int] = (600, 300), highlight_junctions=False, show_atom_ID=False, show_legend=True, remove_explicit_H=True)[source]
Draw the Visualize object (molecule) in 2D with RDKit’s DrawMolecule function.
- Args:
filename (str): size (tuple[int,int]): highlight_junctions (bool): show_atom_ID (bool): if True, show the atom ID in the molecule show_legend (bool): remove_explicit_H (bool): if True, remove the explicit hydrogens from the molecule
- Parameters:
filename (str) – the filename to save the image to
size (Tuple[int,int], optional) – the size of the image to draw, defaults to (600,300)
highlight_junctions (bool, optional) – if True, render the Junction bonds in a different colour to highlight them, defaults to False
show_atom_ID (bool, optional) – if True, render the drawing with the Atom’s labelled with their atom_id, defaults to False
show_legend (bool, optional) – if True, show the legend (the ‘title’ of the underlying Topology) in the image, defaults to True
remove_explicit_H (bool, optional) – if True, removes explicit hydrogens. Valuable for rendering larger images by making them less crowded, defaults to True
- Raises:
ValueError – if both ‘show_atom_ID’ and ‘remove_explicit_H’ are True
- draw3D(view=None, highlight_junctions: bool = False, show_atom_ID: bool = False, remove_explicit_H: bool = True)[source]
Draw the Visualize object (molecule) in 3D with RDKit’s DrawMolecule function.
- Parameters:
view (py3Dmol.view, optional) – a py3Dmol.view() of desired width and height, defaults to None
highlight_junctions (bool, optional) – if True, render the Junction bonds in a different colour to highlight them, defaults to False
show_atom_ID (bool, optional) – if True, render the drawing with the Atom’s labelled with their atom_id, defaults to False
remove_explicit_H (bool, optional) – if True, removes explicit hydrogens. Valuable for rendering larger images by making them less crowded, defaults to True
- infer_bond_order()[source]
Infer the bond order of all bonds in the Topology according to the valencies of the two Atoms that share the Bond and the number of other Bonds each of them have. The inferred bond order is saved to the ‘order’ property of each bond.
Double bonds will be added to the Topology using the known valencies of the Atoms and number of declared Bonds.
This function is called automatically by the Class initialiser if the parameter ‘infer_bond_order’ is True.
- classmethod monomer(monomer: Monomer, infer_bond_order=True) Visualize[source]
Class method to construct Visualize object from a Polymer.
- Parameters:
- Returns:
a Visualize object that can be drawn in 2D or 3D.
- Return type:
Visualize
- classmethod polymer(polymer: Polymer, infer_bond_order=True) Visualize[source]
Class method to construct Visualize object from a Polymer.
- Parameters:
- Returns:
a Visualize object that can be drawn in 2D or 3D.
- Return type:
Visualize
- classmethod topology(topology: Topology, infer_bond_order=True) Visualize[source]
Class method to construct Visualize object from a Topology.
- Parameters:
topology (Topology) – the Topology set to be converted to RDKit format and visualised.
infer_bond_order (bool, optional) – if true, the bond order will be inferred based on the atom type and its number of bonds, defaults to True.
- Returns:
a Visualize object that can be drawn in 2D or 3D.
- Return type:
Visualize