gufe.visualization.mapping_visualization

Functions

display_mapping_3d(mapping[, spheres, ...])

Render the LigandAtomMapping in 3D using py3Dmol.

display_mappings_3d(mappingSet)

Jupyter Visualization Widget This function is visualizing the provided list of mappings.

draw_mapping(mol1_to_mol2, mol1, mol2[, d2d])

Method to visualise the atom map correspondence between two rdkit molecules given an input mapping.

draw_one_molecule_mapping(mol1_to_mol2, ...)

Draw the mapping visualization for a single molecular of a mapping

draw_unhighlighted_molecule(mol[, d2d])

Draw a molecule without any mapping information.

gufe.visualization.mapping_visualization.draw_mapping(mol1_to_mol2: dict[int, int], mol1: rdkit.Chem.Mol, mol2: rdkit.Chem.Mol, d2d=None)

Method to visualise the atom map correspondence between two rdkit molecules given an input mapping.

Legend:
  • Red highlighted atoms: unique atoms, i.e. atoms which are not mapped.

  • Blue highlighted atoms: element changes, i.e. atoms which are mapped but change elements.

  • Red highlighted bonds: any bond which involves at least one unique atom or one element change.

Parameters:
  • mol1_to_mol2 (dict of int:int) – Atom mapping between input molecules.

  • mol1 (RDKit.Mol) – RDKit representation of molecule 1

  • mol2 (RDKit.Mol) – RDKit representation of molecule 2

  • d2d (rdkit.Chem.Draw.rdMolDraw2D.MolDraw2D) – Optional MolDraw2D backend to use for visualisation.

gufe.visualization.mapping_visualization.draw_one_molecule_mapping(mol1_to_mol2, mol1, mol2, d2d=None)

Draw the mapping visualization for a single molecular of a mapping

This will always draw molA. To draw molB, switch order/invert molA_to_molB mapping.

See draw_mapping() for details on the meaning of different colors.

Parameters:
  • mol1_to_mol2 (dict of int:int) – Atom mapping between input molecules.

  • mol1 (RDKit.Mol) – RDKit representation of molecule 1

  • mol2 (RDKit.Mol) – RDKit representation of molecule 2

  • d2d (rdkit.Chem.Draw.rdMolDraw2D.MolDraw2D) – Optional MolDraw2D backend to use for visualisation.

gufe.visualization.mapping_visualization.draw_unhighlighted_molecule(mol, d2d=None)

Draw a molecule without any mapping information.

This uses the same mechanisms as the mapping visualizations, and so can be useful in cases where you want the same visual style both for a plain molecule and a molecule with the mapping highlighted.

Parameters:
gufe.visualization.mapping_visualization.display_mapping_3d(mapping: LigandAtomMapping, spheres: bool = True, show_atomIDs: bool = False, style: str = 'stick', shift: tuple[float, float, float] | NDArray[np.float64] | None = None) py3Dmol.view

Render the LigandAtomMapping in 3D using py3Dmol.

By default matching atoms will be annotated using colored spheres.

py3Dmol is an optional dependency, it can be installed with:

pip install py3Dmol

Parameters:
  • mapping (LigandAtomMapping)

  • spheres (bool, default=True) – If True, show matching atoms as spheres (default=True).

  • show_atomIDs (bool, default=False) – If True, show atom IDs (default=False).

  • style (str, default='stick') – Style in which to represent the molecules in py3Dmol (default=’stick’).

  • shift (tuple[float,...], default=None) – Amount to shift molB by in order to visualize the two ligands. If None, the default shift will be estimated as the largest intraMol distance of both mols.

  • shift – Amount to shift molB by in order to visualize the two ligands. If None, the default shift will be estimated as the largest intraMol distance of both mols.

Returns:

view – View of the system containing both molecules in the edge.

Return type:

py3Dmol.view

gufe.visualization.mapping_visualization.display_mappings_3d(mappingSet: AtomMapping | list[AtomMapping]) widgets.VBox

Jupyter Visualization Widget This function is visualizing the provided list of mappings. It shows in the middle an overlay of the coordinates of the molecues, and left and right the mapping of the atoms (color of the spheres indicates partners). This function is tested in jupyter notebooks.

Parameters:

mappingSet (Union[AtomMapping, List[AtomMapping]]) – a list of atom mappings (gufe.AtomMapping objects)

Returns:

returns a widget, with the visualization and control elements.

Return type:

widgets.Vbox