luna.interaction.view module

class InteractionViewer(show_hydrop_surface=False, **kwargs)[source]

Bases: luna.wrappers.pymol.PymolSessionManager

Class that inherits from PymolSessionManager and implements set_view() to depict interactions in Pymol and save the view as a Pymol session.

This class can be used to visualize multiple complexes into the same Pymol session, for instance, to compare binding modes. To do so, it is recommended that the protein structures are in the same coordinate system, i.e., they should be aligned first. This can be achieved with luna.align.tmalign.align_2struct() or any other tool of your preference.

Parameters
  • show_hydrop_surface (bool) – If True, highlight hydrophobic surfaces. The default value is False

  • **kwargs (dict, optional) – Extra arguments to InteractionViewer. Refer to PymolSessionManager documentation for a list of all possible arguments.

Examples

In the below examples, we will assume a LUNA project object named proj_obj already exists.

Example 1) In the first example, we will visualize all interactions identified in the first protein-ligand complex. To do so, we will provide a tuple containing an InteractionsManager from where the interactions will be recovered.

First access the property interactions_mngrs to get an iterable of InteractionsManager objects and get the first one.

>>> interactions_mngr = list(proj_obj.interactions_mngrs)[0]

As InteractionViewer expects a list of tuples, we will define it now. The first item of the tuple is the Entry instance, which represents a ligand. This can be obtained directly from the InteractionsManager object. The Entry instance is necessary because the second item in the tuple (interactions) may be an iterable of InteractionType from where such information cannot be recovered. Finally, the third item can be either a PDB file or a directory. In this example, we will use the PDB directory defined during the LUNA project initialization.

>>> inter_tuples = [(interactions_mngr.entry, interactions_mngr, proj_obj.pdb_path)]

Now, we create a new InteractionViewer object and call new_session(), which will initialize the session, depict the interactions, and save the session to an output PSE file.

>>> inter_view = InteractionViewer()
>>> inter_view.new_session(inter_tuples, "output.pse")

Example 2) In this example, we will create a new Pymol session where a given set of interactions will be shown. Let’s say, for instance, we only want to visualize hydrogen bonds.

To do so, instead of defining a tuple with an InteractionsManager instance, we will define a list of InteractionType objects, which will contain only hydrogen bonds.

Let’s start with the selection of hydrogen bonds. Here, we will use the built-in method luna.interaction.calc.InteractionsManager.filter_by_types(), which permits to filter interactions by type.

>>> interactions_mngr = list(proj_obj.interactions_mngrs)[0]
>>> hydrogen_bonds = interactions_mngr.filter_by_types(['Hydrogen bond'])

Now, we just create the tuple as we did before and define the list of interactions we want to depict in the Pymol session.

>>> inter_tuples = [(interactions_mngr.entry, hydrogen_bonds, proj_obj.pdb_path)]

Finally, we create a new InteractionViewer object and call InteractionViewer.new_session(), which will initialize the session, depict the interactions, and save the session to an output PSE file.

>>> inter_view = InteractionViewer()
>>> inter_view.new_session(inter_tuples, "output.pse")

Example 3) In this final example, we will create a new Pymol session to visualize all complexes in a LUNA project. To do so, we create a list with one tuple for each complex:

>>> inter_tuples = [(im.entry, im, proj_obj.pdb_path) for im in proj_obj.interactions_mngrs]

Then, as we did before, just create a new InteractionViewer object and call InteractionViewer.new_session().

>>> inter_view = InteractionViewer()
>>> inter_view.new_session(inter_tuples, "output.pse")

Note: it is recommended that all complexes have the same atomic coordinates to make the analysis and comparisons easier. If that’s not the case, you may want to align the structures first. To do so, you can use luna.align.tmalign.align_2struct() or any other tool of your preference.

set_view(inter_tuples)[source]

Depict interactions into the current Pymol session.

Parameters

inter_tuples (iterable of tuple) – Each tuple must contain three items: an Entry instance, an iterable of InteractionType or an InteractionsManager, and a PDB file or the directory where the PDB file is located.