rdmc.view

A module contains py3Dmol functions to draw molecules

rdmc.view.conformer_viewer(mol: RDKitMol, conf_ids: Optional[list] = None, highlight_ids: Optional[list] = None, opacity: float = 0.5, style_spec: Optional[dict] = None, viewer: Optional[view] = None, viewer_size: tuple = (400, 400), viewer_loc: Optional[tuple] = None) view

This is a viewer for viewing multiple overlaid conformers.

Parameters:
  • mol (RDKitMol) – An RDKitMol object with embedded conformers.

  • conf_ids (list, optional) – A list of conformer ids (int) to be overlaid and viewed. If not provided, all embedded conformers will be used.

  • highlight_ids (list, optional) – It is possible to highlight some of the conformers while greying out other conformers by providing the conformer IDs you want to highlight.

  • opacity (float, optional) – Set the opacity of the non-highlighted conformers and is only used with the highlighting feature. the value should be a float number between 0 to 1. The default value is 0.5. Values below 0.3 may be hard to see.

  • style_spec (dict, Optional) –

    Style of the shown molecule. The default setting is {‘stick’: {‘radius’: 0.05, ‘color’: ‘#f2f2f2’},

    ’sphere’: {‘scale’: 0.25},}

    which set both bond width/color and atom sizes. For more details, please refer to the original APIs in 3DMol.js.

  • viewer (py3Dmol.view, optional) – Provide an existing viewer, instead of create a new one.

  • viewer_size (tuple, optional) – Set the viewer size. Only useful if viewer is not provided. Defaults to (400, 400).

  • viewer_loc (tuple, optional) – The location of the viewer in the grid. E.g., (0, 1). Defaults to None.

Returns:

The molecule viewer.

Return type:

py3Dmol.view

rdmc.view.freq_viewer(obj: str, model: str = 'xyz', frames: int = 10, amplitude: float = 1.0, atom_index: bool = True, style_spec: Optional[dict] = None, viewer: Optional[view] = None, viewer_size: tuple = (400, 400), viewer_loc: Optional[tuple] = None) view

This is the viewer for frequency.

Parameters:
  • obj (str) – A string representation of the molecule can be xyz string, sdf string, etc.

  • model (str, optional) – The model (format) of the molecule representation, e.g., 'xyz'. Defaults to 'xyz'.

  • frames (int, optional) – Number of frames to be created.

  • amplitude (float, optional) – amplitude of distortion.

  • atom_index (bool, optional) – Whether to show atom index. Defaults to True.

  • style_spec (dict, Optional) – Style of the shown molecule. The default is showing both both atoms and bonds.

  • viewer (py3Dmol.view, optional) – Provide an existing viewer, instead of create a new one.

  • viewer_size (tuple, optional) – Set the viewer size. Only useful if viewer is not provided. Defaults to (400, 400).

  • viewer_loc (tuple, optional) – The location of the viewer in the grid. E.g., (0, 1). Defaults to None.

Returns:

The molecule frequency viewer.

Return type:

py3Dmol.view

rdmc.view.grid_viewer(viewer_grid: tuple, linked: bool = False, viewer_size: Optional[tuple] = None) view

Create a empty grid viewer.

Parameters:
  • viewer_grid (tuple) – The layout of the grid, e.g., (1, 4) or (2, 2).

  • linked (bool, optional) – Whether changes in different sub viewers are linked. Defaults to False.

  • viewer_size (tuple, optional) – The size of the viewer in (width, height). By Default, each block is 250 width and 400 height.

rdmc.view.interactive_conformer_viewer(mol, **kwargs)

This is a viewer for individually viewing multiple conformers using an ipython slider widget. Uses keywords from mol_viewer function, so all arguments of that function are available here.

Parameters:

mol (RDKitMol) – An RDKitMol object with embedded conformers.

Returns:

The molecule viewer with slider to view different conformers.

Return type:

py3Dmol.view

rdmc.view.mol_animation(obj: str, model: str = 'xyz', model_extra: Optional[dict] = None, animate: Optional[dict] = None, atom_index: bool = True, style_spec: Optional[dict] = None, viewer: Optional[view] = None, viewer_size: tuple = (400, 400), viewer_loc: Optional[tuple] = None) view

This is the most general function to view a molecule powered by py3Dmol

Parameters:
  • obj (str) – A string representation of the molecule can be xyz string, sdf string, etc.

  • model (str, optional) – The model (format) of the molecule representation, e.g., 'xyz'. Defaults to 'xyz'.

  • model_extra (dict, optional) – Extra specs for the model. E.g., frequency specs Can be provided here. Default to None

  • animate (dict, optional) – Specs for animation. E.g., {'loop': 'backAndForth'}.

  • atom_index (bool, optional) – Whether to show atom index. Defaults to True.

  • style_spec (dict, Optional) – Style of the shown molecule. The default is showing both both atoms and bonds.

  • viewer (py3Dmol.view, optional) – Provide an existing viewer, instead of create a new one.

  • viewer_size (tuple, optional) – Set the viewer size. Only useful if viewer is not provided. Defaults to (400, 400).

  • viewer_loc (tuple, optional) – The location of the viewer in the grid. E.g., (0, 1). Defaults to None.

Returns:

The molecule viewer.

Return type:

py3Dmol.view

rdmc.view.mol_viewer(obj: str, model: str = 'xyz', model_extra: Optional[dict] = None, animate: Optional[dict] = None, atom_index: bool = True, style_spec: Optional[dict] = None, viewer: Optional[view] = None, viewer_size: tuple = (400, 400), viewer_loc: Optional[tuple] = None, gv_background: bool = False, confId: int = 0) view

This is the most general function to view a molecule powered by py3Dmol

Parameters:
  • obj (str) – A string representation of the molecule can be xyz string, sdf string, etc. Or an RDKitMol object.

  • model (str, optional) – The model (format) of the molecule representation, e.g., 'xyz'. Defaults to 'xyz'. If RDKitMol is feed in, the model will forced to be sdf.

  • model_extra (dict, optional) – Extra specs for the model. E.g., frequency specs Can be provided here. Default to None

  • animate (dict, optional) – Specs for animation. E.g., {'loop': 'backAndForth'}.

  • atom_index (bool, optional) – Whether to show atom index. Defaults to True.

  • style_spec (dict, Optional) – Style of the shown molecule. The default is showing both both atoms and bonds.

  • viewer (py3Dmol.view, optional) – Provide an existing viewer, instead of create a new one.

  • viewer_size (tuple, optional) – Set the viewer size. Only useful if viewer is not provided. Defaults to (400, 400).

  • viewer_loc (tuple, optional) – The location of the viewer in the grid. E.g., (0, 1). Defaults to None.

  • gv_background (optional, bool) – To use a background that is similar to the style of GaussView. Defaults to False.

  • confId (int) – Integer of embedded conformer to view

Returns:

The molecule viewer.

Return type:

py3Dmol.view

rdmc.view.ts_viewer(r_mol: RDKitMol, p_mol: RDKitMol, ts_mol: RDKitMol, only_ts: bool = False, alignment: list = ['r', 'p', 'ts'], vertically_aligned: bool = True, ts_bond_color: Union[str, Tuple[str]] = ('red', 'green'), ts_bond_width: float = 0.1, **kwargs)

View reactant, product and ts of a given reaction. The broken bonds in the TS will be shown with red lines while the formed bonds in the TS will be shown with green lines. Uses keywords from mol_viewer function, so all arguments of that function are available here.

Parameters:
  • r_mol (RDKitMol) – The reactant complex.

  • p_mol (RDKitMol) – The product complex.

  • ts_mol (RDKitMol) – The ts corresponding to r_mol and p_mol.

  • only_ts (bool, optional) – Only shows TS. Defaults to showing reactant, product, and TS. Defaults to False.

  • alignment (list, optional) – The alignment of reactant, product, and TS. Defaults to [‘r’, ‘p’, ‘ts’]. It can be changed to [‘r’, ‘ts’, ‘p’] to make TS in the middle. You can even remove ‘r’ or ‘p’ to only show TS and one side of the reaction, e.g., [‘r’, ‘ts’]. This argument is only valid when only_ts is False.

  • vertically_aligned (bool, optional) – Reactant, product, and TS are vertically aligned. Defaults to True. Only valid when only_ts is False.

  • ts_bond_color (tuple or str, optional) – The TS bond color for broken bonds (defaults to “red”) and formed bonds (defaults to “green”). If a single str is input, the same color will be used. If a length-2 tuple is provided, then the first color will be used as the broken bond color. As a reference, normal bond color is ‘#f2f2f2’.

  • ts_bond_width (float) – The width of the TS bonds. Defaults to 0.1. As a reference, normal bond width is 0.05.